diff --git a/Build/build-pack-nano-nugets.psm1 b/Build/build-pack-nano-nugets.psm1 index e1981e6ba7..a51f78eb17 100644 --- a/Build/build-pack-nano-nugets.psm1 +++ b/Build/build-pack-nano-nugets.psm1 @@ -23,6 +23,8 @@ function Invoke-BuildNanoNugets { & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Mass\UnitsNet.NanoFramework.Mass.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\MassConcentration\UnitsNet.NanoFramework.MassConcentration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Angle\UnitsNet.NanoFramework.Angle.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" + & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\MagneticField\UnitsNet.NanoFramework.MagneticField.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" + & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Acceleration\UnitsNet.NanoFramework.Acceleration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" } diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index eca752f259..caa5bf7342 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -1,8 +1,8 @@ - + Exe - net6.0 + net8.0 latest enable @@ -10,10 +10,10 @@ - - - - + + + + diff --git a/CodeGen/Exceptions/UnitsNetCodeGenException.cs b/CodeGen/Exceptions/UnitsNetCodeGenException.cs index 2e98bc3e86..e25340993a 100644 --- a/CodeGen/Exceptions/UnitsNetCodeGenException.cs +++ b/CodeGen/Exceptions/UnitsNetCodeGenException.cs @@ -2,20 +2,11 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using System.Runtime.Serialization; namespace CodeGen.Exceptions { internal class UnitsNetCodeGenException : Exception { - public UnitsNetCodeGenException() - { - } - - protected UnitsNetCodeGenException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public UnitsNetCodeGenException(string message) : base(message) { } diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index d375bc8047..595490b2da 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,11 +25,11 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 6.0.0-pre002 + 6.0.0-pre006 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds {_quantity.Name} units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs index 0c5f762c04..1f3db9cf59 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs @@ -45,7 +45,7 @@ public static class NumberTo{_quantityName}Extensions continue; Writer.WL(2, $@" -/// "); +/// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit.ObsoleteText)); diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index f00adc0f88..2c7fabb36d 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Linq.Expressions; using CodeGen.Helpers; using CodeGen.JsonTypes; @@ -37,14 +38,11 @@ public string Generate() using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Linq;"); - if (_quantity.Relations.Any(r => r.Operator is "*" or "/")) - Writer.WL(@"#if NET7_0_OR_GREATER -using System.Numerics; -#endif"); - Writer.WL(@"using System.Runtime.Serialization; +using System.Linq; +using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -90,7 +88,7 @@ namespace UnitsNet default: continue; } - Writer.WL($"<{relation.LeftQuantity.Name}, {relation.RightQuantity.Name}, {relation.ResultQuantity.Name}>,"); + Writer.WL($"<{relation.LeftQuantity.Name}, {relation.RightQuantity.Name}, {relation.ResultQuantity.Name.Replace("double", "QuantityValue")}>,"); } } @@ -111,7 +109,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = ""Value"", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -203,7 +201,7 @@ private void GenerateInstanceConstructors() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public {_quantity.Name}(double value, {_unitEnumName} unit) + public {_quantity.Name}(QuantityValue value, {_unitEnumName} unit) {{"); Writer.WL(@" _value = value;"); @@ -219,7 +217,7 @@ private void GenerateInstanceConstructors() /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public {_quantity.Name}(double value, UnitSystem unitSystem) + public {_quantity.Name}(QuantityValue value, UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -290,10 +288,10 @@ private void GenerateProperties() /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -330,7 +328,7 @@ private void GenerateConversionProperties() /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public QuantityValue {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -421,7 +419,7 @@ private void GenerateStaticFactoryMethods() /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}(double value) + public static {_quantity.Name} From{unit.PluralName}(QuantityValue value) {{ return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); }} @@ -435,7 +433,7 @@ private void GenerateStaticFactoryMethods() /// Value to convert from. /// Unit to convert from. /// {_quantity.Name} unit value. - public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit) + public static {_quantity.Name} From(QuantityValue value, {_unitEnumName} fromUnit) {{ return new {_quantity.Name}(value, fromUnit); }} @@ -626,25 +624,25 @@ private void GenerateArithmeticOperators() }} /// Get from multiplying value and . - public static {_quantity.Name} operator *(double left, {_quantity.Name} right) + public static {_quantity.Name} operator *(QuantityValue left, {_quantity.Name} right) {{ return new {_quantity.Name}(left * right.Value, right.Unit); }} /// Get from multiplying value and . - public static {_quantity.Name} operator *({_quantity.Name} left, double right) + public static {_quantity.Name} operator *({_quantity.Name} left, QuantityValue right) {{ return new {_quantity.Name}(left.Value * right, left.Unit); }} /// Get from dividing by value. - public static {_quantity.Name} operator /({_quantity.Name} left, double right) + public static {_quantity.Name} operator /({_quantity.Name} left, QuantityValue right) {{ return new {_quantity.Name}(left.Value / right, left.Unit); }} /// Get ratio value from dividing by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + public static QuantityValue operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -672,7 +670,10 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic addition // Formula: {x} * log10(10^(x/{x}) + 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value / {x}) + Math.Pow(10, right.ToUnit(left.Unit).Value / {x})), left.Unit); + // TODO see if we can switch to operating in linear space: left + right.ToUnit(left.Unit) + return new {_quantity.Name}({x} * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / {x}).ToDouble()) + Math.Pow(10, (right.ToUnit(left.Unit).Value / {x}).ToDouble()))), + left.Unit); }} /// Get from logarithmic subtraction of two . @@ -680,35 +681,39 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic subtraction // Formula: {x} * log10(10^(x/{x}) - 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value / {x}) - Math.Pow(10, right.ToUnit(left.Unit).Value / {x})), left.Unit); + // TODO see if we can switch to operating in linear space: left - right.ToUnit(left.Unit) + return new {_quantity.Name}({x} * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / {x}).ToDouble()) - Math.Pow(10, (right.ToUnit(left.Unit).Value / {x}).ToDouble()))), + left.Unit); }} /// Get from logarithmic multiplication of value and . - public static {_quantity.Name} operator *(double left, {_quantity.Name} right) + public static {_quantity.Name} operator *(QuantityValue left, {_quantity.Name} right) {{ // Logarithmic multiplication = addition + // TODO see if we can switch to operating in linear space: left * right.ToUnit(left.Unit) return new {_quantity.Name}(left + right.Value, right.Unit); }} /// Get from logarithmic multiplication of value and . - public static {_quantity.Name} operator *({_quantity.Name} left, double right) + public static {_quantity.Name} operator *({_quantity.Name} left, QuantityValue right) {{ // Logarithmic multiplication = addition return new {_quantity.Name}(left.Value + right, left.Unit); }} /// Get from logarithmic division of by value. - public static {_quantity.Name} operator /({_quantity.Name} left, double right) + public static {_quantity.Name} operator /({_quantity.Name} left, QuantityValue right) {{ // Logarithmic division = subtraction return new {_quantity.Name}(left.Value - right, left.Unit); }} /// Get ratio value from logarithmic division of by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + public static QuantityValue operator /({_quantity.Name} left, {_quantity.Name} right) {{ // Logarithmic division = subtraction - return Convert.ToDouble(left.Value - right.ToUnit(left.Unit).Value); + return left.Value - right.ToUnit(left.Unit).Value; }} #endregion @@ -735,46 +740,55 @@ private void GenerateRelationalOperators() /// The corresponding inverse quantity, . public {relation.RightQuantity.Name} Inverse() {{ - return {relation.LeftUnit.PluralName} == 0.0 ? {relation.RightQuantity.Name}.Zero : {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(1 / {relation.LeftUnit.PluralName}); + return {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(QuantityValue.Inverse({relation.LeftUnit.PluralName})); }} "); } else { - var leftParameter = relation.LeftQuantity.Name.ToCamelCase(); + var leftParameterType = relation.LeftQuantity.Name; + var leftParameterName = leftParameterType.ToCamelCase(); var leftConversionProperty = relation.LeftUnit.PluralName; - var rightParameter = relation.RightQuantity.Name.ToCamelCase(); + var rightParameterType = relation.RightQuantity.Name; + var rightParameterName = relation.RightQuantity.Name.ToCamelCase(); var rightConversionProperty = relation.RightUnit.PluralName; - if (leftParameter == rightParameter) + if (leftParameterName == rightParameterName) { - leftParameter = "left"; - rightParameter = "right"; + leftParameterName = "left"; + rightParameterName = "right"; } - var leftPart = $"{leftParameter}.{leftConversionProperty}"; - var rightPart = $"{rightParameter}.{rightConversionProperty}"; + var leftPart = $"{leftParameterName}.{leftConversionProperty}"; + var rightPart = $"{rightParameterName}.{rightConversionProperty}"; - if (leftParameter is "double") + if (leftParameterName is "double") { - leftParameter = leftPart = "value"; + leftParameterType = "QuantityValue"; + leftParameterName = leftPart = "value"; } - if (rightParameter is "double") + if (rightParameterName is "double") { - rightParameter = rightPart = "value"; + rightParameterType = "QuantityValue"; + rightParameterName = rightPart = "value"; } var expression = $"{leftPart} {relation.Operator} {rightPart}"; - if (relation.ResultQuantity.Name is not "double") + var resultType = relation.ResultQuantity.Name; + if (resultType is "double") { - expression = $"{relation.ResultQuantity.Name}.From{relation.ResultUnit.PluralName}({expression})"; + resultType = "QuantityValue"; + } + else + { + expression = $"{resultType}.From{relation.ResultUnit.PluralName}({expression})"; } Writer.WL($@" - /// Get from {relation.Operator} . - public static {relation.ResultQuantity.Name} operator {relation.Operator}({relation.LeftQuantity.Name} {leftParameter}, {relation.RightQuantity.Name} {rightParameter}) + /// Get from {relation.Operator} . + public static {resultType} operator {relation.Operator}({leftParameterType} {leftParameterName}, {rightParameterType} {rightParameterName}) {{ return {expression}; }} @@ -817,27 +831,20 @@ private void GenerateEqualityAndComparison() return left.Value > right.ToUnit(left.Unit).Value; }} - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete(""For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] + /// Indicates strict equality of two quantities. public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) {{ return left.Equals(right); }} - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete(""For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] + /// Indicates strict inequality of two quantities. public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) {{ return !(left == right); }} /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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."")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) {{ if (obj is null || !(obj is {_quantity.Name} otherQuantity)) @@ -847,15 +854,12 @@ public override bool Equals(object? obj) }} /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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."")] + /// Indicates strict equality of two quantities. public bool Equals({_quantity.Name} other) {{ - return new {{ Value, Unit }}.Equals(new {{ other.Value, other.Unit }}); + return _value.Equals(other.As(this.Unit)); }} - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -938,10 +942,10 @@ public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), ""Tolerance must be greater than or equal to 0.""); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); }} @@ -958,7 +962,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals({_quantity.Name} other, {_quantity.Name} tolerance) {{ - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -971,7 +975,12 @@ public bool Equals({_quantity.Name} other, {_quantity.Name} tolerance) /// A hash code for the current {_quantity.Name}. public override int GetHashCode() {{ - return new {{ Info.Name, Value, Unit }}.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new {{ Info.Name, valueInBaseUnit }}.GetHashCode(); + #endif }} #endregion @@ -987,7 +996,7 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As({_unitEnumName} unit) + public QuantityValue As({_unitEnumName} unit) {{ if (Unit == unit) return Value; @@ -999,7 +1008,7 @@ public double As({_unitEnumName} unit) Writer.WL($@" /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1016,7 +1025,7 @@ public double As(UnitSystem unitSystem) Writer.WL($@" /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) {{ if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); @@ -1087,7 +1096,7 @@ private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity. { if (unit.SingularName == _quantity.BaseUnit) continue; - var func = unit.FromUnitToBaseFunc.Replace("{x}", "_value"); + var func = unit.GetUnitToBaseConversionFormat("_value"); Writer.WL($@" ({_unitEnumName}.{unit.SingularName}, {_unitEnumName}.{_quantity.BaseUnit}) => new {_quantity.Name}({func}, {_unitEnumName}.{_quantity.BaseUnit}),"); } @@ -1100,7 +1109,7 @@ private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity. { if (unit.SingularName == _quantity.BaseUnit) continue; - var func = unit.FromBaseToUnitFunc.Replace("{x}", "_value"); + var func = unit.GetFromBaseToUnitConversionFormat("_value"); Writer.WL($@" ({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{unit.SingularName}) => new {_quantity.Name}({func}, {_unitEnumName}.{unit.SingularName}),"); } diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 4dc356fd1e..502437b592 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -49,7 +49,7 @@ public partial class Quantity /// The of the quantity to create. /// The value to construct the quantity with. /// The created quantity. - public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value) + public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValue value) { return quantityInfo.Name switch {"); @@ -72,7 +72,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value /// Unit enum value. /// The resulting quantity if successful, otherwise default. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(double value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) { quantity = unit switch {"); diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 6c0b3b9c2c..348017ba1c 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -160,7 +160,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal({_baseUnitFullName}, quantity.Unit); }} - [Fact] + [Fact(Skip = ""https://github.com/danm-de/Fractions/issues/26"")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() {{ var exception1 = Record.Exception(() => new {_quantity.Name}(double.PositiveInfinity, {_baseUnitFullName})); @@ -170,7 +170,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); }} - [Fact] + [Fact(Skip = ""https://github.com/danm-de/Fractions/issues/26"")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() {{ var exception = Record.Exception(() => new {_quantity.Name}(double.NaN, {_baseUnitFullName})); @@ -240,7 +240,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() Writer.WL($@" }} - [Fact] + [Fact(Skip = ""https://github.com/danm-de/Fractions/issues/26"")] public void From{_baseUnit.PluralName}_WithInfinityValue_DoNotThrowsArgumentException() {{ var exception1 = Record.Exception(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.PositiveInfinity)); @@ -250,7 +250,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() Assert.Null(exception2); }} - [Fact] + [Fact(Skip = ""https://github.com/danm-de/Fractions/issues/26"")] public void From{_baseUnit.PluralName}_WithNanValue_DoNotThrowsArgumentException() {{ var exception = Record.Exception(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NaN)); @@ -501,13 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, {_baseUnitFullName}, 1, {_baseUnitFullName}, true)] // Same value and unit. [InlineData(1, {_baseUnitFullName}, 2, {_baseUnitFullName}, false)] // Different value. - [InlineData(2, {_baseUnitFullName}, 1, {_otherOrBaseUnitFullName}, false)] // Different value and unit."); - if (_baseUnit != _otherOrBaseUnit) - { - Writer.WL($@" - [InlineData(1, {_baseUnitFullName}, 1, {_otherOrBaseUnitFullName}, false)] // Different unit."); - } - Writer.WL($@" public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, {_unitEnumName} unitA, double valueB, {_unitEnumName} unitB, bool expectEqual) {{ var a = new {_quantity.Name}(valueA, unitA); @@ -816,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() 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()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine({_quantity.Name}.Info.Name, quantity.{_baseUnit.PluralName}); + #else + var expected = new {{{_quantity.Name}.Info.Name, valueInBaseUnit = quantity.{_baseUnit.PluralName}}}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); }} "); diff --git a/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluationTerm.cs b/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluationTerm.cs new file mode 100644 index 0000000000..559e476240 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluationTerm.cs @@ -0,0 +1,14 @@ +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer; + +/// +/// A term of the form "P^n" where P is a term that hasn't been parsed, raised to the given power. +/// +/// The actual expression to parse +/// The exponent to use on the parsed expression (default is 1) +/// +/// Since we're tokenizing the expressions from top to bottom, the first step is parsing the exponent of the +/// expression: e.g. Math.Pow(P, 2) +/// +public record ExpressionEvaluationTerm(string Expression, Fraction Exponent); diff --git a/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluator.cs new file mode 100644 index 0000000000..9833152db1 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/ExpressionEvaluator.cs @@ -0,0 +1,294 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; +using CodeGen.Helpers.ExpressionAnalyzer.Functions; +using CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; +using CodeGen.Helpers.ExpressionAnalyzer.Functions.Math.Trigonometry; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer; + +internal class ExpressionEvaluator // TODO make public (and move out in a separate project) +{ + private static readonly Fraction Pi = FractionExtensions.FromDoubleRounded(Math.PI); + private readonly IReadOnlyDictionary _constantValues; + private readonly Dictionary _expressionsEvaluated = []; + + private readonly IReadOnlyDictionary _functionEvaluators; + + public ExpressionEvaluator(string parameterName, params IFunctionEvaluator[] functionEvaluators) + : this(parameterName, functionEvaluators.ToDictionary(x => x.FunctionName), new Dictionary()) + { + } + + public ExpressionEvaluator(string parameterName, IReadOnlyDictionary constantValues, params IFunctionEvaluator[] functionEvaluators) + : this(parameterName, functionEvaluators.ToDictionary(x => x.FunctionName), constantValues) + { + } + + public ExpressionEvaluator(string parameterName, IReadOnlyDictionary functionEvaluators, + IReadOnlyDictionary constantValues) + { + ParameterName = parameterName; + _constantValues = constantValues; + _functionEvaluators = functionEvaluators; + } + + public string ParameterName { get; } + + protected string Add(CompositeExpression expression) + { + var label = "{" + (char)('a' + _expressionsEvaluated.Count) + "}"; + _expressionsEvaluated[label] = expression; + return label; + } + + public CompositeExpression Evaluate(ExpressionEvaluationTerm expressionEvaluationTerm) // TODO either replace by string or add a coefficient + { + if (TryParseExpressionTerm(expressionEvaluationTerm.Expression, expressionEvaluationTerm.Exponent, out ExpressionTerm? expressionTerm)) + { + return expressionTerm; + } + + var expressionToParse = expressionEvaluationTerm.Expression; + Fraction exponent = expressionEvaluationTerm.Exponent; + string previousExpression; + do + { + previousExpression = expressionToParse; + // the regex captures the innermost occurrence of a function group: "Sin(x)", "Pow(x, y)", "(x + 1)" are all valid matches + expressionToParse = Regex.Replace(expressionToParse, @"(\w*)\(([^()]*)\)", match => + { + var functionName = match.Groups[1].Value; + var functionBodyToParse = match.Groups[2].Value; + var evaluationTerm = new ExpressionEvaluationTerm(functionBodyToParse, exponent); + if (string.IsNullOrEmpty(functionName)) // standard grouping (technically this is equivalent to f(x) -> x) + { + // all terms within the group are expanded: extract the simplified expression + CompositeExpression expression = ReplaceTokenizedExpressions(evaluationTerm); + return Add(expression); + } + + if (_functionEvaluators.TryGetValue(functionName, out IFunctionEvaluator? functionEvaluator)) + { + // resolve the expression using the custom function evaluator + CompositeExpression expression = functionEvaluator.CreateExpression(evaluationTerm, ReplaceTokenizedExpressions); + return Add(expression); + } + + throw new FormatException($"No function evaluator available for {functionName}({functionBodyToParse})"); + }); + } while (previousExpression != expressionToParse); + + return ReplaceTokenizedExpressions(expressionEvaluationTerm with { Expression = expressionToParse }); + } + + private CompositeExpression ReplaceTokenizedExpressions(ExpressionEvaluationTerm tokenizedExpression) + { + // all groups and function are expanded: we're left with a standard arithmetic expression such as "4 * a + 2 * b * x - c - d + 5" + // with a, b, c, d representing the previously evaluated expressions + var result = new CompositeExpression(); + var stringBuilder = new StringBuilder(); + ArithmeticOperationToken lastToken = ArithmeticOperationToken.Addition; + CompositeExpression? runningExpression = null; + foreach (var character in tokenizedExpression.Expression) + { + if (!TryReadToken(character, out ArithmeticOperationToken currentToken)) // TODO use None? + { + continue; + } + + switch (currentToken) + { + case ArithmeticOperationToken.Addition or ArithmeticOperationToken.Subtraction: + { + if (stringBuilder.Length == 0) // ignore the leading sign + { + lastToken = currentToken; + continue; + } + + // we're at the end of a term expression + CompositeExpression lastTerm = ParseTerm(); + if (runningExpression is null) + { + result.AddTerms(lastTerm); + } + else // the last term is part of a running multiplication + { + result.AddTerms(runningExpression * lastTerm); + runningExpression = null; + } + + lastToken = currentToken; + break; + } + case ArithmeticOperationToken.Multiplication or ArithmeticOperationToken.Division: + { + CompositeExpression previousTerm = ParseTerm(); + if (runningExpression is null) + { + runningExpression = previousTerm; + } + else // the previousTerm term is part of a running multiplication (which is going to be followed by at least one more multiplication/division) + { + runningExpression *= previousTerm; + } + + lastToken = currentToken; + break; + } + } + } + + CompositeExpression finalTerm = ParseTerm(); + if (runningExpression is null) + { + result.AddTerms(finalTerm); + } + else + { + result.AddTerms(runningExpression * finalTerm); + } + + return result; + + bool TryReadToken(char character, out ArithmeticOperationToken token) + { + switch (character) + { + case '+': + token = ArithmeticOperationToken.Addition; + return true; + case '-': + token = ArithmeticOperationToken.Subtraction; + return true; + case '*': + token = ArithmeticOperationToken.Multiplication; + return true; + case '/': + token = ArithmeticOperationToken.Division; + return true; + case not ' ': + stringBuilder.Append(character); + break; + } + + token = default; + return false; + } + + CompositeExpression ParseTerm() + { + var previousExpression = stringBuilder.ToString(); + stringBuilder.Clear(); + if (_expressionsEvaluated.TryGetValue(previousExpression, out CompositeExpression? expression)) + { + return lastToken switch + { + ArithmeticOperationToken.Subtraction => expression.Negate(), + ArithmeticOperationToken.Division => expression.Invert(), + _ => expression + }; + } + + if (TryParseExpressionTerm(previousExpression, tokenizedExpression.Exponent, out ExpressionTerm? expressionTerm)) + { + return lastToken switch + { + ArithmeticOperationToken.Subtraction => expressionTerm.Negate(), + ArithmeticOperationToken.Division => expressionTerm.Invert(), + _ => expressionTerm + }; + } + + throw new FormatException($"Failed to parse the previous token: {previousExpression}"); + } + } + + + private bool TryParseExpressionTerm(string expressionToParse, Fraction exponent, [MaybeNullWhen(false)] out ExpressionTerm expressionTerm) + { + if (expressionToParse == ParameterName) + { + expressionTerm = new ExpressionTerm(Fraction.One, exponent); + return true; + } + + if (_constantValues.TryGetValue(expressionToParse, out Fraction constantExpression) || Fraction.TryParse(expressionToParse, out constantExpression)) + { + if (exponent.Numerator == exponent.Denominator) + { + expressionTerm = ExpressionTerm.Constant(constantExpression); + return true; + } + + if (exponent.Denominator.IsOne) + { + expressionTerm = ExpressionTerm.Constant(Fraction.Pow(constantExpression, (int)exponent.Numerator)); + return true; + } + + // constant expression using a non-integer power: there is currently no Fraction.Pow(Fraction, Fraction) + expressionTerm = ExpressionTerm.Constant(FractionExtensions.FromDoubleRounded(Math.Pow(constantExpression.ToDouble(), exponent.ToDouble()))); + return true; + } + + expressionTerm = null; + return false; + } + + public static string ReplaceDecimalNotations(string expression, Dictionary constantValues) + { + return Regex.Replace(expression, @"\d*(\.\d*)?[eE][-\+]?\d*[dD]?", match => + { + var tokens = match.Value.ToLower().Replace("d", "").Split('e'); + if (tokens.Length != 2 || !Fraction.TryParse(tokens[0], out Fraction mantissa) || !int.TryParse(tokens[1], out var exponent)) + { + throw new FormatException($"The expression contains invalid tokens: {expression}"); + } + + var label = $"{{v{constantValues.Count}}}"; + constantValues[label] = mantissa * Fraction.Pow(10, exponent); + return label; + }).Replace("d", string.Empty); // TODO these are force-generated for the BitRate (we should stop doing it) + } + + public static string ReplaceMathPi(string expression, Dictionary constantValues) + { + return Regex.Replace(expression, @"Math\.PI", _ => + { + constantValues[nameof(Pi)] = Pi; + return nameof(Pi); + }); + } + + public static CompositeExpression Evaluate(string expression, string parameter) + { + var constantExpressions = new Dictionary(); + + expression = ReplaceDecimalNotations(expression, constantExpressions); // TODO expose an IPreprocessor (or something) + expression = ReplaceMathPi(expression, constantExpressions); + expression = expression.Replace("Math.", string.Empty); + + var expressionEvaluator = new ExpressionEvaluator(parameter, constantExpressions, + new SqrtFunctionEvaluator(), + new PowFunctionEvaluator(), + new SinFunctionEvaluator(), + new AsinFunctionEvaluator()); + + return expressionEvaluator.Evaluate(new ExpressionEvaluationTerm(expression, Fraction.One)); + } + + private enum ArithmeticOperationToken + { + Addition, + Subtraction, + Multiplication, + Division + } +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CompositeExpression.cs b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CompositeExpression.cs new file mode 100644 index 0000000000..1edc2a38ef --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CompositeExpression.cs @@ -0,0 +1,166 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Expressions; + +/// +/// A set of terms, ordered by their degree: "P(x)^2 + P(x) + 1" +/// +internal class CompositeExpression : IEnumerable +{ + private readonly SortedSet _terms; + + /// + /// Initializes a new instance of the class. + /// + /// + /// This constructor creates an empty CompositeExpression with terms sorted in descending order. + /// + public CompositeExpression() + { + _terms = new SortedSet(DescendingOrderComparer); + } + + /// + /// Initializes a new instance of the class with a single term. + /// + /// The initial term of the composite expression. + /// + /// This constructor creates a CompositeExpression with a single term, sorted in descending order. + /// + public CompositeExpression(ExpressionTerm term) + { + _terms = new SortedSet(DescendingOrderComparer) { term }; + } + + private CompositeExpression(IEnumerable terms) + { + _terms = new SortedSet(terms, DescendingOrderComparer); + } + + public Fraction Degree => _terms.Min?.Exponent ?? Fraction.Zero; + + public bool IsConstant => Degree == Fraction.Zero; + + public IReadOnlyCollection Terms => _terms; + + public void Add(ExpressionTerm term) + { + if (_terms.TryGetValue(term, out ExpressionTerm? sameDegreeTerm)) + { + // merge the two terms + term = term with { Coefficient = sameDegreeTerm.Coefficient + term.Coefficient }; + _terms.Remove(sameDegreeTerm); + } + + _terms.Add(term); + } + + public void AddTerms(IEnumerable expressionTerms) + { + foreach (ExpressionTerm term in expressionTerms) + { + Add(term); + } + } + + + public static implicit operator CompositeExpression(ExpressionTerm term) + { + return new CompositeExpression(term); + } + + public static explicit operator ExpressionTerm(CompositeExpression term) + { + return term._terms.Max!; + } + + public CompositeExpression Negate() + { + return new CompositeExpression(_terms.Select(term => term.Negate())); + } + + public CompositeExpression Invert() + { + return new CompositeExpression(_terms.Select(term => term.Invert())); + } + + public CompositeExpression Multiply(CompositeExpression other) + { + var result = new CompositeExpression(); + foreach (ExpressionTerm otherTerm in other) + { + result.AddTerms(_terms.Select(x => x.Multiply(otherTerm))); + } + + return result; + } + + public CompositeExpression Divide(CompositeExpression other) + { + var result = new CompositeExpression(); + foreach (ExpressionTerm otherTerm in other) + { + result.AddTerms(_terms.Select(x => x.Divide(otherTerm))); + } + + return result; + } + + public static CompositeExpression operator *(CompositeExpression left, CompositeExpression right) + { + return left.Multiply(right); + } + + public static CompositeExpression operator /(CompositeExpression left, CompositeExpression right) + { + return left.Divide(right); + } + + public override string ToString() + { + return string.Join(" + ", _terms); + } + + public CompositeExpression Evaluate(Fraction x) + { + var result = new CompositeExpression(); + result.AddTerms(_terms.Select(t => t.Evaluate(x))); + return result; + } + + #region TermComparer + + private sealed class DescendingOrderTermComparer : IComparer + { + public int Compare(ExpressionTerm? y, ExpressionTerm? x) + { + if (ReferenceEquals(x, y)) return 0; + if (ReferenceEquals(null, y)) return 1; + if (ReferenceEquals(null, x)) return -1; + var nestedFunctionComparison = Comparer.Default.Compare(x.NestedFunction, y.NestedFunction); + if (nestedFunctionComparison != 0) return nestedFunctionComparison; + return x.Exponent.CompareTo(y.Exponent); + } + } + + public static IComparer DescendingOrderComparer { get; } = new DescendingOrderTermComparer(); + + #endregion + + #region Implementation of IEnumerable + + public IEnumerator GetEnumerator() + { + return _terms.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CustomFunction.cs b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CustomFunction.cs new file mode 100644 index 0000000000..4144b69afc --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/CustomFunction.cs @@ -0,0 +1,42 @@ +using System; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Expressions; + +/// +/// A custom function f(ax^n + bx^m) +/// +/// +/// +/// +/// These are functions that we don't directly support, such as Sqrt. +internal record CustomFunction(string Name, CompositeExpression Terms, params string[] AdditionalParameters) : IComparable, IComparable +{ + #region Overrides of Object + + public override string ToString() + { + if(AdditionalParameters.Length == 0) + return $"{Name}({Terms})"; + return $"{Name}({Terms}, {string.Join(", ", AdditionalParameters)})"; + } + + #endregion + + #region Relational members + + public int CompareTo(CustomFunction? other) + { + if (ReferenceEquals(this, other)) return 0; + if (ReferenceEquals(null, other)) return 1; + return string.Compare(Name, other.Name, StringComparison.Ordinal); + } + + public int CompareTo(object? obj) + { + if (ReferenceEquals(null, obj)) return 1; + if (ReferenceEquals(this, obj)) return 0; + return obj is CustomFunction other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(CustomFunction)}"); + } + + #endregion +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Expressions/ExpressionTerm.cs b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/ExpressionTerm.cs new file mode 100644 index 0000000000..c295f9ba35 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Expressions/ExpressionTerm.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Numerics; +using CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Expressions; + +/// +/// A term of the form "a * f(x)^n". +/// +/// The constant coefficient (a) +/// The degree of the term (n) +/// f(x) if one is available +/// When there is no nested function f(x) = x +internal record ExpressionTerm(Fraction Coefficient, Fraction Exponent, CustomFunction? NestedFunction = null) : IComparable, IComparable +{ + public bool IsRational => NestedFunction is null && Exponent.Denominator <= BigInteger.One; + + public bool IsConstant => NestedFunction is null && Exponent == Fraction.Zero; + + public ExpressionTerm Negate() + { + return this with { Coefficient = Coefficient.Invert() }; + } + + public ExpressionTerm Invert() + { + return this with { Exponent = Exponent.Invert(), Coefficient = 1 / Coefficient }; + } + + public ExpressionTerm Multiply(ExpressionTerm otherTerm) + { + if (NestedFunction != null && otherTerm.NestedFunction != null && + NestedFunction != otherTerm.NestedFunction) // there aren't any cases of this in the code-base + { + throw new NotSupportedException( + "Multiplying terms with different functions is currently not supported"); // if we need to, we should use a collection or create some function-composition + } + + return new ExpressionTerm(Coefficient * otherTerm.Coefficient, Exponent + otherTerm.Exponent, NestedFunction ?? otherTerm.NestedFunction); + } + + public ExpressionTerm Divide(ExpressionTerm otherTerm) + { + return Multiply(otherTerm.Invert()); + } + + public static ExpressionTerm Constant(Fraction coefficient) + { + return new ExpressionTerm(coefficient, Fraction.Zero); + } + + #region Overrides of Object + + public override string ToString() + { + var coefficientFormat = Coefficient == Fraction.One ? "" : + Coefficient == Fraction.MinusOne ? "-" : $"{Coefficient.ToDouble()} * "; + if (NestedFunction == null) + { + if (Exponent == Fraction.Zero) + { + return $"{Coefficient.ToDouble()}"; + } + + if (Exponent == Fraction.One) + { + return $"{coefficientFormat}x"; + } + + return $"{coefficientFormat}x^{Exponent.ToDouble()}"; + } + + return $"{coefficientFormat}{NestedFunction}"; + } + + #endregion + + public ExpressionTerm Evaluate(Fraction x) + { + if (NestedFunction != null || Exponent.IsZero) + { + return this; + } + + return IsRational + ? Constant(Coefficient * Fraction.Pow(x, Exponent.ToInt32())) + : Constant(Coefficient * FractionExtensions.FromDoubleRounded(Math.Pow(x.ToDouble(), Exponent.ToDouble()))); + } + + #region Relational members + + public int CompareTo(ExpressionTerm? other) + { + if (ReferenceEquals(this, other)) return 0; + if (other is null) return 1; + var exponentComparison = Exponent.CompareTo(other.Exponent); + if (exponentComparison != 0) return exponentComparison; + var nestedFunctionComparison = Comparer.Default.Compare(NestedFunction, other.NestedFunction); + if (nestedFunctionComparison != 0) return nestedFunctionComparison; + return Coefficient.CompareTo(other.Coefficient); + } + + public int CompareTo(object? obj) + { + if (ReferenceEquals(null, obj)) return 1; + if (ReferenceEquals(this, obj)) return 0; + return obj is ExpressionTerm other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(ExpressionTerm)}"); + } + + #endregion +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/IFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/IFunctionEvaluator.cs new file mode 100644 index 0000000000..3af9dcd222 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/IFunctionEvaluator.cs @@ -0,0 +1,26 @@ +using System; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions; + +/// +/// Defines the contract for a function evaluator that can parse and create expressions. +/// +/// +/// Implementations of this interface are used to evaluate specific mathematical functions. +/// +internal interface IFunctionEvaluator +{ + /// + /// Gets the name of the function that this evaluator can handle. + /// + string FunctionName { get; } + + /// + /// Parses the given expression and returns a pending term. + /// + /// The expression to parse. + /// Can be used to evaluate the function body expression. + /// A that represents the parsed expression. + CompositeExpression CreateExpression(ExpressionEvaluationTerm expressionToParse, Func expressionResolver); +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/FractionExtensions.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/FractionExtensions.cs new file mode 100644 index 0000000000..3c914e4ee9 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/FractionExtensions.cs @@ -0,0 +1,138 @@ +// 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.Numerics; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; + +/// +/// We should try to push these extensions to the original library (working on the PRs) +/// +internal static class FractionExtensions +{ + public static readonly Fraction OneHalf = new(BigInteger.One, new BigInteger(2)); + public static readonly BigInteger Ten = new(10); + + public static Fraction Pow(this Fraction x, Fraction power) + { + if (power == Fraction.One) + { + return x; + } + + if (x == Fraction.One) + { + return x; + } + + if (power.Denominator == Fraction.One) + { + return Fraction.Pow(x, (int)power); + } + + // return FractionExtensions.FromDoubleRounded(System.Math.Pow(x.ToDouble(), power.ToDouble())); + return PowRational(x, power); + // if (power == OneHalf) + // { + // return x.Sqrt(); + // } + // + } + + private static Fraction PowRational(this Fraction x, Fraction power) + { + var numeratorRaised = Fraction.Pow(x, (int)power.Numerator); + return numeratorRaised.Root((int)power.Denominator, BigInteger.Pow(10, 12)); + } + + public static Fraction Root(this Fraction number, int n, BigInteger precision) + { + // Fraction x = number; // Initial guess + var initialGuess = System.Math.Pow(number.ToDouble(), 1.0/n); + Fraction x = + initialGuess == 0.0 ? number: + FromDoubleRounded(initialGuess); // Initial guess + Fraction xPrev; + var minChange = new Fraction(1, precision); + do + { + xPrev = x; + x = ((n - 1) * x + number / Fraction.Pow(x, n - 1)) / n; + } while ((x - xPrev).Abs() > minChange); + return x; + } + + /// + /// Converts a floating point value to a QuantityValue. The value is rounded if possible. + /// + /// The floating point value to convert. + /// + /// A QuantityValue representing the rounded floating point value. + /// + /// The double data type stores its values as 64-bit floating point numbers in accordance with the IEC 60559:1989 (IEEE + /// 754) standard for binary floating-point arithmetic. + /// However, the double data type cannot precisely store some binary fractions. For instance, 1/10, which is accurately + /// represented by .1 as a decimal fraction, is represented by .0001100110011... as a binary fraction, with the pattern + /// 0011 repeating indefinitely. + /// In such cases, the floating-point value provides an approximate representation of the number. + /// + /// This method can be used to avoid large numbers in the numerator and denominator. However, be aware that the + /// creation speed is significantly slower than using the pure value resulting from casting to double. + /// + /// + /// + /// This example shows how to use the method. + /// + /// QuantityValue qv = QuantityValue.FromDoubleRounded(0.1); + /// // Output: 1/10, which is exactly 0.1 + /// + /// + public static Fraction FromDoubleRounded(double value, int nbSignificantDigits = 15) + { + if (value == 0) + { + return Fraction.Zero; + } + + // Determine the number of decimal places to keep + var magnitude = System.Math.Floor( System.Math.Log10( System.Math.Abs(value))); + if (magnitude > nbSignificantDigits) + { + var digitsToKeep = new BigInteger(value / System.Math.Pow(10, magnitude - nbSignificantDigits)); + return digitsToKeep * BigInteger.Pow(Ten, (int)magnitude - nbSignificantDigits); + } + + // "decimal" values + var truncatedValue = System.Math.Truncate(value); + var integerPart = new BigInteger(truncatedValue); + + var decimalPlaces = System.Math.Min(-(int)magnitude + nbSignificantDigits - 1, 308); + var scaleFactor = System.Math.Pow(10, decimalPlaces); + // Get the fractional part + var fractionalPartDouble = System.Math.Round((value - truncatedValue) * scaleFactor); + if (fractionalPartDouble == 0) // rounded to integer + { + return new Fraction(integerPart); + } + + var denominator = BigInteger.Pow(Ten, decimalPlaces); + BigInteger numerator = integerPart * denominator + new BigInteger(fractionalPartDouble); + return new Fraction(numerator, denominator); + } + + /// + /// Rounds the given Fraction to the specified number of digits. + /// + /// The Fraction to be rounded. + /// The number of decimal places in the return value. + /// A new Fraction that is the nearest number with the specified number of digits. + public static Fraction Round(this Fraction x, int nbDigits) + { + var factor = BigInteger.Pow(10, nbDigits); + var numerator = x.Numerator * factor; + var roundedNumerator = BigInteger.Divide(numerator + x.Denominator / 2, x.Denominator); + return new Fraction(roundedNumerator, factor); + } +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/MathFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/MathFunctionEvaluator.cs new file mode 100644 index 0000000000..bee042aa92 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/MathFunctionEvaluator.cs @@ -0,0 +1,26 @@ +using System; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; + +internal abstract class MathFunctionEvaluator : IFunctionEvaluator +{ + public abstract string FunctionName { get; } + + public CompositeExpression CreateExpression(ExpressionEvaluationTerm expressionToParse, Func expressionResolver) + { + CompositeExpression functionBody = expressionResolver(expressionToParse with {Exponent = 1}); + Fraction power = expressionToParse.Exponent; + if (functionBody.IsConstant) // constant expression (directly evaluate the function) + { + var constantTerm = (ExpressionTerm)functionBody; + Fraction resultingValue = Evaluate(constantTerm.Coefficient); + return ExpressionTerm.Constant(resultingValue.Pow(power)); + } + // we cannot expand a function of x + return new ExpressionTerm(1, power, new CustomFunction(FunctionName, functionBody)); + } + + public abstract Fraction Evaluate(Fraction value); +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/PowFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/PowFunctionEvaluator.cs new file mode 100644 index 0000000000..2654aa1362 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/PowFunctionEvaluator.cs @@ -0,0 +1,51 @@ +using System; +using System.Globalization; +using System.Numerics; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; + +internal class PowFunctionEvaluator : IFunctionEvaluator +{ + private static readonly Fraction OneHalf = new(BigInteger.One, new BigInteger(2)); + public string FunctionName => nameof(System.Math.Pow); + + public bool ExpandNonConstantExpressions { get; set; } = false; // while it's possible to expand the expression (even for non-rational powers)- probably we shouldn't + + public CompositeExpression CreateExpression(ExpressionEvaluationTerm expressionToParse, + Func expressionResolver) + { + var functionParams = expressionToParse.Expression.Split(','); + if (functionParams.Length != 2 || !Fraction.TryParse(functionParams[1], out Fraction exponentParsed)) + { + throw new FormatException($"The provided string is not in the correct format for the Pow function {expressionToParse}"); + } + + CompositeExpression functionBody = expressionResolver(new ExpressionEvaluationTerm(functionParams[0], 1)); + Fraction power = expressionToParse.Exponent * exponentParsed; + + if (functionBody.IsConstant) + { + var singleTerm = (ExpressionTerm)functionBody; + Fraction coefficient = singleTerm.Coefficient.Pow(power); + return ExpressionTerm.Constant(coefficient); + } + + if (!ExpandNonConstantExpressions) + { + return new ExpressionTerm(1, 1, new CustomFunction(FunctionName, functionBody, power.ToDecimal().ToString(CultureInfo.InvariantCulture))); + } + + // while it's possible to expand the expression (even for non-rational powers)- we shouldn't, as the operation would not be reversible: the result of (x^0.5)^2 may be different from x + if (functionBody.Terms.Count == 1) + { + var singleTerm = (ExpressionTerm)functionBody; + Fraction coefficient = singleTerm.Coefficient.Pow(power); + return singleTerm with { Coefficient = coefficient, Exponent = singleTerm.Exponent * power }; + } + + // TODO see about handling the multi-term expansion (at least for integer exponents) + return new ExpressionTerm(1, 1, new CustomFunction(FunctionName, functionBody, power.ToDecimal().ToString(CultureInfo.InvariantCulture))); + } +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/SqrtFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/SqrtFunctionEvaluator.cs new file mode 100644 index 0000000000..a09c8d4a37 --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/SqrtFunctionEvaluator.cs @@ -0,0 +1,39 @@ +using System; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math; + +internal class SqrtFunctionEvaluator : IFunctionEvaluator +{ + public string FunctionName => nameof(System.Math.Sqrt); + public bool ExpandNonConstantExpressions { get; set; } = false; // while it's possible to expand the expression (even for non-rational powers)- probably we shouldn't + + public CompositeExpression CreateExpression(ExpressionEvaluationTerm expressionToParse, Func expressionResolver) + { + CompositeExpression functionBody = expressionResolver(expressionToParse with {Exponent = 1}); + if (functionBody.IsConstant) + { + var constantTerm = (ExpressionTerm)functionBody; + Fraction coefficient = constantTerm.Coefficient.Pow(expressionToParse.Exponent * FractionExtensions.OneHalf); + return ExpressionTerm.Constant(coefficient); + } + + if (!ExpandNonConstantExpressions) + { + return new ExpressionTerm(1, expressionToParse.Exponent, new CustomFunction(FunctionName, functionBody)); + } + + // while it's possible to expand the expression (even for non-rational powers)- we shouldn't, as the operation would not be reversible: the result of (x^0.5)^2 may be different from x + Fraction power = expressionToParse.Exponent * FractionExtensions.OneHalf; + if (functionBody.Terms.Count == 1) + { + var constantTerm = (ExpressionTerm)functionBody; + Fraction coefficient = constantTerm.Coefficient.Pow(power); + return constantTerm with { Coefficient = coefficient, Exponent = constantTerm.Exponent * power }; + } + + // TODO see about handling the multi-term expansion (at least for integer exponents) + return new ExpressionTerm(1, power, new CustomFunction(FunctionName, functionBody)); + } +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/AsinFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/AsinFunctionEvaluator.cs new file mode 100644 index 0000000000..de7ef7623c --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/AsinFunctionEvaluator.cs @@ -0,0 +1,13 @@ +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math.Trigonometry; + +internal class AsinFunctionEvaluator : MathFunctionEvaluator +{ + public override string FunctionName => nameof(System.Math.Asin); + + public override Fraction Evaluate(Fraction value) + { + return FractionExtensions.FromDoubleRounded(System.Math.Asin(value.ToDouble())); + } +} diff --git a/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/SinFunctionEvaluator.cs b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/SinFunctionEvaluator.cs new file mode 100644 index 0000000000..b81d69613c --- /dev/null +++ b/CodeGen/Helpers/ExpressionAnalyzer/Functions/Math/Trigonometry/SinFunctionEvaluator.cs @@ -0,0 +1,13 @@ +using Fractions; + +namespace CodeGen.Helpers.ExpressionAnalyzer.Functions.Math.Trigonometry; + +internal class SinFunctionEvaluator : MathFunctionEvaluator +{ + public override string FunctionName => nameof(System.Math.Sin); + + public override Fraction Evaluate(Fraction value) + { + return FractionExtensions.FromDoubleRounded(System.Math.Sin(value.ToDouble())); + } +} diff --git a/CodeGen/Helpers/ExpressionEvaluationHelpers.cs b/CodeGen/Helpers/ExpressionEvaluationHelpers.cs new file mode 100644 index 0000000000..27d32cd64f --- /dev/null +++ b/CodeGen/Helpers/ExpressionEvaluationHelpers.cs @@ -0,0 +1,218 @@ +using System.Linq; +using System.Numerics; +using CodeGen.Helpers.ExpressionAnalyzer; +using CodeGen.Helpers.ExpressionAnalyzer.Expressions; +using CodeGen.JsonTypes; +using Fractions; + +namespace CodeGen.Helpers; + +internal static class ExpressionEvaluationHelpers +{ + private static string GetConstantFormat(this Fraction coefficient) + { + if (coefficient == Fraction.One) + { + return "1"; + } + + return coefficient.Denominator.IsOne + ? coefficient.Numerator.ToString() + : $"new QuantityValue({coefficient.Numerator}, {coefficient.Denominator}, false)"; + } + + private static string GetFractionalConstantFormat(this Fraction coefficient) + { + // making sure that neither the Numerator nor the Denominator contain a value that cannot be represented as a compiler constant + if (coefficient.Numerator >= long.MinValue && coefficient.Numerator <= long.MaxValue && coefficient.Denominator <= long.MaxValue) + { + return coefficient.GetConstantFormat(); + } + + // need to represent the fraction in terms of two terms: "a * b" (TODO see about creating a static readonly field in the unit class) + if (coefficient.Denominator > long.MaxValue) // we are very close to zero + { + if (coefficient.Denominator.IsPowerOfTwo) // express as "2^n" + { + var exponent = coefficient.Denominator.GetBitLength() - 1; + if (coefficient.Numerator.IsOne) + { + return coefficient.IsPositive + ? $"1 / BigInteger.Pow(2, {exponent})" + : $"1 / -BigInteger.Pow(2, {exponent})"; + } + + return coefficient.IsPositive + ? $"{coefficient.Numerator} / BigInteger.Pow(2, {exponent})" + : $"{coefficient.Numerator} / -BigInteger.Pow(2, {exponent})"; + } + + Fraction mantissa = coefficient * BigInteger.Pow(10, 19); + return $"{mantissa.GetConstantFormat()} / BigInteger.Pow(10, 19)"; + } + else // we are very far from zero + { + if (coefficient.Numerator.IsPowerOfTwo) // express as "x * 2^n" + { + var exponent = coefficient.Numerator.GetBitLength() - 1; + if (coefficient.Denominator.IsOne) + { + return coefficient.IsPositive + ? $"BigInteger.Pow(2, {exponent})" + : $"-BigInteger.Pow(2, {exponent})"; + } + + return coefficient.IsPositive + ? $"BigInteger.Pow(2, {exponent}) / {coefficient.Denominator}" + : $"-BigInteger.Pow(2, {exponent}) / {coefficient.Denominator}"; + } + + // express as "x * a * 10^n + Fraction mantissa = coefficient / BigInteger.Pow(10, 19); + return $"{mantissa.GetConstantFormat()} * BigInteger.Pow(10, 19)"; + } + } + + private static string GetConstantExpression(this Fraction coefficient, string csharpParameter) + { + if (coefficient == Fraction.One) + { + return csharpParameter; + } + + if (coefficient.Denominator.IsOne) + { + return $"{csharpParameter} * {coefficient.Numerator}"; + } + + if (coefficient.Numerator.IsOne) + { + return $"{csharpParameter} / {coefficient.Denominator}"; + } + + if (coefficient.Numerator == BigInteger.MinusOne) + { + return $"{csharpParameter} / -{coefficient.Denominator}"; + } + + return $"{csharpParameter} * new QuantityValue({coefficient.Numerator}, {coefficient.Denominator}, false)"; + } + + private static string GetFractionalExpressionFormat(this Fraction coefficient, string csharpParameter) + { + // making sure that neither the Numerator nor the Denominator contain a value that cannot be represented as a compiler constant + if (coefficient.Numerator >= long.MinValue && coefficient.Numerator <= long.MaxValue && coefficient.Denominator <= long.MaxValue) + { + return coefficient.GetConstantExpression(csharpParameter); + } + + // need to represent the fraction in terms of two terms: "x * a * b" (TODO see about creating a static readonly field in the unit class) + if (coefficient.Denominator > long.MaxValue) // we are very close to zero + { + if (coefficient.Denominator.IsPowerOfTwo) // express as "x * 2^n" + { + var exponent = coefficient.Denominator.GetBitLength() - 1; + if (coefficient.Numerator.IsOne) + { + return coefficient.IsPositive + ? $"{csharpParameter} / BigInteger.Pow(2, {exponent})" + : $"{csharpParameter} / -BigInteger.Pow(2, {exponent})"; + } + + + return coefficient.IsPositive + ? $"{csharpParameter} * {coefficient.Numerator} / BigInteger.Pow(2, {exponent})" + : $"{csharpParameter} * -{coefficient.Numerator} / BigInteger.Pow(2, {exponent})"; + } + + Fraction mantissa = coefficient * BigInteger.Pow(10, 19); + return $"{mantissa.GetConstantExpression(csharpParameter)} / BigInteger.Pow(10, 19)"; + } + else // we are very far from zero + { + if (coefficient.Numerator.IsPowerOfTwo) // express as "x * 2^n" + { + var exponent = coefficient.Numerator.GetBitLength() - 1; + if (coefficient.Denominator.IsOne) + { + return coefficient.IsPositive + ? $"{csharpParameter} * BigInteger.Pow(2, {exponent})" + : $"{csharpParameter} * -BigInteger.Pow(2, {exponent})"; + } + + return coefficient.IsPositive + ? $"{csharpParameter} * BigInteger.Pow(2, {exponent}) / {coefficient.Denominator}" + : $"{csharpParameter} * -BigInteger.Pow(2, {exponent}) / {coefficient.Denominator}"; + } + + // express as "x * a * 10^n + Fraction mantissa = coefficient / BigInteger.Pow(10, 19); + return $"{mantissa.GetConstantExpression(csharpParameter)} * BigInteger.Pow(10, 19)"; + } + } + + public static string GetExpressionFormat(this CustomFunction customFunction, string csharpParameter) + { + // TODO see about redirecting these to a static method in the quantity's class which is responsible for handling the required operations (efficiently) + var mainArgument = $"({customFunction.Terms.GetExpressionFormat(csharpParameter)}).ToDouble()"; + var functionArguments = string.Join(", ", customFunction.AdditionalParameters.Prepend(mainArgument)); + return $"QuantityValue.FromDoubleRounded(Math.{customFunction.Name}({functionArguments}))"; + } + + public static string GetExponentFormat(this Fraction exponent, string csharpParameter) + { + if (exponent.Numerator == exponent.Denominator) + { + return csharpParameter; + } + + return exponent.Denominator.IsOne + ? $"({csharpParameter} ^ {exponent.ToInt32()})" + : $"QuantityValue.FromDoubleRounded(Math.Pow({csharpParameter}.ToDouble(), {exponent.ToDouble()}))"; + } + + public static string GetExpressionFormat(this ExpressionTerm term, string csharpParameter) + { + if (term.Exponent.IsZero) + { + return term.Coefficient.GetFractionalConstantFormat(); + } + + var expressionFormat = term.NestedFunction is null ? csharpParameter : term.NestedFunction.GetExpressionFormat(csharpParameter); + return term.Coefficient.GetFractionalExpressionFormat(term.Exponent.GetExponentFormat(expressionFormat)); + } + + public static string GetExpressionFormat(this CompositeExpression expression, string csharpParameter) + { + return string.Join(" + ", expression.Terms.Select(x => x.GetExpressionFormat(csharpParameter))); + } + + private static string GetStringExpression(string expression, string csharpParameter, string jsonParameter = "{x}") + { + CompositeExpression compositeExpression = ExpressionEvaluator.Evaluate(expression, jsonParameter); + var expectedFormat = compositeExpression.GetExpressionFormat(csharpParameter); + return expectedFormat; + } + + /// + /// Gets the format of the conversion from the unit to the base unit. + /// + /// The unit for which to get the conversion format. + /// The C# parameter to be used in the conversion expression. + /// A string representing the format of the conversion from the unit to the base unit. + internal static string GetUnitToBaseConversionFormat(this Unit unit, string csharpParameter) + { + return GetStringExpression(unit.FromUnitToBaseFunc, csharpParameter); + } + + /// + /// Gets the format of the conversion from the base unit to the specified unit. + /// + /// The unit to which the conversion format is to be obtained. + /// The C# parameter to be used in the conversion expression. + /// A string representing the format of the conversion from the base unit to the specified unit. + internal static string GetFromBaseToUnitConversionFormat(this Unit unit, string csharpParameter) + { + return GetStringExpression(unit.FromBaseToUnitFunc, csharpParameter); + } +} diff --git a/Common/UnitDefinitions/ForceChangeRate.json b/Common/UnitDefinitions/ForceChangeRate.json index 08bb0d754f..2caf599e8c 100644 --- a/Common/UnitDefinitions/ForceChangeRate.json +++ b/Common/UnitDefinitions/ForceChangeRate.json @@ -37,8 +37,8 @@ { "SingularName": "PoundForcePerMinute", "PluralName": "PoundsForcePerMinute", - "FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421 / 60", - "FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421 * 60", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 60", + "FromBaseToUnitFunc": "{x} / 4.4482216152605 * 60", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -51,8 +51,8 @@ { "SingularName": "PoundForcePerSecond", "PluralName": "PoundsForcePerSecond", - "FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421", - "FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421", + "FromUnitToBaseFunc": "{x} * 4.4482216152605", + "FromBaseToUnitFunc": "{x} / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Irradiation.json b/Common/UnitDefinitions/Irradiation.json index 1097c6e3b4..3689cd0db4 100644 --- a/Common/UnitDefinitions/Irradiation.json +++ b/Common/UnitDefinitions/Irradiation.json @@ -58,6 +58,19 @@ "Abbreviations": [ "Wh/m²" ] } ] + }, + { + "SingularName": "BtuPerSquareFoot", + "PluralName": "BtusPerSquareFoot", + "FromUnitToBaseFunc": "{x} * (52752792631d / 4645152d)", + "FromBaseToUnitFunc": "{x} / (52752792631d / 4645152d)", + "Prefixes": [ "Kilo" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Btu/ft²" ] + } + ] } ] } diff --git a/Common/UnitDefinitions/Molarity.json b/Common/UnitDefinitions/Molarity.json index 81a0c605dc..48984c857e 100644 --- a/Common/UnitDefinitions/Molarity.json +++ b/Common/UnitDefinitions/Molarity.json @@ -49,8 +49,8 @@ "L": "Foot", "N": "PoundMole" }, - "FromUnitToBaseFunc": "{x} / 6.2427960576144611956325455827221e-5", - "FromBaseToUnitFunc": "{x} * 6.2427960576144611956325455827221e-5", + "FromUnitToBaseFunc": "{x} / 0.00220462262184878 * 35.31466672", + "FromBaseToUnitFunc": "{x} * 0.00220462262184878 / 35.31466672", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/RadiationEquivalentDose.json b/Common/UnitDefinitions/RadiationEquivalentDose.json new file mode 100644 index 0000000000..85da7bbed3 --- /dev/null +++ b/Common/UnitDefinitions/RadiationEquivalentDose.json @@ -0,0 +1,48 @@ +{ + "Name": "RadiationEquivalentDose", + "BaseUnit": "Sievert", + "XmlDocSummary": "Equivalent dose is a dose quantity representing the stochastic health effects of low levels of ionizing radiation on the human body which represents the probability of radiation-induced cancer and genetic damage.", + "XmlDocsRemarks": "https://en.wikipedia.org/wiki/Equivalent_dose", + "BaseDimensions": { + "L": 2, + "T": -2 + }, + "Units": [ + { + "SingularName": "Sievert", + "PluralName": "Sieverts", + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, + "Prefixes": [ "Nano", "Micro", "Milli" ], + "XmlDocSummary": "The sievert is a unit in the International System of Units (SI) intended to represent the stochastic health risk of ionizing radiation, which is defined as the probability of causing radiation-induced cancer and genetic damage.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Sievert", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Sv" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Зв" ] + } + ] + }, + { + "SingularName": "RoentgenEquivalentMan", + "PluralName": "RoentgensEquivalentMan", + "FromUnitToBaseFunc": "{x} / 100", + "FromBaseToUnitFunc": "{x} * 100", + "Prefixes": [ "Milli" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "rem" ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Common/UnitDefinitions/StandardVolumeFlow.json b/Common/UnitDefinitions/StandardVolumeFlow.json index bf731df37e..1f00f88fd7 100644 --- a/Common/UnitDefinitions/StandardVolumeFlow.json +++ b/Common/UnitDefinitions/StandardVolumeFlow.json @@ -82,8 +82,8 @@ { "SingularName": "StandardCubicFootPerSecond", "PluralName": "StandardCubicFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 35.314666721", - "FromBaseToUnitFunc": "{x} * 35.314666721", + "FromUnitToBaseFunc": "{x} * 0.028316846592", + "FromBaseToUnitFunc": "{x} / 0.028316846592", "Localization": [ { "Culture": "en-US", @@ -94,8 +94,8 @@ { "SingularName": "StandardCubicFootPerMinute", "PluralName": "StandardCubicFeetPerMinute", - "FromUnitToBaseFunc": "{x} / 2118.88000326", - "FromBaseToUnitFunc": "{x} * 2118.88000326", + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 60", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 60)", "Localization": [ { "Culture": "en-US", @@ -106,8 +106,8 @@ { "SingularName": "StandardCubicFootPerHour", "PluralName": "StandardCubicFeetPerHour", - "FromUnitToBaseFunc": "{x} * 7.8657907199999087346816086183876e-6", - "FromBaseToUnitFunc": "{x} / 7.8657907199999087346816086183876e-6", + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 3600", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 3600)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json index e5ab2458ae..25ee2d9cb9 100644 --- a/Common/UnitDefinitions/Volume.json +++ b/Common/UnitDefinitions/Volume.json @@ -194,8 +194,8 @@ { "SingularName": "CubicInch", "PluralName": "CubicInches", - "FromUnitToBaseFunc": "{x} * 1.6387 * 1e-5", - "FromBaseToUnitFunc": "{x} / (1.6387 * 1e-5)", + "FromUnitToBaseFunc": "{x} * 1.6387064e-5", + "FromBaseToUnitFunc": "{x} / 1.6387064e-5", "Localization": [ { "Culture": "en-US", @@ -229,8 +229,8 @@ { "SingularName": "ImperialOunce", "PluralName": "ImperialOunces", - "FromUnitToBaseFunc": "{x} * 2.8413062499962901241875439064617e-5", - "FromBaseToUnitFunc": "{x} / 2.8413062499962901241875439064617e-5", + "FromUnitToBaseFunc": "{x} * 2.84130625e-5", + "FromBaseToUnitFunc": "{x} / 2.84130625e-5", "Localization": [ { "Culture": "en-US", @@ -264,8 +264,8 @@ { "SingularName": "UsOunce", "PluralName": "UsOunces", - "FromUnitToBaseFunc": "{x} * 2.957352956253760505068307980135e-5", - "FromBaseToUnitFunc": "{x} / 2.957352956253760505068307980135e-5", + "FromUnitToBaseFunc": "{x} * 2.95735295625e-5", + "FromBaseToUnitFunc": "{x} / 2.95735295625e-5", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index 22e3229124..9d07ee2f08 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -70,8 +70,8 @@ { "SingularName": "CubicFootPerSecond", "PluralName": "CubicFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 35.314666721", - "FromBaseToUnitFunc": "{x} * 35.314666721", + "FromUnitToBaseFunc": "{x} * 0.028316846592", + "FromBaseToUnitFunc": "{x} / 0.028316846592", "Localization": [ { "Culture": "en-US", @@ -82,8 +82,8 @@ { "SingularName": "CubicFootPerMinute", "PluralName": "CubicFeetPerMinute", - "FromUnitToBaseFunc": "{x} / 2118.88000326", - "FromBaseToUnitFunc": "{x} * 2118.88000326", + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 60", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 60)", "Localization": [ { "Culture": "en-US", @@ -94,8 +94,8 @@ { "SingularName": "CubicFootPerHour", "PluralName": "CubicFeetPerHour", - "FromUnitToBaseFunc": "{x} * 7.8657907199999087346816086183876e-6", - "FromBaseToUnitFunc": "{x} / 7.8657907199999087346816086183876e-6", + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 3600", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 3600)", "Localization": [ { "Culture": "en-US", @@ -181,7 +181,7 @@ "PluralName": "LitersPerSecond", "FromUnitToBaseFunc": "{x} / 1000", "FromBaseToUnitFunc": "{x} * 1000", - "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ], + "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", @@ -198,7 +198,7 @@ "PluralName": "LitersPerMinute", "FromUnitToBaseFunc": "{x} / 60000.00000", "FromBaseToUnitFunc": "{x} * 60000.00000", - "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ], + "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", @@ -215,7 +215,7 @@ "PluralName": "LitersPerHour", "FromUnitToBaseFunc": "{x} / 3600000.000", "FromBaseToUnitFunc": "{x} * 3600000.000", - "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ], + "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", @@ -232,7 +232,7 @@ "PluralName": "LitersPerDay", "FromUnitToBaseFunc": "{x} / 86400000", "FromBaseToUnitFunc": "{x} * 86400000", - "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ], + "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", @@ -357,8 +357,8 @@ { "SingularName": "OilBarrelPerDay", "PluralName": "OilBarrelsPerDay", - "FromUnitToBaseFunc": "{x} * 1.8401307283333333333333333333333e-6", - "FromBaseToUnitFunc": "{x} / 1.8401307283333333333333333333333e-6", + "FromUnitToBaseFunc": "{x} * 1.8401307283333e-6", + "FromBaseToUnitFunc": "{x} / 1.8401307283333e-6", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/WarpingMomentOfInertia.json b/Common/UnitDefinitions/WarpingMomentOfInertia.json index b8245dc80b..170132214e 100644 --- a/Common/UnitDefinitions/WarpingMomentOfInertia.json +++ b/Common/UnitDefinitions/WarpingMomentOfInertia.json @@ -72,8 +72,8 @@ "BaseUnits": { "L": "Foot" }, - "FromUnitToBaseFunc": "{x} * Math.Pow(0.3048, 6)", - "FromBaseToUnitFunc": "{x} / Math.Pow(0.3048, 6)", + "FromUnitToBaseFunc": "{x} * 0.000801843800914862014464", + "FromBaseToUnitFunc": "{x} / 0.000801843800914862014464", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 4d909db5bb..73ba872afa 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -631,7 +631,9 @@ "KilojoulePerSquareMeter": 4, "KilowattHourPerSquareMeter": 5, "MillijoulePerSquareCentimeter": 6, - "WattHourPerSquareMeter": 7 + "WattHourPerSquareMeter": 7, + "BtuPerSquareFoot": 15, + "KilobtuPerSquareFoot": 9 }, "Jerk": { "CentimeterPerSecondCubed": 1, @@ -1676,7 +1678,15 @@ "MegaliterPerMinute": 64, "MegaliterPerSecond": 65, "MegaukGallonPerDay": 73, - "MegausGallonPerDay": 77 + "MegausGallonPerDay": 77, + "DecaliterPerDay": 71, + "DecaliterPerHour": 78, + "DecaliterPerMinute": 67, + "DecaliterPerSecond": 70, + "HectoliterPerDay": 74, + "HectoliterPerHour": 72, + "HectoliterPerMinute": 75, + "HectoliterPerSecond": 69 }, "VolumeFlowPerArea": { "CubicFootPerMinutePerSquareFoot": 1, @@ -1835,5 +1845,15 @@ "Roentgen": 4, "Microroentgen": 12, "Milliroentgen": 13 + }, + "RadiationEquivalentDose": { + "Microsievert": 1, + "MilliroentgenEquivalentMan": 2, + "Millisievert": 7, + "Nanosievert": 5, + "RoentgenEquivalentMan": 4, + "Sievert": 9, + "Kilosievert": 3, + "Megasievert": 6 } } diff --git a/Common/UnitRelations.json b/Common/UnitRelations.json index b6e6cc2ad3..afd0ab65b6 100644 --- a/Common/UnitRelations.json +++ b/Common/UnitRelations.json @@ -8,6 +8,7 @@ "Angle.Radian = RotationalSpeed.RadianPerSecond * Duration.Second", "Area.SquareMeter = KinematicViscosity.SquareMeterPerSecond * Duration.Second", "Area.SquareMeter = Length.Meter * Length.Meter", + "Area.SquareMeter = Volume.CubicMeter * ReciprocalLength.InverseMeter", "AreaMomentOfInertia.MeterToTheFourth = Volume.CubicMeter * Length.Meter", "double = Density.KilogramPerCubicMeter * SpecificVolume.CubicMeterPerKilogram", "double = SpecificEnergy.JoulePerKilogram * BrakeSpecificFuelConsumption.KilogramPerJoule", @@ -30,7 +31,9 @@ "ForcePerLength.NewtonPerMeter = Pressure.NewtonPerSquareMeter * Length.Meter", "ForcePerLength.NewtonPerMeter = SpecificWeight.NewtonPerCubicMeter * Area.SquareMeter", "KinematicViscosity.SquareMeterPerSecond = Length.Meter * Speed.MeterPerSecond", + "Length.Meter = Area.SquareMeter * ReciprocalLength.InverseMeter", "Length.Meter = Speed.MeterPerSecond * Duration.Second", + "Length.Meter = Volume.CubicMeter * ReciprocalArea.InverseSquareMeter", "LinearDensity.KilogramPerMeter = Area.SquareMeter * Density.KilogramPerCubicMeter", "LuminousIntensity.Candela = Luminance.CandelaPerSquareMeter * Area.SquareMeter", "Mass.Gram = AmountOfSubstance.Mole * MolarMass.GramPerMole", diff --git a/PerfTests/PerfTest_Startup/PerfTest_Startup.csproj b/PerfTests/PerfTest_Startup/PerfTest_Startup.csproj index fa16b7ff97..dd5984c9e8 100644 --- a/PerfTests/PerfTest_Startup/PerfTest_Startup.csproj +++ b/PerfTests/PerfTest_Startup/PerfTest_Startup.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable perftest diff --git a/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj b/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj index 562902a0c0..6ce0806129 100644 --- a/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj +++ b/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable perftest_before diff --git a/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj b/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj index 5140e2090b..03686a9f46 100644 --- a/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj +++ b/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 enable enable perftest_before diff --git a/README.md b/README.md index 2f01def5a1..f4a93903df 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ Add strongly typed quantities to your code and get merrily on with your life. No more magic constants found on Stack Overflow, no more second-guessing the unit of parameters and variables. -[Upgrading from 4.x to 5.x](https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-4.x-to-5.x) +[Upgrading from 4.x to 5.x](https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-4.x-to-5.x)
+[Upgrading from 5.x to 6.x](https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-5.x-to-6.x) (still in prerelease and may yet change) ### Overview diff --git a/UnitsNet.Benchmark/Program.cs b/UnitsNet.Benchmark/Program.cs index 75b1a89759..d5d2dd1677 100644 --- a/UnitsNet.Benchmark/Program.cs +++ b/UnitsNet.Benchmark/Program.cs @@ -7,32 +7,32 @@ namespace UnitsNet.Benchmark [MemoryDiagnoser] public class UnitsNetBenchmarks { - private readonly Length _length = Length.FromMeters(3.0); - private readonly IQuantity _lengthIQuantity = Length.FromMeters(3.0); + private readonly Length _length = Length.FromMeters(3); + private readonly IQuantity _lengthIQuantity = Length.FromMeters(3); [Benchmark] [BenchmarkCategory("Construction")] - public Length Constructor() => new Length(3.0, LengthUnit.Meter); + public Length Constructor() => new Length(3, LengthUnit.Meter); [Benchmark] [BenchmarkCategory("Construction")] - public Length Constructor_SI() => new Length(3.0, UnitSystem.SI); + public Length Constructor_SI() => new Length(3, UnitSystem.SI); [Benchmark] [BenchmarkCategory("Construction")] - public Length FromMethod() => Length.FromMeters(3.0); + public Length FromMethod() => Length.FromMeters(3); [Benchmark] [BenchmarkCategory("Transformation")] - public double ToProperty() => _length.Centimeters; + public QuantityValue ToProperty() => _length.Centimeters; [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As() => _length.As(LengthUnit.Centimeter); + public QuantityValue As() => _length.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As_SI() => _length.As(UnitSystem.SI); + public QuantityValue As_SI() => _length.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] @@ -60,15 +60,15 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Construction")] - public IQuantity QuantityFrom() => Quantity.From(3.0, LengthUnit.Meter); + public IQuantity QuantityFrom() => Quantity.From(3, LengthUnit.Meter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); + public QuantityValue IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); + public QuantityValue IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] @@ -82,6 +82,8 @@ public class UnitsNetBenchmarks class Program { static void Main(string[] args) - => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); + { + BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); + } } } diff --git a/UnitsNet.Benchmark/Scripts/json-export-all-runtimes.bat b/UnitsNet.Benchmark/Scripts/json-export-all-runtimes.bat index 8c631cb1de..895d9d9cb1 100644 --- a/UnitsNet.Benchmark/Scripts/json-export-all-runtimes.bat +++ b/UnitsNet.Benchmark/Scripts/json-export-all-runtimes.bat @@ -4,8 +4,8 @@ SET projectdir="%scriptdir%..\.." SET exportdir="%projectdir%\Artifacts\Benchmark" :: this fails on the build server (also tested with the nightly benchmark.net package: 0.12.1.1533): possibly related to https://github.com/dotnet/BenchmarkDotNet/issues/1487 dotnet run --project "%projectdir%/UnitsNet.Benchmark" -c Release ^ ---framework net6.0 ^ ---runtimes net472 net48 netcoreapp2.1 netcoreapp3.1 net6.0 ^ +--framework net8.0 ^ +--runtimes net48 net8.0 ^ --artifacts=%exportdir% ^ --exporters json ^ --filter * ^ @@ -14,4 +14,4 @@ dotnet run --project "%projectdir%/UnitsNet.Benchmark" -c Release ^ --join %1 %2 %3 :: this runs fine, however there is currently no way of displaying multiple-lines-per-chart: see https://github.com/rhysd/github-action-benchmark/issues/18 -:: dotnet run --project "%scriptdir%/UnitsNet.Benchmark" -c Release -f net6.0 --runtimes netcoreapp31 netcoreapp50 --filter ** --artifacts="%scriptdir%/Artifacts/Benchmark" --exporters json +:: dotnet run --project "%scriptdir%/UnitsNet.Benchmark" -c Release -f net8.0 --runtimes net48 net8.0 --filter ** --artifacts="%scriptdir%/Artifacts/Benchmark" --exporters json diff --git a/UnitsNet.Benchmark/Scripts/json-export-net5.bat b/UnitsNet.Benchmark/Scripts/json-export-net5.bat deleted file mode 100644 index 6d446ec0b5..0000000000 --- a/UnitsNet.Benchmark/Scripts/json-export-net5.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -SET scriptdir=%~dp0 -SET projectdir="%scriptdir%..\.." -SET exportdir="%projectdir%\Artifacts\Benchmark" -:: this fails on the build server (also tested with the nightly benchmark.net package: 0.12.1.1533): possibly related to https://github.com/dotnet/BenchmarkDotNet/issues/1487 -dotnet run --project "%projectdir%\UnitsNet.Benchmark" -c Release ^ ---framework net5.0 ^ ---runtimes net5.0 ^ ---artifacts=%exportdir% ^ ---exporters json ^ ---filter * ^ ---iterationTime 250 ^ ---statisticalTest 0.001ms ^ ---join %1 %2 %3 - -:: this runs fine, however there is currently no way of displaying multiple-lines-per-chart: see https://github.com/rhysd/github-action-benchmark/issues/18 -:: dotnet run --project "%scriptdir%/UnitsNet.Benchmark" -c Release -f net5.0 --runtimes netcoreapp31 net5.0 --filter ** --artifacts="%scriptdir%/Artifacts/Benchmark" --exporters json diff --git a/UnitsNet.Benchmark/Scripts/r-plot-all-runtimes.bat b/UnitsNet.Benchmark/Scripts/r-plot-all-runtimes.bat index aa592c0fba..19cff17270 100644 --- a/UnitsNet.Benchmark/Scripts/r-plot-all-runtimes.bat +++ b/UnitsNet.Benchmark/Scripts/r-plot-all-runtimes.bat @@ -4,8 +4,8 @@ SET projectdir="%scriptdir%..\.." SET exportdir="%projectdir%\Artifacts\Benchmark" :: this fails on the build server (also tested with the nightly benchmark.net package: 0.12.1.1533): possibly related to https://github.com/dotnet/BenchmarkDotNet/issues/1487 dotnet run --project "%projectdir%\UnitsNet.Benchmark" -c Release ^ ---framework net5.0 ^ ---runtimes net472 net48 netcoreapp2.1 netcoreapp3.1 net6.0 ^ +--framework net8.0 ^ +--runtimes net48 net8.0 ^ --artifacts=%exportdir% ^ --exporters rplot ^ --filter * ^ diff --git a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj index 917567e332..5a90114f34 100644 --- a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj +++ b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj @@ -1,7 +1,7 @@  Exe - net6.0;net48 + net8.0 4.0.0.0 4.0.0.0 UnitsNet.Benchmark @@ -10,8 +10,8 @@ - - + + all diff --git a/UnitsNet.NanoFramework/GeneratedCode/AbsorbedDoseOfIonizingRadiation/UnitsNet.NanoFramework.AbsorbedDoseOfIonizingRadiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AbsorbedDoseOfIonizingRadiation/UnitsNet.NanoFramework.AbsorbedDoseOfIonizingRadiation.nuspec index 3a7b85f694..bb286cc245 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AbsorbedDoseOfIonizingRadiation/UnitsNet.NanoFramework.AbsorbedDoseOfIonizingRadiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AbsorbedDoseOfIonizingRadiation/UnitsNet.NanoFramework.AbsorbedDoseOfIonizingRadiation.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.AbsorbedDoseOfIonizingRadiation - 6.0.0-pre002 + 6.0.0-pre006 Units.NET AbsorbedDoseOfIonizingRadiation - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds AbsorbedDoseOfIonizingRadiation units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index f14f2e6eca..e7274fd622 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Acceleration - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Acceleration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index ae8673ef62..093083d857 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.AmountOfSubstance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds AmountOfSubstance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index 27f71e6090..ace92ce237 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.AmplitudeRatio - 6.0.0-pre002 + 6.0.0-pre006 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds AmplitudeRatio units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index 460b8ba3e0..94aa591caf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Angle - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Angle units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 5d30cc6213..948a02c222 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ApparentEnergy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ApparentEnergy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index 98d5dea02f..4e4832be1e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ApparentPower - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ApparentPower units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index 3892a5afad..4643e59d35 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Area - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Area units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index cc84366884..a5e8ccb3d3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.AreaDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds AreaDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index d26b975ab8..06da684f48 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 6.0.0-pre002 + 6.0.0-pre006 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds AreaMomentOfInertia units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index ee6ca4a5cc..24fa166f7a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.BitRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds BitRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index dbdb7032c8..003afcbdf4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 6.0.0-pre002 + 6.0.0-pre006 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds BrakeSpecificFuelConsumption units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 3bf8166c28..bcb37f871a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Capacitance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Capacitance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 39682561df..7a55bc80f5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 6.0.0-pre002 + 6.0.0-pre006 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds CoefficientOfThermalExpansion units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec index f9abdf216f..6bdcbb405a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Compressibility - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Compressibility - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Compressibility units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 18f5d7de62..a8bd31b8fa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Density - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Density units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index 9e004c581f..6767f55c1d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Duration - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Duration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 9e6fe9358c..c1a8d792a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.DynamicViscosity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds DynamicViscosity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 2e072e824e..45f311888e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricAdmittance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricAdmittance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index 91e535f696..f985c484b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricCharge - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricCharge units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index adba848d52..6d477c716c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricChargeDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 463d61299e..135f95b089 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricConductance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricConductance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 61770d3423..0546545f73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricConductivity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricConductivity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 6cb9ac7e5b..50b90312de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricCurrent - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricCurrent units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index cd4d1c8c66..4fe7d78796 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricCurrentDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index c61c20f617..e492038be0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricCurrentGradient units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index eeb466f4ca..42dee45723 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricField - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricField units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index 75c81bf632..eecb8261d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricInductance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricInductance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index fc97fc6289..ac39144ae5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricPotential - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricPotential units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 0e572f241e..f892313d19 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricPotentialAc units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 7cfe7c46f0..3108512dad 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricPotentialChangeRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index 54cd5d7e29..8c5bf8d05c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricPotentialDc units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 6779f40d15..8c5d2a069b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricResistance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricResistance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index ddb6231d4a..d7104781c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricResistivity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricResistivity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index 2d2540b326..f563a573df 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ElectricSurfaceChargeDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index a8b81f536d..3963e0675c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Energy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Energy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/EnergyDensity/UnitsNet.NanoFramework.EnergyDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/EnergyDensity/UnitsNet.NanoFramework.EnergyDensity.nuspec index 41721e71a9..4ddc722375 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/EnergyDensity/UnitsNet.NanoFramework.EnergyDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/EnergyDensity/UnitsNet.NanoFramework.EnergyDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.EnergyDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET EnergyDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds EnergyDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index dc37d5f572..388f627fad 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Entropy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Entropy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index dd091f465e..d7968e1654 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Force - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Force units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index f9b3cf8f55..d3d939aa7e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ForceChangeRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ForceChangeRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index 6be296fb2e..b015e03fad 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ForcePerLength - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ForcePerLength units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 3594f61cf8..cf9bad5d09 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Frequency - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Frequency units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index a4f3a4186b..df7a63b78d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.FuelEfficiency - 6.0.0-pre002 + 6.0.0-pre006 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds FuelEfficiency units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 3f96f5901c..02a645988b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.HeatFlux - 6.0.0-pre002 + 6.0.0-pre006 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds HeatFlux units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 85d3d7e030..9b379dad9b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 6.0.0-pre002 + 6.0.0-pre006 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds HeatTransferCoefficient units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index f968214c64..3e367323f5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Illuminance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Illuminance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Impulse/UnitsNet.NanoFramework.Impulse.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Impulse/UnitsNet.NanoFramework.Impulse.nuspec index 74ddac9282..02a1693a15 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Impulse/UnitsNet.NanoFramework.Impulse.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Impulse/UnitsNet.NanoFramework.Impulse.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Impulse - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Impulse - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Impulse units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index 1547d59f79..b9ab5561d4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Information - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Information units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 96955397c1..ac1bd8bb2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Irradiance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Irradiance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index b03915d644..be125334fc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Irradiation - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Irradiation units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec index 57345f4a53..24a23302bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Jerk - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Jerk - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Jerk units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index b34e77e8dc..0ac3133fa4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.KinematicViscosity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds KinematicViscosity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index d16cfb4ef3..f1ff325ed7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LapseRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LapseRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LeakRate/UnitsNet.NanoFramework.LeakRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LeakRate/UnitsNet.NanoFramework.LeakRate.nuspec index 0d554c02d2..b0b0739746 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LeakRate/UnitsNet.NanoFramework.LeakRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LeakRate/UnitsNet.NanoFramework.LeakRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LeakRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LeakRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LeakRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index c688bfc007..e18aeb53d8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Length - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Length units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index c7e83857a4..9f94e026e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Level - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Level units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index 69b4d071c6..750d6573fe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LinearDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LinearDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index db5cedefe1..d42474b484 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LinearPowerDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LinearPowerDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminance/UnitsNet.NanoFramework.Luminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminance/UnitsNet.NanoFramework.Luminance.nuspec index 049f02c7f6..7b43161bcb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminance/UnitsNet.NanoFramework.Luminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminance/UnitsNet.NanoFramework.Luminance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Luminance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Luminance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Luminance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 24bad24a07..a0001f3579 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Luminosity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Luminosity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 666db97c73..c8cfb7e19a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LuminousFlux - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LuminousFlux units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index f0f6ea674c..5329c9101f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.LuminousIntensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds LuminousIntensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index fd09b77b75..437cb19161 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MagneticField - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MagneticField units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 24341242a3..f6437c7686 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MagneticFlux - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MagneticFlux units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index bf4d97b1e0..49a6048253 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Magnetization - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Magnetization units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index a7ccf3916f..204a7f5fd3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Mass - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Mass units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index c54cf9e79f..5463174583 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MassConcentration - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MassConcentration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 9a22ed732d..5bc2d9f0fb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MassFlow - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MassFlow units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index 0b7de513c1..fa9360ef52 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MassFlux - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MassFlux units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 5fc60bb002..a3ba1946a7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MassFraction - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MassFraction units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index e8ed3169f1..ab16956a7a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MassMomentOfInertia units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec index f72ceab9ac..554bdecda1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molality/UnitsNet.NanoFramework.Molality.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Molality - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Molality - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Molality units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index 6569b938d3..606ef4bd82 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MolarEnergy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MolarEnergy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index 942431d7a5..f71123bf2d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MolarEntropy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MolarEntropy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarFlow/UnitsNet.NanoFramework.MolarFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarFlow/UnitsNet.NanoFramework.MolarFlow.nuspec index d29b883f16..ef23e33842 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarFlow/UnitsNet.NanoFramework.MolarFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarFlow/UnitsNet.NanoFramework.MolarFlow.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MolarFlow - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MolarFlow - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MolarFlow units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 359957c597..2733e8387d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.MolarMass - 6.0.0-pre002 + 6.0.0-pre006 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds MolarMass units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index bf863c1ddc..e29d04a9de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Molarity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Molarity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 422264538b..a38f6720f5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Permeability - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Permeability units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index b2d910146a..4392da511d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Permittivity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Permittivity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec index c5385738fa..72d46532f1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.PorousMediumPermeability - 6.0.0-pre002 + 6.0.0-pre006 Units.NET PorousMediumPermeability - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds PorousMediumPermeability units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index bd143b1593..c50208d87b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Power - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Power units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 7e88b11c18..bd96df289b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.PowerDensity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds PowerDensity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index 3dbc5ac840..b84b3659ef 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.PowerRatio - 6.0.0-pre002 + 6.0.0-pre006 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds PowerRatio units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 81e54b4e97..0dff49b75a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Pressure - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Pressure units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index ecf925c2b7..5dc156da08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.PressureChangeRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds PressureChangeRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs index d75dc0c5d2..a06c8d9e20 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -278,15 +278,15 @@ private double GetValueInBaseUnit() ForceChangeRateUnit.DecinewtonPerSecond => (_value) * 1e-1d, ForceChangeRateUnit.KilonewtonPerMinute => (_value / 60) * 1e3d, ForceChangeRateUnit.KilonewtonPerSecond => (_value) * 1e3d, - ForceChangeRateUnit.KilopoundForcePerMinute => (_value * 4.4482216152605095551842641431421 / 60) * 1e3d, - ForceChangeRateUnit.KilopoundForcePerSecond => (_value * 4.4482216152605095551842641431421) * 1e3d, + ForceChangeRateUnit.KilopoundForcePerMinute => (_value * 4.4482216152605 / 60) * 1e3d, + ForceChangeRateUnit.KilopoundForcePerSecond => (_value * 4.4482216152605) * 1e3d, ForceChangeRateUnit.MicronewtonPerSecond => (_value) * 1e-6d, ForceChangeRateUnit.MillinewtonPerSecond => (_value) * 1e-3d, ForceChangeRateUnit.NanonewtonPerSecond => (_value) * 1e-9d, ForceChangeRateUnit.NewtonPerMinute => _value / 60, ForceChangeRateUnit.NewtonPerSecond => _value, - ForceChangeRateUnit.PoundForcePerMinute => _value * 4.4482216152605095551842641431421 / 60, - ForceChangeRateUnit.PoundForcePerSecond => _value * 4.4482216152605095551842641431421, + ForceChangeRateUnit.PoundForcePerMinute => _value * 4.4482216152605 / 60, + ForceChangeRateUnit.PoundForcePerSecond => _value * 4.4482216152605, _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") }; } @@ -306,15 +306,15 @@ private double GetValueAs(ForceChangeRateUnit unit) ForceChangeRateUnit.DecinewtonPerSecond => (baseUnitValue) / 1e-1d, ForceChangeRateUnit.KilonewtonPerMinute => (baseUnitValue * 60) / 1e3d, ForceChangeRateUnit.KilonewtonPerSecond => (baseUnitValue) / 1e3d, - ForceChangeRateUnit.KilopoundForcePerMinute => (baseUnitValue / 4.4482216152605095551842641431421 * 60) / 1e3d, - ForceChangeRateUnit.KilopoundForcePerSecond => (baseUnitValue / 4.4482216152605095551842641431421) / 1e3d, + ForceChangeRateUnit.KilopoundForcePerMinute => (baseUnitValue / 4.4482216152605 * 60) / 1e3d, + ForceChangeRateUnit.KilopoundForcePerSecond => (baseUnitValue / 4.4482216152605) / 1e3d, ForceChangeRateUnit.MicronewtonPerSecond => (baseUnitValue) / 1e-6d, ForceChangeRateUnit.MillinewtonPerSecond => (baseUnitValue) / 1e-3d, ForceChangeRateUnit.NanonewtonPerSecond => (baseUnitValue) / 1e-9d, ForceChangeRateUnit.NewtonPerMinute => baseUnitValue * 60, ForceChangeRateUnit.NewtonPerSecond => baseUnitValue, - ForceChangeRateUnit.PoundForcePerMinute => baseUnitValue / 4.4482216152605095551842641431421 * 60, - ForceChangeRateUnit.PoundForcePerSecond => baseUnitValue / 4.4482216152605095551842641431421, + ForceChangeRateUnit.PoundForcePerMinute => baseUnitValue / 4.4482216152605 * 60, + ForceChangeRateUnit.PoundForcePerSecond => baseUnitValue / 4.4482216152605, _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs index 694d7ebee1..2f0fe42dd9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs @@ -81,6 +81,11 @@ public Irradiation(double value, IrradiationUnit unit) public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); #region Conversion Properties + /// + /// Gets a value of this quantity converted into + /// + public double BtusPerSquareFoot => As(IrradiationUnit.BtuPerSquareFoot); + /// /// Gets a value of this quantity converted into /// @@ -96,6 +101,11 @@ public Irradiation(double value, IrradiationUnit unit) /// public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + /// + /// Gets a value of this quantity converted into + /// + public double KilobtusPerSquareFoot => As(IrradiationUnit.KilobtuPerSquareFoot); + /// /// Gets a value of this quantity converted into /// @@ -120,6 +130,11 @@ public Irradiation(double value, IrradiationUnit unit) #region Static Factory Methods + /// + /// Creates a from . + /// + public static Irradiation FromBtusPerSquareFoot(double btuspersquarefoot) => new Irradiation(btuspersquarefoot, IrradiationUnit.BtuPerSquareFoot); + /// /// Creates a from . /// @@ -135,6 +150,11 @@ public Irradiation(double value, IrradiationUnit unit) /// public static Irradiation FromJoulesPerSquareMillimeter(double joulespersquaremillimeter) => new Irradiation(joulespersquaremillimeter, IrradiationUnit.JoulePerSquareMillimeter); + /// + /// Creates a from . + /// + public static Irradiation FromKilobtusPerSquareFoot(double kilobtuspersquarefoot) => new Irradiation(kilobtuspersquarefoot, IrradiationUnit.KilobtuPerSquareFoot); + /// /// Creates a from . /// @@ -195,9 +215,11 @@ private double GetValueInBaseUnit() { return Unit switch { + IrradiationUnit.BtuPerSquareFoot => _value * (52752792631d / 4645152d), IrradiationUnit.JoulePerSquareCentimeter => _value * 1e4, IrradiationUnit.JoulePerSquareMeter => _value, IrradiationUnit.JoulePerSquareMillimeter => _value * 1e6, + IrradiationUnit.KilobtuPerSquareFoot => (_value * (52752792631d / 4645152d)) * 1e3d, IrradiationUnit.KilojoulePerSquareMeter => (_value) * 1e3d, IrradiationUnit.KilowattHourPerSquareMeter => (_value * 3600d) * 1e3d, IrradiationUnit.MillijoulePerSquareCentimeter => (_value * 1e4) * 1e-3d, @@ -215,9 +237,11 @@ private double GetValueAs(IrradiationUnit unit) return unit switch { + IrradiationUnit.BtuPerSquareFoot => baseUnitValue / (52752792631d / 4645152d), IrradiationUnit.JoulePerSquareCentimeter => baseUnitValue / 1e4, IrradiationUnit.JoulePerSquareMeter => baseUnitValue, IrradiationUnit.JoulePerSquareMillimeter => baseUnitValue / 1e6, + IrradiationUnit.KilobtuPerSquareFoot => (baseUnitValue / (52752792631d / 4645152d)) / 1e3d, IrradiationUnit.KilojoulePerSquareMeter => (baseUnitValue) / 1e3d, IrradiationUnit.KilowattHourPerSquareMeter => (baseUnitValue / 3600d) / 1e3d, IrradiationUnit.MillijoulePerSquareCentimeter => (baseUnitValue / 1e4) / 1e-3d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs index c104846182..4e2988cc54 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs @@ -245,7 +245,7 @@ private double GetValueInBaseUnit() MolarityUnit.MolePerLiter => _value / 1e-3, MolarityUnit.NanomolePerLiter => (_value / 1e-3) * 1e-9d, MolarityUnit.PicomolePerLiter => (_value / 1e-3) * 1e-12d, - MolarityUnit.PoundMolePerCubicFoot => _value / 6.2427960576144611956325455827221e-5, + MolarityUnit.PoundMolePerCubicFoot => _value / 0.00220462262184878 * 35.31466672, _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") }; } @@ -269,7 +269,7 @@ private double GetValueAs(MolarityUnit unit) MolarityUnit.MolePerLiter => baseUnitValue * 1e-3, MolarityUnit.NanomolePerLiter => (baseUnitValue * 1e-3) / 1e-9d, MolarityUnit.PicomolePerLiter => (baseUnitValue * 1e-3) / 1e-12d, - MolarityUnit.PoundMolePerCubicFoot => baseUnitValue * 6.2427960576144611956325455827221e-5, + MolarityUnit.PoundMolePerCubicFoot => baseUnitValue * 0.00220462262184878 / 35.31466672, _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs new file mode 100644 index 0000000000..7dad4629ec --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -0,0 +1,217 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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 UnitsNet.Units; + +namespace UnitsNet +{ + /// + /// + /// Equivalent dose is a dose quantity representing the stochastic health effects of low levels of ionizing radiation on the human body which represents the probability of radiation-induced cancer and genetic damage. + /// + public struct RadiationEquivalentDose + { + /// + /// The numeric value this quantity was constructed with. + /// + private readonly double _value; + + /// + /// The unit this quantity was constructed with. + /// + private readonly RadiationEquivalentDoseUnit _unit; + + /// + /// The numeric value this quantity was constructed with. + /// + public double Value => _value; + + /// + public RadiationEquivalentDoseUnit Unit => _unit; + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + public RadiationEquivalentDose(double value, RadiationEquivalentDoseUnit unit) + { + _value = value; + _unit = unit; + } + + /// + /// The base unit of RadiationEquivalentDose, which is Second. All conversions go via this value. + /// + public static RadiationEquivalentDoseUnit BaseUnit { get; } = RadiationEquivalentDoseUnit.Sievert; + + /// + /// Represents the largest possible value of RadiationEquivalentDose. + /// + public static RadiationEquivalentDose MaxValue { get; } = new RadiationEquivalentDose(double.MaxValue, BaseUnit); + + /// + /// Represents the smallest possible value of RadiationEquivalentDose. + /// + public static RadiationEquivalentDose MinValue { get; } = new RadiationEquivalentDose(double.MinValue, BaseUnit); + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit Second. + /// + public static RadiationEquivalentDose Zero { get; } = new RadiationEquivalentDose(0, BaseUnit); + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public double Microsieverts => As(RadiationEquivalentDoseUnit.Microsievert); + + /// + /// Gets a value of this quantity converted into + /// + public double MilliroentgensEquivalentMan => As(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan); + + /// + /// Gets a value of this quantity converted into + /// + public double Millisieverts => As(RadiationEquivalentDoseUnit.Millisievert); + + /// + /// Gets a value of this quantity converted into + /// + public double Nanosieverts => As(RadiationEquivalentDoseUnit.Nanosievert); + + /// + /// Gets a value of this quantity converted into + /// + public double RoentgensEquivalentMan => As(RadiationEquivalentDoseUnit.RoentgenEquivalentMan); + + /// + /// Gets a value of this quantity converted into + /// + public double Sieverts => As(RadiationEquivalentDoseUnit.Sievert); + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMicrosieverts(double microsieverts) => new RadiationEquivalentDose(microsieverts, RadiationEquivalentDoseUnit.Microsievert); + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMilliroentgensEquivalentMan(double milliroentgensequivalentman) => new RadiationEquivalentDose(milliroentgensequivalentman, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan); + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMillisieverts(double millisieverts) => new RadiationEquivalentDose(millisieverts, RadiationEquivalentDoseUnit.Millisievert); + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromNanosieverts(double nanosieverts) => new RadiationEquivalentDose(nanosieverts, RadiationEquivalentDoseUnit.Nanosievert); + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromRoentgensEquivalentMan(double roentgensequivalentman) => new RadiationEquivalentDose(roentgensequivalentman, RadiationEquivalentDoseUnit.RoentgenEquivalentMan); + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromSieverts(double sieverts) => new RadiationEquivalentDose(sieverts, RadiationEquivalentDoseUnit.Sievert); + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// RadiationEquivalentDose unit value. + public static RadiationEquivalentDose From(double value, RadiationEquivalentDoseUnit fromUnit) + { + return new RadiationEquivalentDose(value, fromUnit); + } + + #endregion + + #region Conversion Methods + + /// + /// Convert to the unit representation . + /// + /// Value converted to the specified unit. + public double As(RadiationEquivalentDoseUnit unit) => GetValueAs(unit); + + /// + /// Converts this RadiationEquivalentDose to another RadiationEquivalentDose with the unit representation . + /// + /// A RadiationEquivalentDose with the specified unit. + public RadiationEquivalentDose ToUnit(RadiationEquivalentDoseUnit unit) + { + var convertedValue = GetValueAs(unit); + return new RadiationEquivalentDose(convertedValue, unit); + } + + /// + /// Converts the current value + unit to the base unit. + /// This is typically the first step in converting from one unit to another. + /// + /// The value in the base unit representation. + private double GetValueInBaseUnit() + { + return Unit switch + { + RadiationEquivalentDoseUnit.Microsievert => (_value) * 1e-6d, + RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan => (_value / 100) * 1e-3d, + RadiationEquivalentDoseUnit.Millisievert => (_value) * 1e-3d, + RadiationEquivalentDoseUnit.Nanosievert => (_value) * 1e-9d, + RadiationEquivalentDoseUnit.RoentgenEquivalentMan => _value / 100, + RadiationEquivalentDoseUnit.Sievert => _value, + _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") + }; + } + + private double GetValueAs(RadiationEquivalentDoseUnit unit) + { + if (Unit == unit) + return _value; + + var baseUnitValue = GetValueInBaseUnit(); + + return unit switch + { + RadiationEquivalentDoseUnit.Microsievert => (baseUnitValue) / 1e-6d, + RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan => (baseUnitValue * 100) / 1e-3d, + RadiationEquivalentDoseUnit.Millisievert => (baseUnitValue) / 1e-3d, + RadiationEquivalentDoseUnit.Nanosievert => (baseUnitValue) / 1e-9d, + RadiationEquivalentDoseUnit.RoentgenEquivalentMan => baseUnitValue * 100, + RadiationEquivalentDoseUnit.Sievert => baseUnitValue, + _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") + }; + } + + #endregion + } +} + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index e359274165..812ae427b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -213,9 +213,9 @@ private double GetValueInBaseUnit() return Unit switch { StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute => _value / 6e7, - StandardVolumeFlowUnit.StandardCubicFootPerHour => _value * 7.8657907199999087346816086183876e-6, - StandardVolumeFlowUnit.StandardCubicFootPerMinute => _value / 2118.88000326, - StandardVolumeFlowUnit.StandardCubicFootPerSecond => _value / 35.314666721, + StandardVolumeFlowUnit.StandardCubicFootPerHour => _value * 0.028316846592 / 3600, + StandardVolumeFlowUnit.StandardCubicFootPerMinute => _value * 0.028316846592 / 60, + StandardVolumeFlowUnit.StandardCubicFootPerSecond => _value * 0.028316846592, StandardVolumeFlowUnit.StandardCubicMeterPerDay => _value / 86400, StandardVolumeFlowUnit.StandardCubicMeterPerHour => _value / 3600, StandardVolumeFlowUnit.StandardCubicMeterPerMinute => _value / 60, @@ -235,9 +235,9 @@ private double GetValueAs(StandardVolumeFlowUnit unit) return unit switch { StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute => baseUnitValue * 6e7, - StandardVolumeFlowUnit.StandardCubicFootPerHour => baseUnitValue / 7.8657907199999087346816086183876e-6, - StandardVolumeFlowUnit.StandardCubicFootPerMinute => baseUnitValue * 2118.88000326, - StandardVolumeFlowUnit.StandardCubicFootPerSecond => baseUnitValue * 35.314666721, + StandardVolumeFlowUnit.StandardCubicFootPerHour => baseUnitValue / (0.028316846592 / 3600), + StandardVolumeFlowUnit.StandardCubicFootPerMinute => baseUnitValue / (0.028316846592 / 60), + StandardVolumeFlowUnit.StandardCubicFootPerSecond => baseUnitValue / 0.028316846592, StandardVolumeFlowUnit.StandardCubicMeterPerDay => baseUnitValue * 86400, StandardVolumeFlowUnit.StandardCubicMeterPerHour => baseUnitValue * 3600, StandardVolumeFlowUnit.StandardCubicMeterPerMinute => baseUnitValue * 60, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs index af95b83caf..c552a1e486 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs @@ -670,7 +670,7 @@ private double GetValueInBaseUnit() VolumeUnit.CubicDecimeter => _value / 1e3, VolumeUnit.CubicFoot => _value * 2.8316846592e-2, VolumeUnit.CubicHectometer => _value * 1e6, - VolumeUnit.CubicInch => _value * 1.6387 * 1e-5, + VolumeUnit.CubicInch => _value * 1.6387064e-5, VolumeUnit.CubicKilometer => _value * 1e9, VolumeUnit.CubicMeter => _value, VolumeUnit.CubicMicrometer => _value / 1e18, @@ -687,7 +687,7 @@ private double GetValueInBaseUnit() VolumeUnit.HectousGallon => (_value * 0.003785411784) * 1e2d, VolumeUnit.ImperialBeerBarrel => _value * 0.16365924, VolumeUnit.ImperialGallon => _value * 0.00454609, - VolumeUnit.ImperialOunce => _value * 2.8413062499962901241875439064617e-5, + VolumeUnit.ImperialOunce => _value * 2.84130625e-5, VolumeUnit.ImperialPint => _value * 5.6826125e-4, VolumeUnit.ImperialQuart => _value * 1.1365225e-3, VolumeUnit.KilocubicFoot => (_value * 2.8316846592e-2) * 1e3d, @@ -711,7 +711,7 @@ private double GetValueInBaseUnit() VolumeUnit.UsCustomaryCup => _value * 0.0002365882365, VolumeUnit.UsGallon => _value * 0.003785411784, VolumeUnit.UsLegalCup => _value * 0.00024, - VolumeUnit.UsOunce => _value * 2.957352956253760505068307980135e-5, + VolumeUnit.UsOunce => _value * 2.95735295625e-5, VolumeUnit.UsPint => _value * 4.73176473e-4, VolumeUnit.UsQuart => _value * 9.46352946e-4, VolumeUnit.UsTablespoon => _value * 1.478676478125e-5, @@ -737,7 +737,7 @@ private double GetValueAs(VolumeUnit unit) VolumeUnit.CubicDecimeter => baseUnitValue * 1e3, VolumeUnit.CubicFoot => baseUnitValue / 2.8316846592e-2, VolumeUnit.CubicHectometer => baseUnitValue / 1e6, - VolumeUnit.CubicInch => baseUnitValue / (1.6387 * 1e-5), + VolumeUnit.CubicInch => baseUnitValue / 1.6387064e-5, VolumeUnit.CubicKilometer => baseUnitValue / 1e9, VolumeUnit.CubicMeter => baseUnitValue, VolumeUnit.CubicMicrometer => baseUnitValue * 1e18, @@ -754,7 +754,7 @@ private double GetValueAs(VolumeUnit unit) VolumeUnit.HectousGallon => (baseUnitValue / 0.003785411784) / 1e2d, VolumeUnit.ImperialBeerBarrel => baseUnitValue / 0.16365924, VolumeUnit.ImperialGallon => baseUnitValue / 0.00454609, - VolumeUnit.ImperialOunce => baseUnitValue / 2.8413062499962901241875439064617e-5, + VolumeUnit.ImperialOunce => baseUnitValue / 2.84130625e-5, VolumeUnit.ImperialPint => baseUnitValue / 5.6826125e-4, VolumeUnit.ImperialQuart => baseUnitValue / 1.1365225e-3, VolumeUnit.KilocubicFoot => (baseUnitValue / 2.8316846592e-2) / 1e3d, @@ -778,7 +778,7 @@ private double GetValueAs(VolumeUnit unit) VolumeUnit.UsCustomaryCup => baseUnitValue / 0.0002365882365, VolumeUnit.UsGallon => baseUnitValue / 0.003785411784, VolumeUnit.UsLegalCup => baseUnitValue / 0.00024, - VolumeUnit.UsOunce => baseUnitValue / 2.957352956253760505068307980135e-5, + VolumeUnit.UsOunce => baseUnitValue / 2.95735295625e-5, VolumeUnit.UsPint => baseUnitValue / 4.73176473e-4, VolumeUnit.UsQuart => baseUnitValue / 9.46352946e-4, VolumeUnit.UsTablespoon => baseUnitValue / 1.478676478125e-5, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index 6487e4eab0..052928de13 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -188,6 +188,26 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + /// + /// Gets a value of this quantity converted into + /// + public double DecalitersPerDay => As(VolumeFlowUnit.DecaliterPerDay); + + /// + /// Gets a value of this quantity converted into + /// + public double DecalitersPerHour => As(VolumeFlowUnit.DecaliterPerHour); + + /// + /// Gets a value of this quantity converted into + /// + public double DecalitersPerMinute => As(VolumeFlowUnit.DecaliterPerMinute); + + /// + /// Gets a value of this quantity converted into + /// + public double DecalitersPerSecond => As(VolumeFlowUnit.DecaliterPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -208,6 +228,26 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + /// + /// Gets a value of this quantity converted into + /// + public double HectolitersPerDay => As(VolumeFlowUnit.HectoliterPerDay); + + /// + /// Gets a value of this quantity converted into + /// + public double HectolitersPerHour => As(VolumeFlowUnit.HectoliterPerHour); + + /// + /// Gets a value of this quantity converted into + /// + public double HectolitersPerMinute => As(VolumeFlowUnit.HectoliterPerMinute); + + /// + /// Gets a value of this quantity converted into + /// + public double HectolitersPerSecond => As(VolumeFlowUnit.HectoliterPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -527,6 +567,26 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// public static VolumeFlow FromCubicYardsPerSecond(double cubicyardspersecond) => new VolumeFlow(cubicyardspersecond, VolumeFlowUnit.CubicYardPerSecond); + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerDay(double decalitersperday) => new VolumeFlow(decalitersperday, VolumeFlowUnit.DecaliterPerDay); + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerHour(double decalitersperhour) => new VolumeFlow(decalitersperhour, VolumeFlowUnit.DecaliterPerHour); + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerMinute(double decalitersperminute) => new VolumeFlow(decalitersperminute, VolumeFlowUnit.DecaliterPerMinute); + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerSecond(double decaliterspersecond) => new VolumeFlow(decaliterspersecond, VolumeFlowUnit.DecaliterPerSecond); + /// /// Creates a from . /// @@ -547,6 +607,26 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// public static VolumeFlow FromDecilitersPerSecond(double deciliterspersecond) => new VolumeFlow(deciliterspersecond, VolumeFlowUnit.DeciliterPerSecond); + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerDay(double hectolitersperday) => new VolumeFlow(hectolitersperday, VolumeFlowUnit.HectoliterPerDay); + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerHour(double hectolitersperhour) => new VolumeFlow(hectolitersperhour, VolumeFlowUnit.HectoliterPerHour); + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerMinute(double hectolitersperminute) => new VolumeFlow(hectolitersperminute, VolumeFlowUnit.HectoliterPerMinute); + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerSecond(double hectoliterspersecond) => new VolumeFlow(hectoliterspersecond, VolumeFlowUnit.HectoliterPerSecond); + /// /// Creates a from . /// @@ -802,9 +882,9 @@ private double GetValueInBaseUnit() VolumeFlowUnit.CentiliterPerSecond => (_value / 1000) * 1e-2d, VolumeFlowUnit.CubicCentimeterPerMinute => _value * 1.6666666666667e-8, VolumeFlowUnit.CubicDecimeterPerMinute => _value / 60000.00000, - VolumeFlowUnit.CubicFootPerHour => _value * 7.8657907199999087346816086183876e-6, - VolumeFlowUnit.CubicFootPerMinute => _value / 2118.88000326, - VolumeFlowUnit.CubicFootPerSecond => _value / 35.314666721, + VolumeFlowUnit.CubicFootPerHour => _value * 0.028316846592 / 3600, + VolumeFlowUnit.CubicFootPerMinute => _value * 0.028316846592 / 60, + VolumeFlowUnit.CubicFootPerSecond => _value * 0.028316846592, VolumeFlowUnit.CubicMeterPerDay => _value / 86400, VolumeFlowUnit.CubicMeterPerHour => _value / 3600, VolumeFlowUnit.CubicMeterPerMinute => _value / 60, @@ -814,10 +894,18 @@ private double GetValueInBaseUnit() VolumeFlowUnit.CubicYardPerHour => _value * 2.1237634944E-4, VolumeFlowUnit.CubicYardPerMinute => _value * 0.0127425809664, VolumeFlowUnit.CubicYardPerSecond => _value * 0.764554857984, + VolumeFlowUnit.DecaliterPerDay => (_value / 86400000) * 1e1d, + VolumeFlowUnit.DecaliterPerHour => (_value / 3600000.000) * 1e1d, + VolumeFlowUnit.DecaliterPerMinute => (_value / 60000.00000) * 1e1d, + VolumeFlowUnit.DecaliterPerSecond => (_value / 1000) * 1e1d, VolumeFlowUnit.DeciliterPerDay => (_value / 86400000) * 1e-1d, VolumeFlowUnit.DeciliterPerHour => (_value / 3600000.000) * 1e-1d, VolumeFlowUnit.DeciliterPerMinute => (_value / 60000.00000) * 1e-1d, VolumeFlowUnit.DeciliterPerSecond => (_value / 1000) * 1e-1d, + VolumeFlowUnit.HectoliterPerDay => (_value / 86400000) * 1e2d, + VolumeFlowUnit.HectoliterPerHour => (_value / 3600000.000) * 1e2d, + VolumeFlowUnit.HectoliterPerMinute => (_value / 60000.00000) * 1e2d, + VolumeFlowUnit.HectoliterPerSecond => (_value / 1000) * 1e2d, VolumeFlowUnit.KiloliterPerDay => (_value / 86400000) * 1e3d, VolumeFlowUnit.KiloliterPerHour => (_value / 3600000.000) * 1e3d, VolumeFlowUnit.KiloliterPerMinute => (_value / 60000.00000) * 1e3d, @@ -847,7 +935,7 @@ private double GetValueInBaseUnit() VolumeFlowUnit.NanoliterPerHour => (_value / 3600000.000) * 1e-9d, VolumeFlowUnit.NanoliterPerMinute => (_value / 60000.00000) * 1e-9d, VolumeFlowUnit.NanoliterPerSecond => (_value / 1000) * 1e-9d, - VolumeFlowUnit.OilBarrelPerDay => _value * 1.8401307283333333333333333333333e-6, + VolumeFlowUnit.OilBarrelPerDay => _value * 1.8401307283333e-6, VolumeFlowUnit.OilBarrelPerHour => _value * 4.41631375e-5, VolumeFlowUnit.OilBarrelPerMinute => _value * 2.64978825e-3, VolumeFlowUnit.OilBarrelPerSecond => _value / 6.28981, @@ -882,9 +970,9 @@ private double GetValueAs(VolumeFlowUnit unit) VolumeFlowUnit.CentiliterPerSecond => (baseUnitValue * 1000) / 1e-2d, VolumeFlowUnit.CubicCentimeterPerMinute => baseUnitValue / 1.6666666666667e-8, VolumeFlowUnit.CubicDecimeterPerMinute => baseUnitValue * 60000.00000, - VolumeFlowUnit.CubicFootPerHour => baseUnitValue / 7.8657907199999087346816086183876e-6, - VolumeFlowUnit.CubicFootPerMinute => baseUnitValue * 2118.88000326, - VolumeFlowUnit.CubicFootPerSecond => baseUnitValue * 35.314666721, + VolumeFlowUnit.CubicFootPerHour => baseUnitValue / (0.028316846592 / 3600), + VolumeFlowUnit.CubicFootPerMinute => baseUnitValue / (0.028316846592 / 60), + VolumeFlowUnit.CubicFootPerSecond => baseUnitValue / 0.028316846592, VolumeFlowUnit.CubicMeterPerDay => baseUnitValue * 86400, VolumeFlowUnit.CubicMeterPerHour => baseUnitValue * 3600, VolumeFlowUnit.CubicMeterPerMinute => baseUnitValue * 60, @@ -894,10 +982,18 @@ private double GetValueAs(VolumeFlowUnit unit) VolumeFlowUnit.CubicYardPerHour => baseUnitValue / 2.1237634944E-4, VolumeFlowUnit.CubicYardPerMinute => baseUnitValue / 0.0127425809664, VolumeFlowUnit.CubicYardPerSecond => baseUnitValue / 0.764554857984, + VolumeFlowUnit.DecaliterPerDay => (baseUnitValue * 86400000) / 1e1d, + VolumeFlowUnit.DecaliterPerHour => (baseUnitValue * 3600000.000) / 1e1d, + VolumeFlowUnit.DecaliterPerMinute => (baseUnitValue * 60000.00000) / 1e1d, + VolumeFlowUnit.DecaliterPerSecond => (baseUnitValue * 1000) / 1e1d, VolumeFlowUnit.DeciliterPerDay => (baseUnitValue * 86400000) / 1e-1d, VolumeFlowUnit.DeciliterPerHour => (baseUnitValue * 3600000.000) / 1e-1d, VolumeFlowUnit.DeciliterPerMinute => (baseUnitValue * 60000.00000) / 1e-1d, VolumeFlowUnit.DeciliterPerSecond => (baseUnitValue * 1000) / 1e-1d, + VolumeFlowUnit.HectoliterPerDay => (baseUnitValue * 86400000) / 1e2d, + VolumeFlowUnit.HectoliterPerHour => (baseUnitValue * 3600000.000) / 1e2d, + VolumeFlowUnit.HectoliterPerMinute => (baseUnitValue * 60000.00000) / 1e2d, + VolumeFlowUnit.HectoliterPerSecond => (baseUnitValue * 1000) / 1e2d, VolumeFlowUnit.KiloliterPerDay => (baseUnitValue * 86400000) / 1e3d, VolumeFlowUnit.KiloliterPerHour => (baseUnitValue * 3600000.000) / 1e3d, VolumeFlowUnit.KiloliterPerMinute => (baseUnitValue * 60000.00000) / 1e3d, @@ -927,7 +1023,7 @@ private double GetValueAs(VolumeFlowUnit unit) VolumeFlowUnit.NanoliterPerHour => (baseUnitValue * 3600000.000) / 1e-9d, VolumeFlowUnit.NanoliterPerMinute => (baseUnitValue * 60000.00000) / 1e-9d, VolumeFlowUnit.NanoliterPerSecond => (baseUnitValue * 1000) / 1e-9d, - VolumeFlowUnit.OilBarrelPerDay => baseUnitValue / 1.8401307283333333333333333333333e-6, + VolumeFlowUnit.OilBarrelPerDay => baseUnitValue / 1.8401307283333e-6, VolumeFlowUnit.OilBarrelPerHour => baseUnitValue / 4.41631375e-5, VolumeFlowUnit.OilBarrelPerMinute => baseUnitValue / 2.64978825e-3, VolumeFlowUnit.OilBarrelPerSecond => baseUnitValue * 6.28981, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 370afa1fda..65ff4a28bc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -184,7 +184,7 @@ private double GetValueInBaseUnit() { WarpingMomentOfInertiaUnit.CentimeterToTheSixth => _value / 1e12, WarpingMomentOfInertiaUnit.DecimeterToTheSixth => _value / 1e6, - WarpingMomentOfInertiaUnit.FootToTheSixth => _value * Math.Pow(0.3048, 6), + WarpingMomentOfInertiaUnit.FootToTheSixth => _value * 0.000801843800914862014464, WarpingMomentOfInertiaUnit.InchToTheSixth => _value * Math.Pow(2.54e-2, 6), WarpingMomentOfInertiaUnit.MeterToTheSixth => _value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth => _value / 1e18, @@ -203,7 +203,7 @@ private double GetValueAs(WarpingMomentOfInertiaUnit unit) { WarpingMomentOfInertiaUnit.CentimeterToTheSixth => baseUnitValue * 1e12, WarpingMomentOfInertiaUnit.DecimeterToTheSixth => baseUnitValue * 1e6, - WarpingMomentOfInertiaUnit.FootToTheSixth => baseUnitValue / Math.Pow(0.3048, 6), + WarpingMomentOfInertiaUnit.FootToTheSixth => baseUnitValue / 0.000801843800914862014464, WarpingMomentOfInertiaUnit.InchToTheSixth => baseUnitValue / Math.Pow(2.54e-2, 6), WarpingMomentOfInertiaUnit.MeterToTheSixth => baseUnitValue, WarpingMomentOfInertiaUnit.MillimeterToTheSixth => baseUnitValue * 1e18, diff --git a/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/RadiationEquivalentDose.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/RadiationEquivalentDose.nfproj new file mode 100644 index 0000000000..552e257f67 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/RadiationEquivalentDose.nfproj @@ -0,0 +1,42 @@ + + + + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ + + + + Debug + AnyCPU + {11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + {dcdccf04-c930-b455-77a4-d9d4a7df8723} + Library + Properties + 512 + UnitsNet + UnitsNet.RadiationEquivalentDose + v1.0 + bin\$(Configuration)\$(AssemblyName).xml + + + + + + + + + + ..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll + True + True + + + + + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/UnitsNet.NanoFramework.RadiationEquivalentDose.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/UnitsNet.NanoFramework.RadiationEquivalentDose.nuspec new file mode 100644 index 0000000000..5e39a87c6d --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/UnitsNet.NanoFramework.RadiationEquivalentDose.nuspec @@ -0,0 +1,26 @@ + + + + UnitsNet.nanoFramework.RadiationEquivalentDose + 6.0.0-pre006 + Units.NET RadiationEquivalentDose - nanoFramework + Andreas Gullberg Larsen,nanoframework + UnitsNet + MIT-0 + https://github.com/angularsen/UnitsNet + false + Adds RadiationEquivalentDose units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. + https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png + + + Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). + en-US + nanoframework radiationequivalentdose unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable + + + + + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/packages.config b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/packages.config new file mode 100644 index 0000000000..313a8dccdf --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/RadiationEquivalentDose/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RadiationExposure/UnitsNet.NanoFramework.RadiationExposure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RadiationExposure/UnitsNet.NanoFramework.RadiationExposure.nuspec index 3422169043..64b9009223 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RadiationExposure/UnitsNet.NanoFramework.RadiationExposure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RadiationExposure/UnitsNet.NanoFramework.RadiationExposure.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RadiationExposure - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RadiationExposure - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RadiationExposure units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Radioactivity/UnitsNet.NanoFramework.Radioactivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Radioactivity/UnitsNet.NanoFramework.Radioactivity.nuspec index 355143390f..964dc047e5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Radioactivity/UnitsNet.NanoFramework.Radioactivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Radioactivity/UnitsNet.NanoFramework.Radioactivity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Radioactivity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Radioactivity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Radioactivity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 6cbca2b03e..97bc5334ce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Ratio - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Ratio units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index 75fe2a795f..c68f593e6b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RatioChangeRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RatioChangeRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index 0864450750..3273e83d0c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ReactiveEnergy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ReactiveEnergy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index e5fe2ad590..7c2eb24be4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ReactivePower - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ReactivePower units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 8ad50bc1e3..298ab7ca94 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ReciprocalArea - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ReciprocalArea units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index f295702b9f..3da3990c08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ReciprocalLength - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ReciprocalLength units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index 8dea8cc176..f5fd4a4b7e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RelativeHumidity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RelativeHumidity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index 1bf54f9d6c..759c615f95 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RotationalAcceleration - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RotationalAcceleration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 1c097bbbf1..d539a3fe32 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RotationalSpeed - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RotationalSpeed units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index f43923368d..2017d12272 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RotationalStiffness - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RotationalStiffness units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index d7d981688d..208a2e105b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 6.0.0-pre002 + 6.0.0-pre006 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds RotationalStiffnessPerLength units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 072d9230cd..6378a5e8b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Scalar - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Scalar units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 90b39e7f92..4b4ceefb23 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SolidAngle - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SolidAngle units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 187f4401db..fe2ee7f825 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SpecificEnergy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SpecificEnergy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index d5ed99cf0e..9765f6dd82 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SpecificEntropy - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SpecificEntropy units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 297663da6a..4e03dfbf02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SpecificFuelConsumption units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 6102fe1d0b..0f01b7795f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SpecificVolume - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SpecificVolume units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 9bf3064045..66339b7946 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.SpecificWeight - 6.0.0-pre002 + 6.0.0-pre006 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds SpecificWeight units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index 1818a483f0..04a5b93aa2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Speed - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Speed units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 76c1085b88..e33459bc31 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 6.0.0-pre002 + 6.0.0-pre006 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds StandardVolumeFlow units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index f142047e92..8aded72c90 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Temperature - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Temperature units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 66fbb41220..90d5edd58e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 6.0.0-pre002 + 6.0.0-pre006 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds TemperatureChangeRate units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 758c136fa5..bf80969093 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.TemperatureDelta - 6.0.0-pre002 + 6.0.0-pre006 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds TemperatureDelta units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec index 3ebfc812f7..5088e8b5a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.TemperatureGradient - 6.0.0-pre002 + 6.0.0-pre006 Units.NET TemperatureGradient - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds TemperatureGradient units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index fc491c6431..18cc985fb4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ThermalConductivity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ThermalConductivity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index 72b991cf1f..8f08481295 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.ThermalResistance - 6.0.0-pre002 + 6.0.0-pre006 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds ThermalResistance units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 876f789701..fa36938ec6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Torque - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Torque units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index b6af04d90d..8f611759ab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.TorquePerLength - 6.0.0-pre002 + 6.0.0-pre006 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds TorquePerLength units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 708818bc43..f62fb43b3f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Turbidity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Turbidity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs index 449fdf2491..26d131063a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs @@ -25,9 +25,11 @@ namespace UnitsNet.Units public enum IrradiationUnit { + BtuPerSquareFoot = 15, JoulePerSquareCentimeter = 1, JoulePerSquareMeter = 2, JoulePerSquareMillimeter = 3, + KilobtuPerSquareFoot = 9, KilojoulePerSquareMeter = 4, KilowattHourPerSquareMeter = 5, MillijoulePerSquareCentimeter = 6, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs new file mode 100644 index 0000000000..2095852833 --- /dev/null +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum RadiationEquivalentDoseUnit + { + Microsievert = 1, + MilliroentgenEquivalentMan = 2, + Millisievert = 7, + Nanosievert = 5, + RoentgenEquivalentMan = 4, + + /// + /// The sievert is a unit in the International System of Units (SI) intended to represent the stochastic health risk of ionizing radiation, which is defined as the probability of causing radiation-induced cancer and genetic damage. + /// + /// https://en.wikipedia.org/wiki/Sievert + Sievert = 9, + } + + #pragma warning restore 1591 +} diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs index ab8b2bca49..6c14bc7b98 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -47,10 +47,18 @@ public enum VolumeFlowUnit CubicYardPerHour = 20, CubicYardPerMinute = 21, CubicYardPerSecond = 22, + DecaliterPerDay = 71, + DecaliterPerHour = 78, + DecaliterPerMinute = 67, + DecaliterPerSecond = 70, DeciliterPerDay = 23, DeciliterPerHour = 24, DeciliterPerMinute = 25, DeciliterPerSecond = 26, + HectoliterPerDay = 74, + HectoliterPerHour = 72, + HectoliterPerMinute = 75, + HectoliterPerSecond = 69, KiloliterPerDay = 27, KiloliterPerHour = 28, KiloliterPerMinute = 29, diff --git a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln index 4ae1dab440..d64098f57d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln +++ b/UnitsNet.NanoFramework/GeneratedCode/UnitsNet.nanoFramework.sln @@ -170,6 +170,8 @@ Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Pressure", "Pressure\Pressu EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "PressureChangeRate", "PressureChangeRate\PressureChangeRate.nfproj", "{c9e4cfa9-c5d3-5e9d-243c-106ba4b6a447}" EndProject +Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "RadiationEquivalentDose", "RadiationEquivalentDose\RadiationEquivalentDose.nfproj", "{dcdccf04-c930-b455-77a4-d9d4a7df8723}" +EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "RadiationExposure", "RadiationExposure\RadiationExposure.nfproj", "{69b383c7-828a-1857-cbe2-f11b9ba77320}" EndProject Project("{d608a2b1-6ead-4383-a205-ad1ce69d9ef7}") = "Radioactivity", "Radioactivity\Radioactivity.nfproj", "{abf4b42f-e999-2a78-403f-fb09524f186a}" @@ -758,6 +760,12 @@ Global {c9e4cfa9-c5d3-5e9d-243c-106ba4b6a447}.Release|Any CPU.ActiveCfg = Release|Any CPU {c9e4cfa9-c5d3-5e9d-243c-106ba4b6a447}.Release|Any CPU.Build.0 = Release|Any CPU {c9e4cfa9-c5d3-5e9d-243c-106ba4b6a447}.Release|Any CPU.Deploy.0 = Release|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Debug|Any CPU.ActiveCfg = Debug|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Debug|Any CPU.Build.0 = Debug|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Debug|Any CPU.Deploy.0 = Debug|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Release|Any CPU.ActiveCfg = Release|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Release|Any CPU.Build.0 = Release|Any CPU +{dcdccf04-c930-b455-77a4-d9d4a7df8723}.Release|Any CPU.Deploy.0 = Release|Any CPU {69b383c7-828a-1857-cbe2-f11b9ba77320}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69b383c7-828a-1857-cbe2-f11b9ba77320}.Debug|Any CPU.Build.0 = Debug|Any CPU {69b383c7-828a-1857-cbe2-f11b9ba77320}.Debug|Any CPU.Deploy.0 = Debug|Any CPU diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index 1cd4004167..4c3c1b4944 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VitaminA - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VitaminA units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 8deab862b7..985a60544a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.Volume - 6.0.0-pre002 + 6.0.0-pre006 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds Volume units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index 7b5ffd0efc..7580eec0bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VolumeConcentration - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VolumeConcentration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index fd75a5a62c..52adce9d8e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VolumeFlow - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VolumeFlow units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec index 8f8f9167e3..19b0b42cc6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VolumeFlowPerArea - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VolumeFlowPerArea - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VolumeFlowPerArea units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index 888c9ff84c..9f02db1904 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VolumePerLength - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VolumePerLength units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 914e6fec32..8582de2853 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 6.0.0-pre002 + 6.0.0-pre006 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds VolumetricHeatCapacity units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index c8f74a22f9..7fb474ddd4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,11 +2,11 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 6.0.0-pre002 + 6.0.0-pre006 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet - MIT + MIT-0 https://github.com/angularsen/UnitsNet false Adds WarpingMomentOfInertia units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead. diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs index 23b0b7a841..50794ecd99 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs @@ -24,6 +24,10 @@ namespace UnitsNet.Tests { public class NumberToIrradiationExtensionsTests { + [Fact] + public void NumberToBtusPerSquareFootTest() => + Assert.Equal(Irradiation.FromBtusPerSquareFoot(2), 2.BtusPerSquareFoot()); + [Fact] public void NumberToJoulesPerSquareCentimeterTest() => Assert.Equal(Irradiation.FromJoulesPerSquareCentimeter(2), 2.JoulesPerSquareCentimeter()); @@ -36,6 +40,10 @@ public void NumberToJoulesPerSquareMeterTest() => public void NumberToJoulesPerSquareMillimeterTest() => Assert.Equal(Irradiation.FromJoulesPerSquareMillimeter(2), 2.JoulesPerSquareMillimeter()); + [Fact] + public void NumberToKilobtusPerSquareFootTest() => + Assert.Equal(Irradiation.FromKilobtusPerSquareFoot(2), 2.KilobtusPerSquareFoot()); + [Fact] public void NumberToKilojoulesPerSquareMeterTest() => Assert.Equal(Irradiation.FromKilojoulesPerSquareMeter(2), 2.KilojoulesPerSquareMeter()); diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseExtensionsTest.g.cs new file mode 100644 index 0000000000..65aebc965b --- /dev/null +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseExtensionsTest.g.cs @@ -0,0 +1,52 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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.NumberExtensions.NumberToRadiationEquivalentDose; +using Xunit; + +namespace UnitsNet.Tests +{ + public class NumberToRadiationEquivalentDoseExtensionsTests + { + [Fact] + public void NumberToMicrosievertsTest() => + Assert.Equal(RadiationEquivalentDose.FromMicrosieverts(2), 2.Microsieverts()); + + [Fact] + public void NumberToMilliroentgensEquivalentManTest() => + Assert.Equal(RadiationEquivalentDose.FromMilliroentgensEquivalentMan(2), 2.MilliroentgensEquivalentMan()); + + [Fact] + public void NumberToMillisievertsTest() => + Assert.Equal(RadiationEquivalentDose.FromMillisieverts(2), 2.Millisieverts()); + + [Fact] + public void NumberToNanosievertsTest() => + Assert.Equal(RadiationEquivalentDose.FromNanosieverts(2), 2.Nanosieverts()); + + [Fact] + public void NumberToRoentgensEquivalentManTest() => + Assert.Equal(RadiationEquivalentDose.FromRoentgensEquivalentMan(2), 2.RoentgensEquivalentMan()); + + [Fact] + public void NumberToSievertsTest() => + Assert.Equal(RadiationEquivalentDose.FromSieverts(2), 2.Sieverts()); + + } +} diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs index 13d1660359..028a366069 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs @@ -112,6 +112,22 @@ public void NumberToCubicYardsPerMinuteTest() => public void NumberToCubicYardsPerSecondTest() => Assert.Equal(VolumeFlow.FromCubicYardsPerSecond(2), 2.CubicYardsPerSecond()); + [Fact] + public void NumberToDecalitersPerDayTest() => + Assert.Equal(VolumeFlow.FromDecalitersPerDay(2), 2.DecalitersPerDay()); + + [Fact] + public void NumberToDecalitersPerHourTest() => + Assert.Equal(VolumeFlow.FromDecalitersPerHour(2), 2.DecalitersPerHour()); + + [Fact] + public void NumberToDecalitersPerMinuteTest() => + Assert.Equal(VolumeFlow.FromDecalitersPerMinute(2), 2.DecalitersPerMinute()); + + [Fact] + public void NumberToDecalitersPerSecondTest() => + Assert.Equal(VolumeFlow.FromDecalitersPerSecond(2), 2.DecalitersPerSecond()); + [Fact] public void NumberToDecilitersPerDayTest() => Assert.Equal(VolumeFlow.FromDecilitersPerDay(2), 2.DecilitersPerDay()); @@ -128,6 +144,22 @@ public void NumberToDecilitersPerMinuteTest() => public void NumberToDecilitersPerSecondTest() => Assert.Equal(VolumeFlow.FromDecilitersPerSecond(2), 2.DecilitersPerSecond()); + [Fact] + public void NumberToHectolitersPerDayTest() => + Assert.Equal(VolumeFlow.FromHectolitersPerDay(2), 2.HectolitersPerDay()); + + [Fact] + public void NumberToHectolitersPerHourTest() => + Assert.Equal(VolumeFlow.FromHectolitersPerHour(2), 2.HectolitersPerHour()); + + [Fact] + public void NumberToHectolitersPerMinuteTest() => + Assert.Equal(VolumeFlow.FromHectolitersPerMinute(2), 2.HectolitersPerMinute()); + + [Fact] + public void NumberToHectolitersPerSecondTest() => + Assert.Equal(VolumeFlow.FromHectolitersPerSecond(2), 2.HectolitersPerSecond()); + [Fact] public void NumberToKilolitersPerDayTest() => Assert.Equal(VolumeFlow.FromKilolitersPerDay(2), 2.KilolitersPerDay()); diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 015498125f..e655661336 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 UnitsNet.NumberExtensions.Tests latest enable @@ -25,10 +25,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAbsorbedDoseOfIonizingRadiationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAbsorbedDoseOfIonizingRadiationExtensions.g.cs index 8011ae4fef..c57be2a47c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAbsorbedDoseOfIonizingRadiationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAbsorbedDoseOfIonizingRadiationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAbsorbedDoseOfIonizingRadiation /// public static class NumberToAbsorbedDoseOfIonizingRadiationExtensions { - /// + /// public static AbsorbedDoseOfIonizingRadiation Centigrays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static AbsorbedDoseOfIonizingRadiation Centigrays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromCentigrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Femtograys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static AbsorbedDoseOfIonizingRadiation Femtograys(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromFemtograys(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Gigagrays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static AbsorbedDoseOfIonizingRadiation Gigagrays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromGigagrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Grays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static AbsorbedDoseOfIonizingRadiation Grays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromGrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Kilograys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static AbsorbedDoseOfIonizingRadiation Kilograys(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromKilograys(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Kilorads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static AbsorbedDoseOfIonizingRadiation Kilorads(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromKilorads(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Megagrays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static AbsorbedDoseOfIonizingRadiation Megagrays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromMegagrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Megarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static AbsorbedDoseOfIonizingRadiation Megarads(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromMegarads(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Micrograys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static AbsorbedDoseOfIonizingRadiation Micrograys(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromMicrograys(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Milligrays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static AbsorbedDoseOfIonizingRadiation Milligrays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromMilligrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Millirads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static AbsorbedDoseOfIonizingRadiation Millirads(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromMillirads(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Nanograys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static AbsorbedDoseOfIonizingRadiation Nanograys(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromNanograys(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Petagrays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static AbsorbedDoseOfIonizingRadiation Petagrays(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromPetagrays(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Picograys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static AbsorbedDoseOfIonizingRadiation Picograys(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromPicograys(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Rads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static AbsorbedDoseOfIonizingRadiation Rads(this T value) #endif => AbsorbedDoseOfIonizingRadiation.FromRads(Convert.ToDouble(value)); - /// + /// public static AbsorbedDoseOfIonizingRadiation Teragrays(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs index 53301e4bef..e0120c9cf2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAcceleration /// public static class NumberToAccelerationExtensions { - /// + /// public static Acceleration CentimetersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Acceleration CentimetersPerSecondSquared(this T value) #endif => Acceleration.FromCentimetersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration DecimetersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Acceleration DecimetersPerSecondSquared(this T value) #endif => Acceleration.FromDecimetersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration FeetPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Acceleration FeetPerSecondSquared(this T value) #endif => Acceleration.FromFeetPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration InchesPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Acceleration InchesPerSecondSquared(this T value) #endif => Acceleration.FromInchesPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration KilometersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Acceleration KilometersPerSecondSquared(this T value) #endif => Acceleration.FromKilometersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration KnotsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Acceleration KnotsPerHour(this T value) #endif => Acceleration.FromKnotsPerHour(Convert.ToDouble(value)); - /// + /// public static Acceleration KnotsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Acceleration KnotsPerMinute(this T value) #endif => Acceleration.FromKnotsPerMinute(Convert.ToDouble(value)); - /// + /// public static Acceleration KnotsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Acceleration KnotsPerSecond(this T value) #endif => Acceleration.FromKnotsPerSecond(Convert.ToDouble(value)); - /// + /// public static Acceleration MetersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Acceleration MetersPerSecondSquared(this T value) #endif => Acceleration.FromMetersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration MicrometersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Acceleration MicrometersPerSecondSquared(this T value) #endif => Acceleration.FromMicrometersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration MillimetersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Acceleration MillimetersPerSecondSquared(this T value) #endif => Acceleration.FromMillimetersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration MillistandardGravity(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Acceleration MillistandardGravity(this T value) #endif => Acceleration.FromMillistandardGravity(Convert.ToDouble(value)); - /// + /// public static Acceleration NanometersPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Acceleration NanometersPerSecondSquared(this T value) #endif => Acceleration.FromNanometersPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static Acceleration StandardGravity(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs index 4993b43931..be7d43abef 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAmountOfSubstance /// public static class NumberToAmountOfSubstanceExtensions { - /// + /// public static AmountOfSubstance Centimoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static AmountOfSubstance Centimoles(this T value) #endif => AmountOfSubstance.FromCentimoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance CentipoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static AmountOfSubstance CentipoundMoles(this T value) #endif => AmountOfSubstance.FromCentipoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Decimoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static AmountOfSubstance Decimoles(this T value) #endif => AmountOfSubstance.FromDecimoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance DecipoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static AmountOfSubstance DecipoundMoles(this T value) #endif => AmountOfSubstance.FromDecipoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Femtomoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static AmountOfSubstance Femtomoles(this T value) #endif => AmountOfSubstance.FromFemtomoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Kilomoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static AmountOfSubstance Kilomoles(this T value) #endif => AmountOfSubstance.FromKilomoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance KilopoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static AmountOfSubstance KilopoundMoles(this T value) #endif => AmountOfSubstance.FromKilopoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Megamoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static AmountOfSubstance Megamoles(this T value) #endif => AmountOfSubstance.FromMegamoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Micromoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static AmountOfSubstance Micromoles(this T value) #endif => AmountOfSubstance.FromMicromoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance MicropoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static AmountOfSubstance MicropoundMoles(this T value) #endif => AmountOfSubstance.FromMicropoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Millimoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static AmountOfSubstance Millimoles(this T value) #endif => AmountOfSubstance.FromMillimoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance MillipoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static AmountOfSubstance MillipoundMoles(this T value) #endif => AmountOfSubstance.FromMillipoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Moles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static AmountOfSubstance Moles(this T value) #endif => AmountOfSubstance.FromMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Nanomoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static AmountOfSubstance Nanomoles(this T value) #endif => AmountOfSubstance.FromNanomoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance NanopoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static AmountOfSubstance NanopoundMoles(this T value) #endif => AmountOfSubstance.FromNanopoundMoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance Picomoles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static AmountOfSubstance Picomoles(this T value) #endif => AmountOfSubstance.FromPicomoles(Convert.ToDouble(value)); - /// + /// public static AmountOfSubstance PoundMoles(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs index 778ee3b019..aa49a55df5 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAmplitudeRatio /// public static class NumberToAmplitudeRatioExtensions { - /// + /// public static AmplitudeRatio DecibelMicrovolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static AmplitudeRatio DecibelMicrovolts(this T value) #endif => AmplitudeRatio.FromDecibelMicrovolts(Convert.ToDouble(value)); - /// + /// public static AmplitudeRatio DecibelMillivolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static AmplitudeRatio DecibelMillivolts(this T value) #endif => AmplitudeRatio.FromDecibelMillivolts(Convert.ToDouble(value)); - /// + /// public static AmplitudeRatio DecibelsUnloaded(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static AmplitudeRatio DecibelsUnloaded(this T value) #endif => AmplitudeRatio.FromDecibelsUnloaded(Convert.ToDouble(value)); - /// + /// public static AmplitudeRatio DecibelVolts(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs index 538044922c..5bb72f059c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAngle /// public static class NumberToAngleExtensions { - /// + /// public static Angle Arcminutes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Angle Arcminutes(this T value) #endif => Angle.FromArcminutes(Convert.ToDouble(value)); - /// + /// public static Angle Arcseconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Angle Arcseconds(this T value) #endif => Angle.FromArcseconds(Convert.ToDouble(value)); - /// + /// public static Angle Centiradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Angle Centiradians(this T value) #endif => Angle.FromCentiradians(Convert.ToDouble(value)); - /// + /// public static Angle Deciradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Angle Deciradians(this T value) #endif => Angle.FromDeciradians(Convert.ToDouble(value)); - /// + /// public static Angle Degrees(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Angle Degrees(this T value) #endif => Angle.FromDegrees(Convert.ToDouble(value)); - /// + /// public static Angle Gradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Angle Gradians(this T value) #endif => Angle.FromGradians(Convert.ToDouble(value)); - /// + /// public static Angle Microdegrees(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Angle Microdegrees(this T value) #endif => Angle.FromMicrodegrees(Convert.ToDouble(value)); - /// + /// public static Angle Microradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Angle Microradians(this T value) #endif => Angle.FromMicroradians(Convert.ToDouble(value)); - /// + /// public static Angle Millidegrees(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Angle Millidegrees(this T value) #endif => Angle.FromMillidegrees(Convert.ToDouble(value)); - /// + /// public static Angle Milliradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Angle Milliradians(this T value) #endif => Angle.FromMilliradians(Convert.ToDouble(value)); - /// + /// public static Angle Nanodegrees(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Angle Nanodegrees(this T value) #endif => Angle.FromNanodegrees(Convert.ToDouble(value)); - /// + /// public static Angle Nanoradians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Angle Nanoradians(this T value) #endif => Angle.FromNanoradians(Convert.ToDouble(value)); - /// + /// public static Angle NatoMils(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Angle NatoMils(this T value) #endif => Angle.FromNatoMils(Convert.ToDouble(value)); - /// + /// public static Angle Radians(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Angle Radians(this T value) #endif => Angle.FromRadians(Convert.ToDouble(value)); - /// + /// public static Angle Revolutions(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Angle Revolutions(this T value) #endif => Angle.FromRevolutions(Convert.ToDouble(value)); - /// + /// public static Angle Tilt(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs index 4f5e9aa218..87b0fad3af 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToApparentEnergy /// public static class NumberToApparentEnergyExtensions { - /// + /// public static ApparentEnergy KilovoltampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ApparentEnergy KilovoltampereHours(this T value) #endif => ApparentEnergy.FromKilovoltampereHours(Convert.ToDouble(value)); - /// + /// public static ApparentEnergy MegavoltampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ApparentEnergy MegavoltampereHours(this T value) #endif => ApparentEnergy.FromMegavoltampereHours(Convert.ToDouble(value)); - /// + /// public static ApparentEnergy VoltampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs index 7fb405d7e3..e81f77687c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToApparentPower /// public static class NumberToApparentPowerExtensions { - /// + /// public static ApparentPower Gigavoltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ApparentPower Gigavoltamperes(this T value) #endif => ApparentPower.FromGigavoltamperes(Convert.ToDouble(value)); - /// + /// public static ApparentPower Kilovoltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ApparentPower Kilovoltamperes(this T value) #endif => ApparentPower.FromKilovoltamperes(Convert.ToDouble(value)); - /// + /// public static ApparentPower Megavoltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ApparentPower Megavoltamperes(this T value) #endif => ApparentPower.FromMegavoltamperes(Convert.ToDouble(value)); - /// + /// public static ApparentPower Microvoltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ApparentPower Microvoltamperes(this T value) #endif => ApparentPower.FromMicrovoltamperes(Convert.ToDouble(value)); - /// + /// public static ApparentPower Millivoltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ApparentPower Millivoltamperes(this T value) #endif => ApparentPower.FromMillivoltamperes(Convert.ToDouble(value)); - /// + /// public static ApparentPower Voltamperes(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs index ad2a5a212a..8a39f732fa 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAreaDensity /// public static class NumberToAreaDensityExtensions { - /// + /// public static AreaDensity GramsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static AreaDensity GramsPerSquareMeter(this T value) #endif => AreaDensity.FromGramsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static AreaDensity KilogramsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static AreaDensity KilogramsPerSquareMeter(this T value) #endif => AreaDensity.FromKilogramsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static AreaDensity MilligramsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs index 11c81e72b1..9d2b2749b1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToArea /// public static class NumberToAreaExtensions { - /// + /// public static Area Acres(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Area Acres(this T value) #endif => Area.FromAcres(Convert.ToDouble(value)); - /// + /// public static Area Hectares(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Area Hectares(this T value) #endif => Area.FromHectares(Convert.ToDouble(value)); - /// + /// public static Area SquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Area SquareCentimeters(this T value) #endif => Area.FromSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static Area SquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Area SquareDecimeters(this T value) #endif => Area.FromSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static Area SquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Area SquareFeet(this T value) #endif => Area.FromSquareFeet(Convert.ToDouble(value)); - /// + /// public static Area SquareInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Area SquareInches(this T value) #endif => Area.FromSquareInches(Convert.ToDouble(value)); - /// + /// public static Area SquareKilometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Area SquareKilometers(this T value) #endif => Area.FromSquareKilometers(Convert.ToDouble(value)); - /// + /// public static Area SquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Area SquareMeters(this T value) #endif => Area.FromSquareMeters(Convert.ToDouble(value)); - /// + /// public static Area SquareMicrometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Area SquareMicrometers(this T value) #endif => Area.FromSquareMicrometers(Convert.ToDouble(value)); - /// + /// public static Area SquareMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Area SquareMiles(this T value) #endif => Area.FromSquareMiles(Convert.ToDouble(value)); - /// + /// public static Area SquareMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Area SquareMillimeters(this T value) #endif => Area.FromSquareMillimeters(Convert.ToDouble(value)); - /// + /// public static Area SquareNauticalMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Area SquareNauticalMiles(this T value) #endif => Area.FromSquareNauticalMiles(Convert.ToDouble(value)); - /// + /// public static Area SquareYards(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Area SquareYards(this T value) #endif => Area.FromSquareYards(Convert.ToDouble(value)); - /// + /// public static Area UsSurveySquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs index 09807623e6..63205a9036 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToAreaMomentOfInertia /// public static class NumberToAreaMomentOfInertiaExtensions { - /// + /// public static AreaMomentOfInertia CentimetersToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static AreaMomentOfInertia CentimetersToTheFourth(this T value) #endif => AreaMomentOfInertia.FromCentimetersToTheFourth(Convert.ToDouble(value)); - /// + /// public static AreaMomentOfInertia DecimetersToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static AreaMomentOfInertia DecimetersToTheFourth(this T value) #endif => AreaMomentOfInertia.FromDecimetersToTheFourth(Convert.ToDouble(value)); - /// + /// public static AreaMomentOfInertia FeetToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static AreaMomentOfInertia FeetToTheFourth(this T value) #endif => AreaMomentOfInertia.FromFeetToTheFourth(Convert.ToDouble(value)); - /// + /// public static AreaMomentOfInertia InchesToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static AreaMomentOfInertia InchesToTheFourth(this T value) #endif => AreaMomentOfInertia.FromInchesToTheFourth(Convert.ToDouble(value)); - /// + /// public static AreaMomentOfInertia MetersToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static AreaMomentOfInertia MetersToTheFourth(this T value) #endif => AreaMomentOfInertia.FromMetersToTheFourth(Convert.ToDouble(value)); - /// + /// public static AreaMomentOfInertia MillimetersToTheFourth(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs index 2f85da9ccc..6358a6ea2b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToBitRate /// public static class NumberToBitRateExtensions { - /// + /// public static BitRate BitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static BitRate BitsPerSecond(this T value) #endif => BitRate.FromBitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate BytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static BitRate BytesPerSecond(this T value) #endif => BitRate.FromBytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate ExabitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static BitRate ExabitsPerSecond(this T value) #endif => BitRate.FromExabitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate ExabytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static BitRate ExabytesPerSecond(this T value) #endif => BitRate.FromExabytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate ExbibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static BitRate ExbibitsPerSecond(this T value) #endif => BitRate.FromExbibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate ExbibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static BitRate ExbibytesPerSecond(this T value) #endif => BitRate.FromExbibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate GibibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static BitRate GibibitsPerSecond(this T value) #endif => BitRate.FromGibibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate GibibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static BitRate GibibytesPerSecond(this T value) #endif => BitRate.FromGibibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate GigabitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static BitRate GigabitsPerSecond(this T value) #endif => BitRate.FromGigabitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate GigabytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static BitRate GigabytesPerSecond(this T value) #endif => BitRate.FromGigabytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate KibibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static BitRate KibibitsPerSecond(this T value) #endif => BitRate.FromKibibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate KibibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static BitRate KibibytesPerSecond(this T value) #endif => BitRate.FromKibibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate KilobitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static BitRate KilobitsPerSecond(this T value) #endif => BitRate.FromKilobitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate KilobytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static BitRate KilobytesPerSecond(this T value) #endif => BitRate.FromKilobytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate MebibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static BitRate MebibitsPerSecond(this T value) #endif => BitRate.FromMebibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate MebibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static BitRate MebibytesPerSecond(this T value) #endif => BitRate.FromMebibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate MegabitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static BitRate MegabitsPerSecond(this T value) #endif => BitRate.FromMegabitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate MegabytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static BitRate MegabytesPerSecond(this T value) #endif => BitRate.FromMegabytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate PebibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static BitRate PebibitsPerSecond(this T value) #endif => BitRate.FromPebibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate PebibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static BitRate PebibytesPerSecond(this T value) #endif => BitRate.FromPebibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate PetabitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static BitRate PetabitsPerSecond(this T value) #endif => BitRate.FromPetabitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate PetabytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static BitRate PetabytesPerSecond(this T value) #endif => BitRate.FromPetabytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate TebibitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static BitRate TebibitsPerSecond(this T value) #endif => BitRate.FromTebibitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate TebibytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static BitRate TebibytesPerSecond(this T value) #endif => BitRate.FromTebibytesPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate TerabitsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static BitRate TerabitsPerSecond(this T value) #endif => BitRate.FromTerabitsPerSecond(Convert.ToDouble(value)); - /// + /// public static BitRate TerabytesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs index bfffa5835f..9182f0775f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToBrakeSpecificFuelConsumption /// public static class NumberToBrakeSpecificFuelConsumptionExtensions { - /// + /// public static BrakeSpecificFuelConsumption GramsPerKiloWattHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static BrakeSpecificFuelConsumption GramsPerKiloWattHour(this T value) #endif => BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(Convert.ToDouble(value)); - /// + /// public static BrakeSpecificFuelConsumption KilogramsPerJoule(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static BrakeSpecificFuelConsumption KilogramsPerJoule(this T value) #endif => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(Convert.ToDouble(value)); - /// + /// public static BrakeSpecificFuelConsumption PoundsPerMechanicalHorsepowerHour(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs index ca11428455..85adc42c19 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToCapacitance /// public static class NumberToCapacitanceExtensions { - /// + /// public static Capacitance Farads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Capacitance Farads(this T value) #endif => Capacitance.FromFarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Kilofarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Capacitance Kilofarads(this T value) #endif => Capacitance.FromKilofarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Megafarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Capacitance Megafarads(this T value) #endif => Capacitance.FromMegafarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Microfarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Capacitance Microfarads(this T value) #endif => Capacitance.FromMicrofarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Millifarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Capacitance Millifarads(this T value) #endif => Capacitance.FromMillifarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Nanofarads(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Capacitance Nanofarads(this T value) #endif => Capacitance.FromNanofarads(Convert.ToDouble(value)); - /// + /// public static Capacitance Picofarads(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs index 22adc70a09..690e2bf0d7 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToCoefficientOfThermalExpansion /// public static class NumberToCoefficientOfThermalExpansionExtensions { - /// + /// public static CoefficientOfThermalExpansion PerDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static CoefficientOfThermalExpansion PerDegreeCelsius(this T value) #endif => CoefficientOfThermalExpansion.FromPerDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static CoefficientOfThermalExpansion PerDegreeFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static CoefficientOfThermalExpansion PerDegreeFahrenheit(this T value) #endif => CoefficientOfThermalExpansion.FromPerDegreeFahrenheit(Convert.ToDouble(value)); - /// + /// public static CoefficientOfThermalExpansion PerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static CoefficientOfThermalExpansion PerKelvin(this T value) #endif => CoefficientOfThermalExpansion.FromPerKelvin(Convert.ToDouble(value)); - /// + /// public static CoefficientOfThermalExpansion PpmPerDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static CoefficientOfThermalExpansion PpmPerDegreeCelsius(this T value) #endif => CoefficientOfThermalExpansion.FromPpmPerDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static CoefficientOfThermalExpansion PpmPerDegreeFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static CoefficientOfThermalExpansion PpmPerDegreeFahrenheit(this T val #endif => CoefficientOfThermalExpansion.FromPpmPerDegreeFahrenheit(Convert.ToDouble(value)); - /// + /// public static CoefficientOfThermalExpansion PpmPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCompressibilityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCompressibilityExtensions.g.cs index f5683c23f3..2f4addddf3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCompressibilityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCompressibilityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToCompressibility /// public static class NumberToCompressibilityExtensions { - /// + /// public static Compressibility InverseAtmospheres(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Compressibility InverseAtmospheres(this T value) #endif => Compressibility.FromInverseAtmospheres(Convert.ToDouble(value)); - /// + /// public static Compressibility InverseBars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Compressibility InverseBars(this T value) #endif => Compressibility.FromInverseBars(Convert.ToDouble(value)); - /// + /// public static Compressibility InverseKilopascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Compressibility InverseKilopascals(this T value) #endif => Compressibility.FromInverseKilopascals(Convert.ToDouble(value)); - /// + /// public static Compressibility InverseMegapascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Compressibility InverseMegapascals(this T value) #endif => Compressibility.FromInverseMegapascals(Convert.ToDouble(value)); - /// + /// public static Compressibility InverseMillibars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Compressibility InverseMillibars(this T value) #endif => Compressibility.FromInverseMillibars(Convert.ToDouble(value)); - /// + /// public static Compressibility InversePascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Compressibility InversePascals(this T value) #endif => Compressibility.FromInversePascals(Convert.ToDouble(value)); - /// + /// public static Compressibility InversePoundsForcePerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs index a10af41796..33fed3e129 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToDensity /// public static class NumberToDensityExtensions { - /// + /// public static Density CentigramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Density CentigramsPerDeciliter(this T value) #endif => Density.FromCentigramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density CentigramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Density CentigramsPerLiter(this T value) #endif => Density.FromCentigramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density CentigramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Density CentigramsPerMilliliter(this T value) #endif => Density.FromCentigramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density DecigramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Density DecigramsPerDeciliter(this T value) #endif => Density.FromDecigramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density DecigramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Density DecigramsPerLiter(this T value) #endif => Density.FromDecigramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density DecigramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Density DecigramsPerMilliliter(this T value) #endif => Density.FromDecigramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density FemtogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Density FemtogramsPerDeciliter(this T value) #endif => Density.FromFemtogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density FemtogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Density FemtogramsPerLiter(this T value) #endif => Density.FromFemtogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density FemtogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Density FemtogramsPerMilliliter(this T value) #endif => Density.FromFemtogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Density GramsPerCubicCentimeter(this T value) #endif => Density.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Density GramsPerCubicFoot(this T value) #endif => Density.FromGramsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static Density GramsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Density GramsPerCubicInch(this T value) #endif => Density.FromGramsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static Density GramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Density GramsPerCubicMeter(this T value) #endif => Density.FromGramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Density GramsPerCubicMillimeter(this T value) #endif => Density.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Density GramsPerDeciliter(this T value) #endif => Density.FromGramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Density GramsPerLiter(this T value) #endif => Density.FromGramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density GramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Density GramsPerMilliliter(this T value) #endif => Density.FromGramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density KilogramsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Density KilogramsPerCubicCentimeter(this T value) #endif => Density.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static Density KilogramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Density KilogramsPerCubicMeter(this T value) #endif => Density.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density KilogramsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Density KilogramsPerCubicMillimeter(this T value) #endif => Density.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static Density KilogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Density KilogramsPerLiter(this T value) #endif => Density.FromKilogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density KilopoundsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Density KilopoundsPerCubicFoot(this T value) #endif => Density.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static Density KilopoundsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Density KilopoundsPerCubicInch(this T value) #endif => Density.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static Density KilopoundsPerCubicYard(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Density KilopoundsPerCubicYard(this T value) #endif => Density.FromKilopoundsPerCubicYard(Convert.ToDouble(value)); - /// + /// public static Density MicrogramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Density MicrogramsPerCubicMeter(this T value) #endif => Density.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density MicrogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Density MicrogramsPerDeciliter(this T value) #endif => Density.FromMicrogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density MicrogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Density MicrogramsPerLiter(this T value) #endif => Density.FromMicrogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density MicrogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Density MicrogramsPerMilliliter(this T value) #endif => Density.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density MilligramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Density MilligramsPerCubicMeter(this T value) #endif => Density.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density MilligramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Density MilligramsPerDeciliter(this T value) #endif => Density.FromMilligramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density MilligramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Density MilligramsPerLiter(this T value) #endif => Density.FromMilligramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density MilligramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Density MilligramsPerMilliliter(this T value) #endif => Density.FromMilligramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density NanogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static Density NanogramsPerDeciliter(this T value) #endif => Density.FromNanogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density NanogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static Density NanogramsPerLiter(this T value) #endif => Density.FromNanogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density NanogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static Density NanogramsPerMilliliter(this T value) #endif => Density.FromNanogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density PicogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static Density PicogramsPerDeciliter(this T value) #endif => Density.FromPicogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static Density PicogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static Density PicogramsPerLiter(this T value) #endif => Density.FromPicogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static Density PicogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static Density PicogramsPerMilliliter(this T value) #endif => Density.FromPicogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static Density PoundsPerCubicCentimeter(this T value) #endif => Density.FromPoundsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static Density PoundsPerCubicFoot(this T value) #endif => Density.FromPoundsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static Density PoundsPerCubicInch(this T value) #endif => Density.FromPoundsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +368,7 @@ public static Density PoundsPerCubicMeter(this T value) #endif => Density.FromPoundsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +376,7 @@ public static Density PoundsPerCubicMillimeter(this T value) #endif => Density.FromPoundsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerCubicYard(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -384,7 +384,7 @@ public static Density PoundsPerCubicYard(this T value) #endif => Density.FromPoundsPerCubicYard(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerImperialGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -392,7 +392,7 @@ public static Density PoundsPerImperialGallon(this T value) #endif => Density.FromPoundsPerImperialGallon(Convert.ToDouble(value)); - /// + /// public static Density PoundsPerUSGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -400,7 +400,7 @@ public static Density PoundsPerUSGallon(this T value) #endif => Density.FromPoundsPerUSGallon(Convert.ToDouble(value)); - /// + /// public static Density SlugsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -408,7 +408,7 @@ public static Density SlugsPerCubicCentimeter(this T value) #endif => Density.FromSlugsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static Density SlugsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -416,7 +416,7 @@ public static Density SlugsPerCubicFoot(this T value) #endif => Density.FromSlugsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static Density SlugsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -424,7 +424,7 @@ public static Density SlugsPerCubicInch(this T value) #endif => Density.FromSlugsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static Density SlugsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -432,7 +432,7 @@ public static Density SlugsPerCubicMeter(this T value) #endif => Density.FromSlugsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density SlugsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -440,7 +440,7 @@ public static Density SlugsPerCubicMillimeter(this T value) #endif => Density.FromSlugsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static Density TonnesPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -448,7 +448,7 @@ public static Density TonnesPerCubicCentimeter(this T value) #endif => Density.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static Density TonnesPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -456,7 +456,7 @@ public static Density TonnesPerCubicFoot(this T value) #endif => Density.FromTonnesPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static Density TonnesPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -464,7 +464,7 @@ public static Density TonnesPerCubicInch(this T value) #endif => Density.FromTonnesPerCubicInch(Convert.ToDouble(value)); - /// + /// public static Density TonnesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -472,7 +472,7 @@ public static Density TonnesPerCubicMeter(this T value) #endif => Density.FromTonnesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Density TonnesPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs index 518f224453..0e4b13b088 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToDuration /// public static class NumberToDurationExtensions { - /// + /// public static Duration Days(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Duration Days(this T value) #endif => Duration.FromDays(Convert.ToDouble(value)); - /// + /// public static Duration Hours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Duration Hours(this T value) #endif => Duration.FromHours(Convert.ToDouble(value)); - /// + /// public static Duration JulianYears(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Duration JulianYears(this T value) #endif => Duration.FromJulianYears(Convert.ToDouble(value)); - /// + /// public static Duration Microseconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Duration Microseconds(this T value) #endif => Duration.FromMicroseconds(Convert.ToDouble(value)); - /// + /// public static Duration Milliseconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Duration Milliseconds(this T value) #endif => Duration.FromMilliseconds(Convert.ToDouble(value)); - /// + /// public static Duration Minutes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Duration Minutes(this T value) #endif => Duration.FromMinutes(Convert.ToDouble(value)); - /// + /// public static Duration Months30(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Duration Months30(this T value) #endif => Duration.FromMonths30(Convert.ToDouble(value)); - /// + /// public static Duration Nanoseconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Duration Nanoseconds(this T value) #endif => Duration.FromNanoseconds(Convert.ToDouble(value)); - /// + /// public static Duration Seconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Duration Seconds(this T value) #endif => Duration.FromSeconds(Convert.ToDouble(value)); - /// + /// public static Duration Weeks(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Duration Weeks(this T value) #endif => Duration.FromWeeks(Convert.ToDouble(value)); - /// + /// public static Duration Years365(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs index 59c792b747..861203e8ad 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToDynamicViscosity /// public static class NumberToDynamicViscosityExtensions { - /// + /// public static DynamicViscosity Centipoise(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static DynamicViscosity Centipoise(this T value) #endif => DynamicViscosity.FromCentipoise(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity MicropascalSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static DynamicViscosity MicropascalSeconds(this T value) #endif => DynamicViscosity.FromMicropascalSeconds(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity MillipascalSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static DynamicViscosity MillipascalSeconds(this T value) #endif => DynamicViscosity.FromMillipascalSeconds(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity NewtonSecondsPerMeterSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static DynamicViscosity NewtonSecondsPerMeterSquared(this T value) #endif => DynamicViscosity.FromNewtonSecondsPerMeterSquared(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity PascalSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static DynamicViscosity PascalSeconds(this T value) #endif => DynamicViscosity.FromPascalSeconds(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity Poise(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static DynamicViscosity Poise(this T value) #endif => DynamicViscosity.FromPoise(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity PoundsForceSecondPerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static DynamicViscosity PoundsForceSecondPerSquareFoot(this T value) #endif => DynamicViscosity.FromPoundsForceSecondPerSquareFoot(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity PoundsForceSecondPerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static DynamicViscosity PoundsForceSecondPerSquareInch(this T value) #endif => DynamicViscosity.FromPoundsForceSecondPerSquareInch(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity PoundsPerFootSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static DynamicViscosity PoundsPerFootSecond(this T value) #endif => DynamicViscosity.FromPoundsPerFootSecond(Convert.ToDouble(value)); - /// + /// public static DynamicViscosity Reyns(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs index b02da0f9f6..841a6ff6b6 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricAdmittance /// public static class NumberToElectricAdmittanceExtensions { - /// + /// public static ElectricAdmittance Microsiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricAdmittance Microsiemens(this T value) #endif => ElectricAdmittance.FromMicrosiemens(Convert.ToDouble(value)); - /// + /// public static ElectricAdmittance Millisiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricAdmittance Millisiemens(this T value) #endif => ElectricAdmittance.FromMillisiemens(Convert.ToDouble(value)); - /// + /// public static ElectricAdmittance Nanosiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricAdmittance Nanosiemens(this T value) #endif => ElectricAdmittance.FromNanosiemens(Convert.ToDouble(value)); - /// + /// public static ElectricAdmittance Siemens(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs index 640d805651..4bbd788d07 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricChargeDensity /// public static class NumberToElectricChargeDensityExtensions { - /// + /// public static ElectricChargeDensity CoulombsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs index 422aa5f121..3a1d241727 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCharge /// public static class NumberToElectricChargeExtensions { - /// + /// public static ElectricCharge AmpereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricCharge AmpereHours(this T value) #endif => ElectricCharge.FromAmpereHours(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Coulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricCharge Coulombs(this T value) #endif => ElectricCharge.FromCoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge KiloampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricCharge KiloampereHours(this T value) #endif => ElectricCharge.FromKiloampereHours(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Kilocoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricCharge Kilocoulombs(this T value) #endif => ElectricCharge.FromKilocoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge MegaampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricCharge MegaampereHours(this T value) #endif => ElectricCharge.FromMegaampereHours(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Megacoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricCharge Megacoulombs(this T value) #endif => ElectricCharge.FromMegacoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Microcoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ElectricCharge Microcoulombs(this T value) #endif => ElectricCharge.FromMicrocoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge MilliampereHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ElectricCharge MilliampereHours(this T value) #endif => ElectricCharge.FromMilliampereHours(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Millicoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ElectricCharge Millicoulombs(this T value) #endif => ElectricCharge.FromMillicoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Nanocoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ElectricCharge Nanocoulombs(this T value) #endif => ElectricCharge.FromNanocoulombs(Convert.ToDouble(value)); - /// + /// public static ElectricCharge Picocoulombs(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs index d656b7462b..8b0bde0de0 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricConductance /// public static class NumberToElectricConductanceExtensions { - /// + /// public static ElectricConductance Kilosiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricConductance Kilosiemens(this T value) #endif => ElectricConductance.FromKilosiemens(Convert.ToDouble(value)); - /// + /// public static ElectricConductance Microsiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricConductance Microsiemens(this T value) #endif => ElectricConductance.FromMicrosiemens(Convert.ToDouble(value)); - /// + /// public static ElectricConductance Millisiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricConductance Millisiemens(this T value) #endif => ElectricConductance.FromMillisiemens(Convert.ToDouble(value)); - /// + /// public static ElectricConductance Nanosiemens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricConductance Nanosiemens(this T value) #endif => ElectricConductance.FromNanosiemens(Convert.ToDouble(value)); - /// + /// public static ElectricConductance Siemens(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs index d5a791c5c9..1c4b08f3bb 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricConductivity /// public static class NumberToElectricConductivityExtensions { - /// + /// public static ElectricConductivity MicrosiemensPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricConductivity MicrosiemensPerCentimeter(this T value) #endif => ElectricConductivity.FromMicrosiemensPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricConductivity MillisiemensPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricConductivity MillisiemensPerCentimeter(this T value) #endif => ElectricConductivity.FromMillisiemensPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricConductivity SiemensPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricConductivity SiemensPerCentimeter(this T value) #endif => ElectricConductivity.FromSiemensPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricConductivity SiemensPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricConductivity SiemensPerFoot(this T value) #endif => ElectricConductivity.FromSiemensPerFoot(Convert.ToDouble(value)); - /// + /// public static ElectricConductivity SiemensPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricConductivity SiemensPerInch(this T value) #endif => ElectricConductivity.FromSiemensPerInch(Convert.ToDouble(value)); - /// + /// public static ElectricConductivity SiemensPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs index 58d52df54b..487d3fe779 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrentDensity /// public static class NumberToElectricCurrentDensityExtensions { - /// + /// public static ElectricCurrentDensity AmperesPerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricCurrentDensity AmperesPerSquareFoot(this T value) #endif => ElectricCurrentDensity.FromAmperesPerSquareFoot(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentDensity AmperesPerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricCurrentDensity AmperesPerSquareInch(this T value) #endif => ElectricCurrentDensity.FromAmperesPerSquareInch(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentDensity AmperesPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs index 42816bffd1..cc581473cd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrent /// public static class NumberToElectricCurrentExtensions { - /// + /// public static ElectricCurrent Amperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricCurrent Amperes(this T value) #endif => ElectricCurrent.FromAmperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Centiamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricCurrent Centiamperes(this T value) #endif => ElectricCurrent.FromCentiamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Femtoamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricCurrent Femtoamperes(this T value) #endif => ElectricCurrent.FromFemtoamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Kiloamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricCurrent Kiloamperes(this T value) #endif => ElectricCurrent.FromKiloamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Megaamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricCurrent Megaamperes(this T value) #endif => ElectricCurrent.FromMegaamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Microamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricCurrent Microamperes(this T value) #endif => ElectricCurrent.FromMicroamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Milliamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ElectricCurrent Milliamperes(this T value) #endif => ElectricCurrent.FromMilliamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Nanoamperes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ElectricCurrent Nanoamperes(this T value) #endif => ElectricCurrent.FromNanoamperes(Convert.ToDouble(value)); - /// + /// public static ElectricCurrent Picoamperes(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs index 898b7c41e0..96f939d1df 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrentGradient /// public static class NumberToElectricCurrentGradientExtensions { - /// + /// public static ElectricCurrentGradient AmperesPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricCurrentGradient AmperesPerMicrosecond(this T value) #endif => ElectricCurrentGradient.FromAmperesPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient AmperesPerMillisecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricCurrentGradient AmperesPerMillisecond(this T value) #endif => ElectricCurrentGradient.FromAmperesPerMillisecond(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient AmperesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricCurrentGradient AmperesPerMinute(this T value) #endif => ElectricCurrentGradient.FromAmperesPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient AmperesPerNanosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricCurrentGradient AmperesPerNanosecond(this T value) #endif => ElectricCurrentGradient.FromAmperesPerNanosecond(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient AmperesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricCurrentGradient AmperesPerSecond(this T value) #endif => ElectricCurrentGradient.FromAmperesPerSecond(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient MilliamperesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricCurrentGradient MilliamperesPerMinute(this T value) #endif => ElectricCurrentGradient.FromMilliamperesPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricCurrentGradient MilliamperesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs index bb9a391be8..59f0e4700b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricField /// public static class NumberToElectricFieldExtensions { - /// + /// public static ElectricField VoltsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs index 07aedbcbb2..d84376dc13 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricInductance /// public static class NumberToElectricInductanceExtensions { - /// + /// public static ElectricInductance Henries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricInductance Henries(this T value) #endif => ElectricInductance.FromHenries(Convert.ToDouble(value)); - /// + /// public static ElectricInductance Microhenries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricInductance Microhenries(this T value) #endif => ElectricInductance.FromMicrohenries(Convert.ToDouble(value)); - /// + /// public static ElectricInductance Millihenries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricInductance Millihenries(this T value) #endif => ElectricInductance.FromMillihenries(Convert.ToDouble(value)); - /// + /// public static ElectricInductance Nanohenries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricInductance Nanohenries(this T value) #endif => ElectricInductance.FromNanohenries(Convert.ToDouble(value)); - /// + /// public static ElectricInductance Picohenries(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs index cb96006b46..4281aa753c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialAc /// public static class NumberToElectricPotentialAcExtensions { - /// + /// public static ElectricPotentialAc KilovoltsAc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricPotentialAc KilovoltsAc(this T value) #endif => ElectricPotentialAc.FromKilovoltsAc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialAc MegavoltsAc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricPotentialAc MegavoltsAc(this T value) #endif => ElectricPotentialAc.FromMegavoltsAc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialAc MicrovoltsAc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricPotentialAc MicrovoltsAc(this T value) #endif => ElectricPotentialAc.FromMicrovoltsAc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialAc MillivoltsAc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricPotentialAc MillivoltsAc(this T value) #endif => ElectricPotentialAc.FromMillivoltsAc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialAc VoltsAc(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs index 3381b64770..6609bbcd0d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialChangeRate /// public static class NumberToElectricPotentialChangeRateExtensions { - /// + /// public static ElectricPotentialChangeRate KilovoltsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricPotentialChangeRate KilovoltsPerHour(this T value) #endif => ElectricPotentialChangeRate.FromKilovoltsPerHour(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate KilovoltsPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricPotentialChangeRate KilovoltsPerMicrosecond(this T valu #endif => ElectricPotentialChangeRate.FromKilovoltsPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate KilovoltsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricPotentialChangeRate KilovoltsPerMinute(this T value) #endif => ElectricPotentialChangeRate.FromKilovoltsPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate KilovoltsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricPotentialChangeRate KilovoltsPerSecond(this T value) #endif => ElectricPotentialChangeRate.FromKilovoltsPerSecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MegavoltsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricPotentialChangeRate MegavoltsPerHour(this T value) #endif => ElectricPotentialChangeRate.FromMegavoltsPerHour(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MegavoltsPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricPotentialChangeRate MegavoltsPerMicrosecond(this T valu #endif => ElectricPotentialChangeRate.FromMegavoltsPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MegavoltsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ElectricPotentialChangeRate MegavoltsPerMinute(this T value) #endif => ElectricPotentialChangeRate.FromMegavoltsPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MegavoltsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ElectricPotentialChangeRate MegavoltsPerSecond(this T value) #endif => ElectricPotentialChangeRate.FromMegavoltsPerSecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MicrovoltsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ElectricPotentialChangeRate MicrovoltsPerHour(this T value) #endif => ElectricPotentialChangeRate.FromMicrovoltsPerHour(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MicrovoltsPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ElectricPotentialChangeRate MicrovoltsPerMicrosecond(this T val #endif => ElectricPotentialChangeRate.FromMicrovoltsPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MicrovoltsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static ElectricPotentialChangeRate MicrovoltsPerMinute(this T value) #endif => ElectricPotentialChangeRate.FromMicrovoltsPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MicrovoltsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static ElectricPotentialChangeRate MicrovoltsPerSecond(this T value) #endif => ElectricPotentialChangeRate.FromMicrovoltsPerSecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MillivoltsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static ElectricPotentialChangeRate MillivoltsPerHour(this T value) #endif => ElectricPotentialChangeRate.FromMillivoltsPerHour(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MillivoltsPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static ElectricPotentialChangeRate MillivoltsPerMicrosecond(this T val #endif => ElectricPotentialChangeRate.FromMillivoltsPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MillivoltsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static ElectricPotentialChangeRate MillivoltsPerMinute(this T value) #endif => ElectricPotentialChangeRate.FromMillivoltsPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate MillivoltsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static ElectricPotentialChangeRate MillivoltsPerSecond(this T value) #endif => ElectricPotentialChangeRate.FromMillivoltsPerSecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate VoltsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static ElectricPotentialChangeRate VoltsPerHour(this T value) #endif => ElectricPotentialChangeRate.FromVoltsPerHour(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate VoltsPerMicrosecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static ElectricPotentialChangeRate VoltsPerMicrosecond(this T value) #endif => ElectricPotentialChangeRate.FromVoltsPerMicrosecond(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate VoltsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static ElectricPotentialChangeRate VoltsPerMinute(this T value) #endif => ElectricPotentialChangeRate.FromVoltsPerMinute(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialChangeRate VoltsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs index a8614fd5db..9a07369c4e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialDc /// public static class NumberToElectricPotentialDcExtensions { - /// + /// public static ElectricPotentialDc KilovoltsDc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricPotentialDc KilovoltsDc(this T value) #endif => ElectricPotentialDc.FromKilovoltsDc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialDc MegavoltsDc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricPotentialDc MegavoltsDc(this T value) #endif => ElectricPotentialDc.FromMegavoltsDc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialDc MicrovoltsDc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricPotentialDc MicrovoltsDc(this T value) #endif => ElectricPotentialDc.FromMicrovoltsDc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialDc MillivoltsDc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricPotentialDc MillivoltsDc(this T value) #endif => ElectricPotentialDc.FromMillivoltsDc(Convert.ToDouble(value)); - /// + /// public static ElectricPotentialDc VoltsDc(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs index c89a5069a6..c09579d06c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotential /// public static class NumberToElectricPotentialExtensions { - /// + /// public static ElectricPotential Kilovolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricPotential Kilovolts(this T value) #endif => ElectricPotential.FromKilovolts(Convert.ToDouble(value)); - /// + /// public static ElectricPotential Megavolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricPotential Megavolts(this T value) #endif => ElectricPotential.FromMegavolts(Convert.ToDouble(value)); - /// + /// public static ElectricPotential Microvolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricPotential Microvolts(this T value) #endif => ElectricPotential.FromMicrovolts(Convert.ToDouble(value)); - /// + /// public static ElectricPotential Millivolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricPotential Millivolts(this T value) #endif => ElectricPotential.FromMillivolts(Convert.ToDouble(value)); - /// + /// public static ElectricPotential Nanovolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricPotential Nanovolts(this T value) #endif => ElectricPotential.FromNanovolts(Convert.ToDouble(value)); - /// + /// public static ElectricPotential Volts(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs index 99e17110cf..880649ac27 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricResistance /// public static class NumberToElectricResistanceExtensions { - /// + /// public static ElectricResistance Gigaohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricResistance Gigaohms(this T value) #endif => ElectricResistance.FromGigaohms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Kiloohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricResistance Kiloohms(this T value) #endif => ElectricResistance.FromKiloohms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Megaohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricResistance Megaohms(this T value) #endif => ElectricResistance.FromMegaohms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Microohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricResistance Microohms(this T value) #endif => ElectricResistance.FromMicroohms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Milliohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricResistance Milliohms(this T value) #endif => ElectricResistance.FromMilliohms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Ohms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricResistance Ohms(this T value) #endif => ElectricResistance.FromOhms(Convert.ToDouble(value)); - /// + /// public static ElectricResistance Teraohms(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs index 4beb953b18..5548bac92b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricResistivity /// public static class NumberToElectricResistivityExtensions { - /// + /// public static ElectricResistivity KiloohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricResistivity KiloohmsCentimeter(this T value) #endif => ElectricResistivity.FromKiloohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity KiloohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricResistivity KiloohmMeters(this T value) #endif => ElectricResistivity.FromKiloohmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MegaohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ElectricResistivity MegaohmsCentimeter(this T value) #endif => ElectricResistivity.FromMegaohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MegaohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ElectricResistivity MegaohmMeters(this T value) #endif => ElectricResistivity.FromMegaohmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MicroohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ElectricResistivity MicroohmsCentimeter(this T value) #endif => ElectricResistivity.FromMicroohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MicroohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ElectricResistivity MicroohmMeters(this T value) #endif => ElectricResistivity.FromMicroohmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MilliohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ElectricResistivity MilliohmsCentimeter(this T value) #endif => ElectricResistivity.FromMilliohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity MilliohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ElectricResistivity MilliohmMeters(this T value) #endif => ElectricResistivity.FromMilliohmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity NanoohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ElectricResistivity NanoohmsCentimeter(this T value) #endif => ElectricResistivity.FromNanoohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity NanoohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ElectricResistivity NanoohmMeters(this T value) #endif => ElectricResistivity.FromNanoohmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity OhmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static ElectricResistivity OhmsCentimeter(this T value) #endif => ElectricResistivity.FromOhmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity OhmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static ElectricResistivity OhmMeters(this T value) #endif => ElectricResistivity.FromOhmMeters(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity PicoohmsCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static ElectricResistivity PicoohmsCentimeter(this T value) #endif => ElectricResistivity.FromPicoohmsCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricResistivity PicoohmMeters(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs index 4324398c42..4562c7d02e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToElectricSurfaceChargeDensity /// public static class NumberToElectricSurfaceChargeDensityExtensions { - /// + /// public static ElectricSurfaceChargeDensity CoulombsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ElectricSurfaceChargeDensity CoulombsPerSquareCentimeter(this T #endif => ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static ElectricSurfaceChargeDensity CoulombsPerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ElectricSurfaceChargeDensity CoulombsPerSquareInch(this T value #endif => ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(Convert.ToDouble(value)); - /// + /// public static ElectricSurfaceChargeDensity CoulombsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyDensityExtensions.g.cs index 6cc51eeee6..a576dbc12d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToEnergyDensity /// public static class NumberToEnergyDensityExtensions { - /// + /// public static EnergyDensity GigajoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static EnergyDensity GigajoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromGigajoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity GigawattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static EnergyDensity GigawattHoursPerCubicMeter(this T value) #endif => EnergyDensity.FromGigawattHoursPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity JoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static EnergyDensity JoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromJoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity KilojoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static EnergyDensity KilojoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromKilojoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity KilowattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static EnergyDensity KilowattHoursPerCubicMeter(this T value) #endif => EnergyDensity.FromKilowattHoursPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity MegajoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static EnergyDensity MegajoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromMegajoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity MegawattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static EnergyDensity MegawattHoursPerCubicMeter(this T value) #endif => EnergyDensity.FromMegawattHoursPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity PetajoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static EnergyDensity PetajoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromPetajoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity PetawattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static EnergyDensity PetawattHoursPerCubicMeter(this T value) #endif => EnergyDensity.FromPetawattHoursPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity TerajoulesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static EnergyDensity TerajoulesPerCubicMeter(this T value) #endif => EnergyDensity.FromTerajoulesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity TerawattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static EnergyDensity TerawattHoursPerCubicMeter(this T value) #endif => EnergyDensity.FromTerawattHoursPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static EnergyDensity WattHoursPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs index e07186fad8..6f85aa0942 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToEnergy /// public static class NumberToEnergyExtensions { - /// + /// public static Energy BritishThermalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Energy BritishThermalUnits(this T value) #endif => Energy.FromBritishThermalUnits(Convert.ToDouble(value)); - /// + /// public static Energy Calories(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Energy Calories(this T value) #endif => Energy.FromCalories(Convert.ToDouble(value)); - /// + /// public static Energy DecathermsEc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Energy DecathermsEc(this T value) #endif => Energy.FromDecathermsEc(Convert.ToDouble(value)); - /// + /// public static Energy DecathermsImperial(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Energy DecathermsImperial(this T value) #endif => Energy.FromDecathermsImperial(Convert.ToDouble(value)); - /// + /// public static Energy DecathermsUs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Energy DecathermsUs(this T value) #endif => Energy.FromDecathermsUs(Convert.ToDouble(value)); - /// + /// public static Energy ElectronVolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Energy ElectronVolts(this T value) #endif => Energy.FromElectronVolts(Convert.ToDouble(value)); - /// + /// public static Energy Ergs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Energy Ergs(this T value) #endif => Energy.FromErgs(Convert.ToDouble(value)); - /// + /// public static Energy FootPounds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Energy FootPounds(this T value) #endif => Energy.FromFootPounds(Convert.ToDouble(value)); - /// + /// public static Energy GigabritishThermalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Energy GigabritishThermalUnits(this T value) #endif => Energy.FromGigabritishThermalUnits(Convert.ToDouble(value)); - /// + /// public static Energy GigaelectronVolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Energy GigaelectronVolts(this T value) #endif => Energy.FromGigaelectronVolts(Convert.ToDouble(value)); - /// + /// public static Energy Gigajoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Energy Gigajoules(this T value) #endif => Energy.FromGigajoules(Convert.ToDouble(value)); - /// + /// public static Energy GigawattDays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Energy GigawattDays(this T value) #endif => Energy.FromGigawattDays(Convert.ToDouble(value)); - /// + /// public static Energy GigawattHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Energy GigawattHours(this T value) #endif => Energy.FromGigawattHours(Convert.ToDouble(value)); - /// + /// public static Energy HorsepowerHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Energy HorsepowerHours(this T value) #endif => Energy.FromHorsepowerHours(Convert.ToDouble(value)); - /// + /// public static Energy Joules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Energy Joules(this T value) #endif => Energy.FromJoules(Convert.ToDouble(value)); - /// + /// public static Energy KilobritishThermalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Energy KilobritishThermalUnits(this T value) #endif => Energy.FromKilobritishThermalUnits(Convert.ToDouble(value)); - /// + /// public static Energy Kilocalories(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Energy Kilocalories(this T value) #endif => Energy.FromKilocalories(Convert.ToDouble(value)); - /// + /// public static Energy KiloelectronVolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Energy KiloelectronVolts(this T value) #endif => Energy.FromKiloelectronVolts(Convert.ToDouble(value)); - /// + /// public static Energy Kilojoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Energy Kilojoules(this T value) #endif => Energy.FromKilojoules(Convert.ToDouble(value)); - /// + /// public static Energy KilowattDays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Energy KilowattDays(this T value) #endif => Energy.FromKilowattDays(Convert.ToDouble(value)); - /// + /// public static Energy KilowattHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Energy KilowattHours(this T value) #endif => Energy.FromKilowattHours(Convert.ToDouble(value)); - /// + /// public static Energy MegabritishThermalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Energy MegabritishThermalUnits(this T value) #endif => Energy.FromMegabritishThermalUnits(Convert.ToDouble(value)); - /// + /// public static Energy Megacalories(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Energy Megacalories(this T value) #endif => Energy.FromMegacalories(Convert.ToDouble(value)); - /// + /// public static Energy MegaelectronVolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Energy MegaelectronVolts(this T value) #endif => Energy.FromMegaelectronVolts(Convert.ToDouble(value)); - /// + /// public static Energy Megajoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Energy Megajoules(this T value) #endif => Energy.FromMegajoules(Convert.ToDouble(value)); - /// + /// public static Energy MegawattDays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Energy MegawattDays(this T value) #endif => Energy.FromMegawattDays(Convert.ToDouble(value)); - /// + /// public static Energy MegawattHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Energy MegawattHours(this T value) #endif => Energy.FromMegawattHours(Convert.ToDouble(value)); - /// + /// public static Energy Microjoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Energy Microjoules(this T value) #endif => Energy.FromMicrojoules(Convert.ToDouble(value)); - /// + /// public static Energy Millijoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Energy Millijoules(this T value) #endif => Energy.FromMillijoules(Convert.ToDouble(value)); - /// + /// public static Energy Nanojoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Energy Nanojoules(this T value) #endif => Energy.FromNanojoules(Convert.ToDouble(value)); - /// + /// public static Energy Petajoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Energy Petajoules(this T value) #endif => Energy.FromPetajoules(Convert.ToDouble(value)); - /// + /// public static Energy TeraelectronVolts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Energy TeraelectronVolts(this T value) #endif => Energy.FromTeraelectronVolts(Convert.ToDouble(value)); - /// + /// public static Energy Terajoules(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static Energy Terajoules(this T value) #endif => Energy.FromTerajoules(Convert.ToDouble(value)); - /// + /// public static Energy TerawattDays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static Energy TerawattDays(this T value) #endif => Energy.FromTerawattDays(Convert.ToDouble(value)); - /// + /// public static Energy TerawattHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static Energy TerawattHours(this T value) #endif => Energy.FromTerawattHours(Convert.ToDouble(value)); - /// + /// public static Energy ThermsEc(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static Energy ThermsEc(this T value) #endif => Energy.FromThermsEc(Convert.ToDouble(value)); - /// + /// public static Energy ThermsImperial(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static Energy ThermsImperial(this T value) #endif => Energy.FromThermsImperial(Convert.ToDouble(value)); - /// + /// public static Energy ThermsUs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static Energy ThermsUs(this T value) #endif => Energy.FromThermsUs(Convert.ToDouble(value)); - /// + /// public static Energy WattDays(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static Energy WattDays(this T value) #endif => Energy.FromWattDays(Convert.ToDouble(value)); - /// + /// public static Energy WattHours(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs index a0ccaf7096..4ec74e3e35 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToEntropy /// public static class NumberToEntropyExtensions { - /// + /// public static Entropy CaloriesPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Entropy CaloriesPerKelvin(this T value) #endif => Entropy.FromCaloriesPerKelvin(Convert.ToDouble(value)); - /// + /// public static Entropy JoulesPerDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Entropy JoulesPerDegreeCelsius(this T value) #endif => Entropy.FromJoulesPerDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static Entropy JoulesPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Entropy JoulesPerKelvin(this T value) #endif => Entropy.FromJoulesPerKelvin(Convert.ToDouble(value)); - /// + /// public static Entropy KilocaloriesPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Entropy KilocaloriesPerKelvin(this T value) #endif => Entropy.FromKilocaloriesPerKelvin(Convert.ToDouble(value)); - /// + /// public static Entropy KilojoulesPerDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Entropy KilojoulesPerDegreeCelsius(this T value) #endif => Entropy.FromKilojoulesPerDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static Entropy KilojoulesPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Entropy KilojoulesPerKelvin(this T value) #endif => Entropy.FromKilojoulesPerKelvin(Convert.ToDouble(value)); - /// + /// public static Entropy MegajoulesPerKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs index 1466c67707..ecddbda96e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToForceChangeRate /// public static class NumberToForceChangeRateExtensions { - /// + /// public static ForceChangeRate CentinewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ForceChangeRate CentinewtonsPerSecond(this T value) #endif => ForceChangeRate.FromCentinewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate DecanewtonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ForceChangeRate DecanewtonsPerMinute(this T value) #endif => ForceChangeRate.FromDecanewtonsPerMinute(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate DecanewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ForceChangeRate DecanewtonsPerSecond(this T value) #endif => ForceChangeRate.FromDecanewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate DecinewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ForceChangeRate DecinewtonsPerSecond(this T value) #endif => ForceChangeRate.FromDecinewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate KilonewtonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ForceChangeRate KilonewtonsPerMinute(this T value) #endif => ForceChangeRate.FromKilonewtonsPerMinute(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate KilonewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ForceChangeRate KilonewtonsPerSecond(this T value) #endif => ForceChangeRate.FromKilonewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate KilopoundsForcePerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ForceChangeRate KilopoundsForcePerMinute(this T value) #endif => ForceChangeRate.FromKilopoundsForcePerMinute(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate KilopoundsForcePerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ForceChangeRate KilopoundsForcePerSecond(this T value) #endif => ForceChangeRate.FromKilopoundsForcePerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate MicronewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ForceChangeRate MicronewtonsPerSecond(this T value) #endif => ForceChangeRate.FromMicronewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate MillinewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ForceChangeRate MillinewtonsPerSecond(this T value) #endif => ForceChangeRate.FromMillinewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate NanonewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static ForceChangeRate NanonewtonsPerSecond(this T value) #endif => ForceChangeRate.FromNanonewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate NewtonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static ForceChangeRate NewtonsPerMinute(this T value) #endif => ForceChangeRate.FromNewtonsPerMinute(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate NewtonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static ForceChangeRate NewtonsPerSecond(this T value) #endif => ForceChangeRate.FromNewtonsPerSecond(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate PoundsForcePerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static ForceChangeRate PoundsForcePerMinute(this T value) #endif => ForceChangeRate.FromPoundsForcePerMinute(Convert.ToDouble(value)); - /// + /// public static ForceChangeRate PoundsForcePerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs index 85f4b75944..5c1c4047a5 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToForce /// public static class NumberToForceExtensions { - /// + /// public static Force Decanewtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Force Decanewtons(this T value) #endif => Force.FromDecanewtons(Convert.ToDouble(value)); - /// + /// public static Force Dyne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Force Dyne(this T value) #endif => Force.FromDyne(Convert.ToDouble(value)); - /// + /// public static Force KilogramsForce(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Force KilogramsForce(this T value) #endif => Force.FromKilogramsForce(Convert.ToDouble(value)); - /// + /// public static Force Kilonewtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Force Kilonewtons(this T value) #endif => Force.FromKilonewtons(Convert.ToDouble(value)); - /// + /// public static Force KiloPonds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Force KiloPonds(this T value) #endif => Force.FromKiloPonds(Convert.ToDouble(value)); - /// + /// public static Force KilopoundsForce(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Force KilopoundsForce(this T value) #endif => Force.FromKilopoundsForce(Convert.ToDouble(value)); - /// + /// public static Force Meganewtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Force Meganewtons(this T value) #endif => Force.FromMeganewtons(Convert.ToDouble(value)); - /// + /// public static Force Micronewtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Force Micronewtons(this T value) #endif => Force.FromMicronewtons(Convert.ToDouble(value)); - /// + /// public static Force Millinewtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Force Millinewtons(this T value) #endif => Force.FromMillinewtons(Convert.ToDouble(value)); - /// + /// public static Force Newtons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Force Newtons(this T value) #endif => Force.FromNewtons(Convert.ToDouble(value)); - /// + /// public static Force OunceForce(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Force OunceForce(this T value) #endif => Force.FromOunceForce(Convert.ToDouble(value)); - /// + /// public static Force Poundals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Force Poundals(this T value) #endif => Force.FromPoundals(Convert.ToDouble(value)); - /// + /// public static Force PoundsForce(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Force PoundsForce(this T value) #endif => Force.FromPoundsForce(Convert.ToDouble(value)); - /// + /// public static Force ShortTonsForce(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Force ShortTonsForce(this T value) #endif => Force.FromShortTonsForce(Convert.ToDouble(value)); - /// + /// public static Force TonnesForce(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs index d506a693a6..aa7262c31b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToForcePerLength /// public static class NumberToForcePerLengthExtensions { - /// + /// public static ForcePerLength CentinewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ForcePerLength CentinewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromCentinewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength CentinewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ForcePerLength CentinewtonsPerMeter(this T value) #endif => ForcePerLength.FromCentinewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength CentinewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ForcePerLength CentinewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromCentinewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecanewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ForcePerLength DecanewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromDecanewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecanewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ForcePerLength DecanewtonsPerMeter(this T value) #endif => ForcePerLength.FromDecanewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecanewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ForcePerLength DecanewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromDecanewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecinewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ForcePerLength DecinewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromDecinewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecinewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ForcePerLength DecinewtonsPerMeter(this T value) #endif => ForcePerLength.FromDecinewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength DecinewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ForcePerLength DecinewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromDecinewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilogramsForcePerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ForcePerLength KilogramsForcePerCentimeter(this T value) #endif => ForcePerLength.FromKilogramsForcePerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilogramsForcePerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static ForcePerLength KilogramsForcePerMeter(this T value) #endif => ForcePerLength.FromKilogramsForcePerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilogramsForcePerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static ForcePerLength KilogramsForcePerMillimeter(this T value) #endif => ForcePerLength.FromKilogramsForcePerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilonewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static ForcePerLength KilonewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromKilonewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilonewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static ForcePerLength KilonewtonsPerMeter(this T value) #endif => ForcePerLength.FromKilonewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilonewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static ForcePerLength KilonewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromKilonewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilopoundsForcePerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static ForcePerLength KilopoundsForcePerFoot(this T value) #endif => ForcePerLength.FromKilopoundsForcePerFoot(Convert.ToDouble(value)); - /// + /// public static ForcePerLength KilopoundsForcePerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static ForcePerLength KilopoundsForcePerInch(this T value) #endif => ForcePerLength.FromKilopoundsForcePerInch(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MeganewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static ForcePerLength MeganewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromMeganewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MeganewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static ForcePerLength MeganewtonsPerMeter(this T value) #endif => ForcePerLength.FromMeganewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MeganewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static ForcePerLength MeganewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromMeganewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MicronewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static ForcePerLength MicronewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromMicronewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MicronewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static ForcePerLength MicronewtonsPerMeter(this T value) #endif => ForcePerLength.FromMicronewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MicronewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static ForcePerLength MicronewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromMicronewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MillinewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static ForcePerLength MillinewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromMillinewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MillinewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static ForcePerLength MillinewtonsPerMeter(this T value) #endif => ForcePerLength.FromMillinewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength MillinewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static ForcePerLength MillinewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromMillinewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NanonewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static ForcePerLength NanonewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromNanonewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NanonewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static ForcePerLength NanonewtonsPerMeter(this T value) #endif => ForcePerLength.FromNanonewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NanonewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static ForcePerLength NanonewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromNanonewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NewtonsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static ForcePerLength NewtonsPerCentimeter(this T value) #endif => ForcePerLength.FromNewtonsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NewtonsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static ForcePerLength NewtonsPerMeter(this T value) #endif => ForcePerLength.FromNewtonsPerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength NewtonsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static ForcePerLength NewtonsPerMillimeter(this T value) #endif => ForcePerLength.FromNewtonsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength PoundsForcePerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static ForcePerLength PoundsForcePerFoot(this T value) #endif => ForcePerLength.FromPoundsForcePerFoot(Convert.ToDouble(value)); - /// + /// public static ForcePerLength PoundsForcePerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static ForcePerLength PoundsForcePerInch(this T value) #endif => ForcePerLength.FromPoundsForcePerInch(Convert.ToDouble(value)); - /// + /// public static ForcePerLength PoundsForcePerYard(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static ForcePerLength PoundsForcePerYard(this T value) #endif => ForcePerLength.FromPoundsForcePerYard(Convert.ToDouble(value)); - /// + /// public static ForcePerLength TonnesForcePerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static ForcePerLength TonnesForcePerCentimeter(this T value) #endif => ForcePerLength.FromTonnesForcePerCentimeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength TonnesForcePerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static ForcePerLength TonnesForcePerMeter(this T value) #endif => ForcePerLength.FromTonnesForcePerMeter(Convert.ToDouble(value)); - /// + /// public static ForcePerLength TonnesForcePerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs index 3839b85f8b..b6ef94f1ff 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToFrequency /// public static class NumberToFrequencyExtensions { - /// + /// public static Frequency BeatsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Frequency BeatsPerMinute(this T value) #endif => Frequency.FromBeatsPerMinute(Convert.ToDouble(value)); - /// + /// public static Frequency BUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Frequency BUnits(this T value) #endif => Frequency.FromBUnits(Convert.ToDouble(value)); - /// + /// public static Frequency CyclesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Frequency CyclesPerHour(this T value) #endif => Frequency.FromCyclesPerHour(Convert.ToDouble(value)); - /// + /// public static Frequency CyclesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Frequency CyclesPerMinute(this T value) #endif => Frequency.FromCyclesPerMinute(Convert.ToDouble(value)); - /// + /// public static Frequency Gigahertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Frequency Gigahertz(this T value) #endif => Frequency.FromGigahertz(Convert.ToDouble(value)); - /// + /// public static Frequency Hertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Frequency Hertz(this T value) #endif => Frequency.FromHertz(Convert.ToDouble(value)); - /// + /// public static Frequency Kilohertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Frequency Kilohertz(this T value) #endif => Frequency.FromKilohertz(Convert.ToDouble(value)); - /// + /// public static Frequency Megahertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Frequency Megahertz(this T value) #endif => Frequency.FromMegahertz(Convert.ToDouble(value)); - /// + /// public static Frequency Microhertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Frequency Microhertz(this T value) #endif => Frequency.FromMicrohertz(Convert.ToDouble(value)); - /// + /// public static Frequency Millihertz(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Frequency Millihertz(this T value) #endif => Frequency.FromMillihertz(Convert.ToDouble(value)); - /// + /// public static Frequency PerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Frequency PerSecond(this T value) #endif => Frequency.FromPerSecond(Convert.ToDouble(value)); - /// + /// public static Frequency RadiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Frequency RadiansPerSecond(this T value) #endif => Frequency.FromRadiansPerSecond(Convert.ToDouble(value)); - /// + /// public static Frequency Terahertz(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs index c2db1d3139..c1998a9d9c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToFuelEfficiency /// public static class NumberToFuelEfficiencyExtensions { - /// + /// public static FuelEfficiency KilometersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static FuelEfficiency KilometersPerLiter(this T value) #endif => FuelEfficiency.FromKilometersPerLiter(Convert.ToDouble(value)); - /// + /// public static FuelEfficiency LitersPer100Kilometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static FuelEfficiency LitersPer100Kilometers(this T value) #endif => FuelEfficiency.FromLitersPer100Kilometers(Convert.ToDouble(value)); - /// + /// public static FuelEfficiency MilesPerUkGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static FuelEfficiency MilesPerUkGallon(this T value) #endif => FuelEfficiency.FromMilesPerUkGallon(Convert.ToDouble(value)); - /// + /// public static FuelEfficiency MilesPerUsGallon(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs index 6039addde3..baedfb6ec2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToHeatFlux /// public static class NumberToHeatFluxExtensions { - /// + /// public static HeatFlux BtusPerHourSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static HeatFlux BtusPerHourSquareFoot(this T value) #endif => HeatFlux.FromBtusPerHourSquareFoot(Convert.ToDouble(value)); - /// + /// public static HeatFlux BtusPerMinuteSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static HeatFlux BtusPerMinuteSquareFoot(this T value) #endif => HeatFlux.FromBtusPerMinuteSquareFoot(Convert.ToDouble(value)); - /// + /// public static HeatFlux BtusPerSecondSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static HeatFlux BtusPerSecondSquareFoot(this T value) #endif => HeatFlux.FromBtusPerSecondSquareFoot(Convert.ToDouble(value)); - /// + /// public static HeatFlux BtusPerSecondSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static HeatFlux BtusPerSecondSquareInch(this T value) #endif => HeatFlux.FromBtusPerSecondSquareInch(Convert.ToDouble(value)); - /// + /// public static HeatFlux CaloriesPerSecondSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static HeatFlux CaloriesPerSecondSquareCentimeter(this T value) #endif => HeatFlux.FromCaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux CentiwattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static HeatFlux CentiwattsPerSquareMeter(this T value) #endif => HeatFlux.FromCentiwattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux DeciwattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static HeatFlux DeciwattsPerSquareMeter(this T value) #endif => HeatFlux.FromDeciwattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux KilocaloriesPerHourSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static HeatFlux KilocaloriesPerHourSquareMeter(this T value) #endif => HeatFlux.FromKilocaloriesPerHourSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux KilocaloriesPerSecondSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static HeatFlux KilocaloriesPerSecondSquareCentimeter(this T value) #endif => HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux KilowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static HeatFlux KilowattsPerSquareMeter(this T value) #endif => HeatFlux.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux MicrowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static HeatFlux MicrowattsPerSquareMeter(this T value) #endif => HeatFlux.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux MilliwattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static HeatFlux MilliwattsPerSquareMeter(this T value) #endif => HeatFlux.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux NanowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static HeatFlux NanowattsPerSquareMeter(this T value) #endif => HeatFlux.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static HeatFlux PoundsForcePerFootSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static HeatFlux PoundsForcePerFootSecond(this T value) #endif => HeatFlux.FromPoundsForcePerFootSecond(Convert.ToDouble(value)); - /// + /// public static HeatFlux PoundsPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static HeatFlux PoundsPerSecondCubed(this T value) #endif => HeatFlux.FromPoundsPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static HeatFlux WattsPerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static HeatFlux WattsPerSquareFoot(this T value) #endif => HeatFlux.FromWattsPerSquareFoot(Convert.ToDouble(value)); - /// + /// public static HeatFlux WattsPerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static HeatFlux WattsPerSquareInch(this T value) #endif => HeatFlux.FromWattsPerSquareInch(Convert.ToDouble(value)); - /// + /// public static HeatFlux WattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs index 477658707c..fc7d8bc20a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToHeatTransferCoefficient /// public static class NumberToHeatTransferCoefficientExtensions { - /// + /// public static HeatTransferCoefficient BtusPerHourSquareFootDegreeFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static HeatTransferCoefficient BtusPerHourSquareFootDegreeFahrenheit(t #endif => HeatTransferCoefficient.FromBtusPerHourSquareFootDegreeFahrenheit(Convert.ToDouble(value)); - /// + /// public static HeatTransferCoefficient CaloriesPerHourSquareMeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static HeatTransferCoefficient CaloriesPerHourSquareMeterDegreeCelsius #endif => HeatTransferCoefficient.FromCaloriesPerHourSquareMeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static HeatTransferCoefficient KilocaloriesPerHourSquareMeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static HeatTransferCoefficient KilocaloriesPerHourSquareMeterDegreeCelsiu #endif => HeatTransferCoefficient.FromKilocaloriesPerHourSquareMeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static HeatTransferCoefficient WattsPerSquareMeterCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static HeatTransferCoefficient WattsPerSquareMeterCelsius(this T value #endif => HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(Convert.ToDouble(value)); - /// + /// public static HeatTransferCoefficient WattsPerSquareMeterKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs index e901c49a6a..f44a7c70ea 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToIlluminance /// public static class NumberToIlluminanceExtensions { - /// + /// public static Illuminance Kilolux(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Illuminance Kilolux(this T value) #endif => Illuminance.FromKilolux(Convert.ToDouble(value)); - /// + /// public static Illuminance Lux(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Illuminance Lux(this T value) #endif => Illuminance.FromLux(Convert.ToDouble(value)); - /// + /// public static Illuminance Megalux(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Illuminance Megalux(this T value) #endif => Illuminance.FromMegalux(Convert.ToDouble(value)); - /// + /// public static Illuminance Millilux(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToImpulseExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToImpulseExtensions.g.cs index 8e48e38d3a..5ad90b7e85 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToImpulseExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToImpulseExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToImpulse /// public static class NumberToImpulseExtensions { - /// + /// public static Impulse CentinewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Impulse CentinewtonSeconds(this T value) #endif => Impulse.FromCentinewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse DecanewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Impulse DecanewtonSeconds(this T value) #endif => Impulse.FromDecanewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse DecinewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Impulse DecinewtonSeconds(this T value) #endif => Impulse.FromDecinewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse KilogramMetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Impulse KilogramMetersPerSecond(this T value) #endif => Impulse.FromKilogramMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static Impulse KilonewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Impulse KilonewtonSeconds(this T value) #endif => Impulse.FromKilonewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse MeganewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Impulse MeganewtonSeconds(this T value) #endif => Impulse.FromMeganewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse MicronewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Impulse MicronewtonSeconds(this T value) #endif => Impulse.FromMicronewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse MillinewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Impulse MillinewtonSeconds(this T value) #endif => Impulse.FromMillinewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse NanonewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Impulse NanonewtonSeconds(this T value) #endif => Impulse.FromNanonewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse NewtonSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Impulse NewtonSeconds(this T value) #endif => Impulse.FromNewtonSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse PoundFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Impulse PoundFeetPerSecond(this T value) #endif => Impulse.FromPoundFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static Impulse PoundForceSeconds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Impulse PoundForceSeconds(this T value) #endif => Impulse.FromPoundForceSeconds(Convert.ToDouble(value)); - /// + /// public static Impulse SlugFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs index f8251dc677..80ce8e5b8a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToInformation /// public static class NumberToInformationExtensions { - /// + /// public static Information Bits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Information Bits(this T value) #endif => Information.FromBits(Convert.ToDouble(value)); - /// + /// public static Information Bytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Information Bytes(this T value) #endif => Information.FromBytes(Convert.ToDouble(value)); - /// + /// public static Information Exabits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Information Exabits(this T value) #endif => Information.FromExabits(Convert.ToDouble(value)); - /// + /// public static Information Exabytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Information Exabytes(this T value) #endif => Information.FromExabytes(Convert.ToDouble(value)); - /// + /// public static Information Exbibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Information Exbibits(this T value) #endif => Information.FromExbibits(Convert.ToDouble(value)); - /// + /// public static Information Exbibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Information Exbibytes(this T value) #endif => Information.FromExbibytes(Convert.ToDouble(value)); - /// + /// public static Information Gibibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Information Gibibits(this T value) #endif => Information.FromGibibits(Convert.ToDouble(value)); - /// + /// public static Information Gibibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Information Gibibytes(this T value) #endif => Information.FromGibibytes(Convert.ToDouble(value)); - /// + /// public static Information Gigabits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Information Gigabits(this T value) #endif => Information.FromGigabits(Convert.ToDouble(value)); - /// + /// public static Information Gigabytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Information Gigabytes(this T value) #endif => Information.FromGigabytes(Convert.ToDouble(value)); - /// + /// public static Information Kibibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Information Kibibits(this T value) #endif => Information.FromKibibits(Convert.ToDouble(value)); - /// + /// public static Information Kibibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Information Kibibytes(this T value) #endif => Information.FromKibibytes(Convert.ToDouble(value)); - /// + /// public static Information Kilobits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Information Kilobits(this T value) #endif => Information.FromKilobits(Convert.ToDouble(value)); - /// + /// public static Information Kilobytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Information Kilobytes(this T value) #endif => Information.FromKilobytes(Convert.ToDouble(value)); - /// + /// public static Information Mebibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Information Mebibits(this T value) #endif => Information.FromMebibits(Convert.ToDouble(value)); - /// + /// public static Information Mebibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Information Mebibytes(this T value) #endif => Information.FromMebibytes(Convert.ToDouble(value)); - /// + /// public static Information Megabits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Information Megabits(this T value) #endif => Information.FromMegabits(Convert.ToDouble(value)); - /// + /// public static Information Megabytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Information Megabytes(this T value) #endif => Information.FromMegabytes(Convert.ToDouble(value)); - /// + /// public static Information Pebibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Information Pebibits(this T value) #endif => Information.FromPebibits(Convert.ToDouble(value)); - /// + /// public static Information Pebibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Information Pebibytes(this T value) #endif => Information.FromPebibytes(Convert.ToDouble(value)); - /// + /// public static Information Petabits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Information Petabits(this T value) #endif => Information.FromPetabits(Convert.ToDouble(value)); - /// + /// public static Information Petabytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Information Petabytes(this T value) #endif => Information.FromPetabytes(Convert.ToDouble(value)); - /// + /// public static Information Tebibits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Information Tebibits(this T value) #endif => Information.FromTebibits(Convert.ToDouble(value)); - /// + /// public static Information Tebibytes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Information Tebibytes(this T value) #endif => Information.FromTebibytes(Convert.ToDouble(value)); - /// + /// public static Information Terabits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Information Terabits(this T value) #endif => Information.FromTerabits(Convert.ToDouble(value)); - /// + /// public static Information Terabytes(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs index cd54959d81..04ec9b745b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToIrradiance /// public static class NumberToIrradianceExtensions { - /// + /// public static Irradiance KilowattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Irradiance KilowattsPerSquareCentimeter(this T value) #endif => Irradiance.FromKilowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance KilowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Irradiance KilowattsPerSquareMeter(this T value) #endif => Irradiance.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MegawattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Irradiance MegawattsPerSquareCentimeter(this T value) #endif => Irradiance.FromMegawattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MegawattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Irradiance MegawattsPerSquareMeter(this T value) #endif => Irradiance.FromMegawattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MicrowattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Irradiance MicrowattsPerSquareCentimeter(this T value) #endif => Irradiance.FromMicrowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MicrowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Irradiance MicrowattsPerSquareMeter(this T value) #endif => Irradiance.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MilliwattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Irradiance MilliwattsPerSquareCentimeter(this T value) #endif => Irradiance.FromMilliwattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance MilliwattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Irradiance MilliwattsPerSquareMeter(this T value) #endif => Irradiance.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance NanowattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Irradiance NanowattsPerSquareCentimeter(this T value) #endif => Irradiance.FromNanowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance NanowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Irradiance NanowattsPerSquareMeter(this T value) #endif => Irradiance.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance PicowattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Irradiance PicowattsPerSquareCentimeter(this T value) #endif => Irradiance.FromPicowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance PicowattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Irradiance PicowattsPerSquareMeter(this T value) #endif => Irradiance.FromPicowattsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiance WattsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Irradiance WattsPerSquareCentimeter(this T value) #endif => Irradiance.FromWattsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiance WattsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs index 56c114cc94..3c9de0b4fd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs @@ -32,7 +32,15 @@ namespace UnitsNet.NumberExtensions.NumberToIrradiation /// public static class NumberToIrradiationExtensions { - /// + /// + public static Irradiation BtusPerSquareFoot(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => Irradiation.FromBtusPerSquareFoot(Convert.ToDouble(value)); + + /// public static Irradiation JoulesPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +48,7 @@ public static Irradiation JoulesPerSquareCentimeter(this T value) #endif => Irradiation.FromJoulesPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiation JoulesPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +56,7 @@ public static Irradiation JoulesPerSquareMeter(this T value) #endif => Irradiation.FromJoulesPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiation JoulesPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +64,15 @@ public static Irradiation JoulesPerSquareMillimeter(this T value) #endif => Irradiation.FromJoulesPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// + public static Irradiation KilobtusPerSquareFoot(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => Irradiation.FromKilobtusPerSquareFoot(Convert.ToDouble(value)); + + /// public static Irradiation KilojoulesPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +80,7 @@ public static Irradiation KilojoulesPerSquareMeter(this T value) #endif => Irradiation.FromKilojoulesPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiation KilowattHoursPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +88,7 @@ public static Irradiation KilowattHoursPerSquareMeter(this T value) #endif => Irradiation.FromKilowattHoursPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Irradiation MillijoulesPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +96,7 @@ public static Irradiation MillijoulesPerSquareCentimeter(this T value) #endif => Irradiation.FromMillijoulesPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Irradiation WattHoursPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToJerkExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToJerkExtensions.g.cs index fca1b8986b..45c9984dc7 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToJerkExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToJerkExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToJerk /// public static class NumberToJerkExtensions { - /// + /// public static Jerk CentimetersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Jerk CentimetersPerSecondCubed(this T value) #endif => Jerk.FromCentimetersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk DecimetersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Jerk DecimetersPerSecondCubed(this T value) #endif => Jerk.FromDecimetersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk FeetPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Jerk FeetPerSecondCubed(this T value) #endif => Jerk.FromFeetPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk InchesPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Jerk InchesPerSecondCubed(this T value) #endif => Jerk.FromInchesPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk KilometersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Jerk KilometersPerSecondCubed(this T value) #endif => Jerk.FromKilometersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk MetersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Jerk MetersPerSecondCubed(this T value) #endif => Jerk.FromMetersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk MicrometersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Jerk MicrometersPerSecondCubed(this T value) #endif => Jerk.FromMicrometersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk MillimetersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Jerk MillimetersPerSecondCubed(this T value) #endif => Jerk.FromMillimetersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk MillistandardGravitiesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Jerk MillistandardGravitiesPerSecond(this T value) #endif => Jerk.FromMillistandardGravitiesPerSecond(Convert.ToDouble(value)); - /// + /// public static Jerk NanometersPerSecondCubed(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Jerk NanometersPerSecondCubed(this T value) #endif => Jerk.FromNanometersPerSecondCubed(Convert.ToDouble(value)); - /// + /// public static Jerk StandardGravitiesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs index c6f829f8cd..4d5312658a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToKinematicViscosity /// public static class NumberToKinematicViscosityExtensions { - /// + /// public static KinematicViscosity Centistokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static KinematicViscosity Centistokes(this T value) #endif => KinematicViscosity.FromCentistokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Decistokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static KinematicViscosity Decistokes(this T value) #endif => KinematicViscosity.FromDecistokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Kilostokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static KinematicViscosity Kilostokes(this T value) #endif => KinematicViscosity.FromKilostokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Microstokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static KinematicViscosity Microstokes(this T value) #endif => KinematicViscosity.FromMicrostokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Millistokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static KinematicViscosity Millistokes(this T value) #endif => KinematicViscosity.FromMillistokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Nanostokes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static KinematicViscosity Nanostokes(this T value) #endif => KinematicViscosity.FromNanostokes(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity SquareFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static KinematicViscosity SquareFeetPerSecond(this T value) #endif => KinematicViscosity.FromSquareFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity SquareMetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static KinematicViscosity SquareMetersPerSecond(this T value) #endif => KinematicViscosity.FromSquareMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static KinematicViscosity Stokes(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLeakRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLeakRateExtensions.g.cs index da9bdbf25d..d307d1989e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLeakRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLeakRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLeakRate /// public static class NumberToLeakRateExtensions { - /// + /// public static LeakRate MillibarLitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static LeakRate MillibarLitersPerSecond(this T value) #endif => LeakRate.FromMillibarLitersPerSecond(Convert.ToDouble(value)); - /// + /// public static LeakRate PascalCubicMetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static LeakRate PascalCubicMetersPerSecond(this T value) #endif => LeakRate.FromPascalCubicMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static LeakRate TorrLitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs index d15563ea80..c27c30b18d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLength /// public static class NumberToLengthExtensions { - /// + /// public static Length Angstroms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Length Angstroms(this T value) #endif => Length.FromAngstroms(Convert.ToDouble(value)); - /// + /// public static Length AstronomicalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Length AstronomicalUnits(this T value) #endif => Length.FromAstronomicalUnits(Convert.ToDouble(value)); - /// + /// public static Length Centimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Length Centimeters(this T value) #endif => Length.FromCentimeters(Convert.ToDouble(value)); - /// + /// public static Length Chains(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Length Chains(this T value) #endif => Length.FromChains(Convert.ToDouble(value)); - /// + /// public static Length DataMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Length DataMiles(this T value) #endif => Length.FromDataMiles(Convert.ToDouble(value)); - /// + /// public static Length Decameters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Length Decameters(this T value) #endif => Length.FromDecameters(Convert.ToDouble(value)); - /// + /// public static Length Decimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Length Decimeters(this T value) #endif => Length.FromDecimeters(Convert.ToDouble(value)); - /// + /// public static Length DtpPicas(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Length DtpPicas(this T value) #endif => Length.FromDtpPicas(Convert.ToDouble(value)); - /// + /// public static Length DtpPoints(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Length DtpPoints(this T value) #endif => Length.FromDtpPoints(Convert.ToDouble(value)); - /// + /// public static Length Fathoms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Length Fathoms(this T value) #endif => Length.FromFathoms(Convert.ToDouble(value)); - /// + /// public static Length Femtometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Length Femtometers(this T value) #endif => Length.FromFemtometers(Convert.ToDouble(value)); - /// + /// public static Length Feet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Length Feet(this T value) #endif => Length.FromFeet(Convert.ToDouble(value)); - /// + /// public static Length Gigameters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Length Gigameters(this T value) #endif => Length.FromGigameters(Convert.ToDouble(value)); - /// + /// public static Length Hands(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Length Hands(this T value) #endif => Length.FromHands(Convert.ToDouble(value)); - /// + /// public static Length Hectometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Length Hectometers(this T value) #endif => Length.FromHectometers(Convert.ToDouble(value)); - /// + /// public static Length Inches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Length Inches(this T value) #endif => Length.FromInches(Convert.ToDouble(value)); - /// + /// public static Length Kilofeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Length Kilofeet(this T value) #endif => Length.FromKilofeet(Convert.ToDouble(value)); - /// + /// public static Length KilolightYears(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Length KilolightYears(this T value) #endif => Length.FromKilolightYears(Convert.ToDouble(value)); - /// + /// public static Length Kilometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Length Kilometers(this T value) #endif => Length.FromKilometers(Convert.ToDouble(value)); - /// + /// public static Length Kiloparsecs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Length Kiloparsecs(this T value) #endif => Length.FromKiloparsecs(Convert.ToDouble(value)); - /// + /// public static Length Kiloyards(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Length Kiloyards(this T value) #endif => Length.FromKiloyards(Convert.ToDouble(value)); - /// + /// public static Length LightYears(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Length LightYears(this T value) #endif => Length.FromLightYears(Convert.ToDouble(value)); - /// + /// public static Length MegalightYears(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Length MegalightYears(this T value) #endif => Length.FromMegalightYears(Convert.ToDouble(value)); - /// + /// public static Length Megameters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Length Megameters(this T value) #endif => Length.FromMegameters(Convert.ToDouble(value)); - /// + /// public static Length Megaparsecs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Length Megaparsecs(this T value) #endif => Length.FromMegaparsecs(Convert.ToDouble(value)); - /// + /// public static Length Meters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Length Meters(this T value) #endif => Length.FromMeters(Convert.ToDouble(value)); - /// + /// public static Length Microinches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Length Microinches(this T value) #endif => Length.FromMicroinches(Convert.ToDouble(value)); - /// + /// public static Length Micrometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Length Micrometers(this T value) #endif => Length.FromMicrometers(Convert.ToDouble(value)); - /// + /// public static Length Mils(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Length Mils(this T value) #endif => Length.FromMils(Convert.ToDouble(value)); - /// + /// public static Length Miles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Length Miles(this T value) #endif => Length.FromMiles(Convert.ToDouble(value)); - /// + /// public static Length Millimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Length Millimeters(this T value) #endif => Length.FromMillimeters(Convert.ToDouble(value)); - /// + /// public static Length Nanometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Length Nanometers(this T value) #endif => Length.FromNanometers(Convert.ToDouble(value)); - /// + /// public static Length NauticalMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static Length NauticalMiles(this T value) #endif => Length.FromNauticalMiles(Convert.ToDouble(value)); - /// + /// public static Length Parsecs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static Length Parsecs(this T value) #endif => Length.FromParsecs(Convert.ToDouble(value)); - /// + /// public static Length Picometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static Length Picometers(this T value) #endif => Length.FromPicometers(Convert.ToDouble(value)); - /// + /// public static Length PrinterPicas(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static Length PrinterPicas(this T value) #endif => Length.FromPrinterPicas(Convert.ToDouble(value)); - /// + /// public static Length PrinterPoints(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static Length PrinterPoints(this T value) #endif => Length.FromPrinterPoints(Convert.ToDouble(value)); - /// + /// public static Length Shackles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static Length Shackles(this T value) #endif => Length.FromShackles(Convert.ToDouble(value)); - /// + /// public static Length SolarRadiuses(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static Length SolarRadiuses(this T value) #endif => Length.FromSolarRadiuses(Convert.ToDouble(value)); - /// + /// public static Length Twips(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static Length Twips(this T value) #endif => Length.FromTwips(Convert.ToDouble(value)); - /// + /// public static Length UsSurveyFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static Length UsSurveyFeet(this T value) #endif => Length.FromUsSurveyFeet(Convert.ToDouble(value)); - /// + /// public static Length Yards(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs index 3d1c71a5c6..e7e387c63f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLevel /// public static class NumberToLevelExtensions { - /// + /// public static Level Decibels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Level Decibels(this T value) #endif => Level.FromDecibels(Convert.ToDouble(value)); - /// + /// public static Level Nepers(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs index b86df0fd24..d3f24626d1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLinearDensity /// public static class NumberToLinearDensityExtensions { - /// + /// public static LinearDensity GramsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static LinearDensity GramsPerCentimeter(this T value) #endif => LinearDensity.FromGramsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity GramsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static LinearDensity GramsPerMeter(this T value) #endif => LinearDensity.FromGramsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity GramsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static LinearDensity GramsPerMillimeter(this T value) #endif => LinearDensity.FromGramsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity KilogramsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static LinearDensity KilogramsPerCentimeter(this T value) #endif => LinearDensity.FromKilogramsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity KilogramsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static LinearDensity KilogramsPerMeter(this T value) #endif => LinearDensity.FromKilogramsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity KilogramsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static LinearDensity KilogramsPerMillimeter(this T value) #endif => LinearDensity.FromKilogramsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MicrogramsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static LinearDensity MicrogramsPerCentimeter(this T value) #endif => LinearDensity.FromMicrogramsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MicrogramsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static LinearDensity MicrogramsPerMeter(this T value) #endif => LinearDensity.FromMicrogramsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MicrogramsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static LinearDensity MicrogramsPerMillimeter(this T value) #endif => LinearDensity.FromMicrogramsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MilligramsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static LinearDensity MilligramsPerCentimeter(this T value) #endif => LinearDensity.FromMilligramsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MilligramsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static LinearDensity MilligramsPerMeter(this T value) #endif => LinearDensity.FromMilligramsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity MilligramsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static LinearDensity MilligramsPerMillimeter(this T value) #endif => LinearDensity.FromMilligramsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearDensity PoundsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static LinearDensity PoundsPerFoot(this T value) #endif => LinearDensity.FromPoundsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearDensity PoundsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs index 053dfdd3bb..85cf7293f3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLinearPowerDensity /// public static class NumberToLinearPowerDensityExtensions { - /// + /// public static LinearPowerDensity GigawattsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static LinearPowerDensity GigawattsPerCentimeter(this T value) #endif => LinearPowerDensity.FromGigawattsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity GigawattsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static LinearPowerDensity GigawattsPerFoot(this T value) #endif => LinearPowerDensity.FromGigawattsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity GigawattsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static LinearPowerDensity GigawattsPerInch(this T value) #endif => LinearPowerDensity.FromGigawattsPerInch(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity GigawattsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static LinearPowerDensity GigawattsPerMeter(this T value) #endif => LinearPowerDensity.FromGigawattsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity GigawattsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static LinearPowerDensity GigawattsPerMillimeter(this T value) #endif => LinearPowerDensity.FromGigawattsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity KilowattsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static LinearPowerDensity KilowattsPerCentimeter(this T value) #endif => LinearPowerDensity.FromKilowattsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity KilowattsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static LinearPowerDensity KilowattsPerFoot(this T value) #endif => LinearPowerDensity.FromKilowattsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity KilowattsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static LinearPowerDensity KilowattsPerInch(this T value) #endif => LinearPowerDensity.FromKilowattsPerInch(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity KilowattsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static LinearPowerDensity KilowattsPerMeter(this T value) #endif => LinearPowerDensity.FromKilowattsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity KilowattsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static LinearPowerDensity KilowattsPerMillimeter(this T value) #endif => LinearPowerDensity.FromKilowattsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MegawattsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static LinearPowerDensity MegawattsPerCentimeter(this T value) #endif => LinearPowerDensity.FromMegawattsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MegawattsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static LinearPowerDensity MegawattsPerFoot(this T value) #endif => LinearPowerDensity.FromMegawattsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MegawattsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static LinearPowerDensity MegawattsPerInch(this T value) #endif => LinearPowerDensity.FromMegawattsPerInch(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MegawattsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static LinearPowerDensity MegawattsPerMeter(this T value) #endif => LinearPowerDensity.FromMegawattsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MegawattsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static LinearPowerDensity MegawattsPerMillimeter(this T value) #endif => LinearPowerDensity.FromMegawattsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MilliwattsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static LinearPowerDensity MilliwattsPerCentimeter(this T value) #endif => LinearPowerDensity.FromMilliwattsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MilliwattsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static LinearPowerDensity MilliwattsPerFoot(this T value) #endif => LinearPowerDensity.FromMilliwattsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MilliwattsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static LinearPowerDensity MilliwattsPerInch(this T value) #endif => LinearPowerDensity.FromMilliwattsPerInch(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MilliwattsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static LinearPowerDensity MilliwattsPerMeter(this T value) #endif => LinearPowerDensity.FromMilliwattsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity MilliwattsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static LinearPowerDensity MilliwattsPerMillimeter(this T value) #endif => LinearPowerDensity.FromMilliwattsPerMillimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity WattsPerCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static LinearPowerDensity WattsPerCentimeter(this T value) #endif => LinearPowerDensity.FromWattsPerCentimeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity WattsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static LinearPowerDensity WattsPerFoot(this T value) #endif => LinearPowerDensity.FromWattsPerFoot(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity WattsPerInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static LinearPowerDensity WattsPerInch(this T value) #endif => LinearPowerDensity.FromWattsPerInch(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity WattsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static LinearPowerDensity WattsPerMeter(this T value) #endif => LinearPowerDensity.FromWattsPerMeter(Convert.ToDouble(value)); - /// + /// public static LinearPowerDensity WattsPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminanceExtensions.g.cs index 8a465149e9..4ab205139e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLuminance /// public static class NumberToLuminanceExtensions { - /// + /// public static Luminance CandelasPerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Luminance CandelasPerSquareFoot(this T value) #endif => Luminance.FromCandelasPerSquareFoot(Convert.ToDouble(value)); - /// + /// public static Luminance CandelasPerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Luminance CandelasPerSquareInch(this T value) #endif => Luminance.FromCandelasPerSquareInch(Convert.ToDouble(value)); - /// + /// public static Luminance CandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Luminance CandelasPerSquareMeter(this T value) #endif => Luminance.FromCandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance CenticandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Luminance CenticandelasPerSquareMeter(this T value) #endif => Luminance.FromCenticandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance DecicandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Luminance DecicandelasPerSquareMeter(this T value) #endif => Luminance.FromDecicandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance KilocandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Luminance KilocandelasPerSquareMeter(this T value) #endif => Luminance.FromKilocandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance MicrocandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Luminance MicrocandelasPerSquareMeter(this T value) #endif => Luminance.FromMicrocandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance MillicandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Luminance MillicandelasPerSquareMeter(this T value) #endif => Luminance.FromMillicandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance NanocandelasPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Luminance NanocandelasPerSquareMeter(this T value) #endif => Luminance.FromNanocandelasPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Luminance Nits(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs index 36b11e2995..013d07fa18 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLuminosity /// public static class NumberToLuminosityExtensions { - /// + /// public static Luminosity Decawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Luminosity Decawatts(this T value) #endif => Luminosity.FromDecawatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Deciwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Luminosity Deciwatts(this T value) #endif => Luminosity.FromDeciwatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Femtowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Luminosity Femtowatts(this T value) #endif => Luminosity.FromFemtowatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Gigawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Luminosity Gigawatts(this T value) #endif => Luminosity.FromGigawatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Kilowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Luminosity Kilowatts(this T value) #endif => Luminosity.FromKilowatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Megawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Luminosity Megawatts(this T value) #endif => Luminosity.FromMegawatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Microwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Luminosity Microwatts(this T value) #endif => Luminosity.FromMicrowatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Milliwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Luminosity Milliwatts(this T value) #endif => Luminosity.FromMilliwatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Nanowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Luminosity Nanowatts(this T value) #endif => Luminosity.FromNanowatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Petawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Luminosity Petawatts(this T value) #endif => Luminosity.FromPetawatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Picowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Luminosity Picowatts(this T value) #endif => Luminosity.FromPicowatts(Convert.ToDouble(value)); - /// + /// public static Luminosity SolarLuminosities(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Luminosity SolarLuminosities(this T value) #endif => Luminosity.FromSolarLuminosities(Convert.ToDouble(value)); - /// + /// public static Luminosity Terawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Luminosity Terawatts(this T value) #endif => Luminosity.FromTerawatts(Convert.ToDouble(value)); - /// + /// public static Luminosity Watts(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs index dd13f7f308..cb7e763545 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLuminousFlux /// public static class NumberToLuminousFluxExtensions { - /// + /// public static LuminousFlux Lumens(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs index 724e6f1f69..0ad7f0c4db 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToLuminousIntensity /// public static class NumberToLuminousIntensityExtensions { - /// + /// public static LuminousIntensity Candela(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs index 67043e22b6..8dc0294b76 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMagneticField /// public static class NumberToMagneticFieldExtensions { - /// + /// public static MagneticField Gausses(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MagneticField Gausses(this T value) #endif => MagneticField.FromGausses(Convert.ToDouble(value)); - /// + /// public static MagneticField Microteslas(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MagneticField Microteslas(this T value) #endif => MagneticField.FromMicroteslas(Convert.ToDouble(value)); - /// + /// public static MagneticField Milligausses(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MagneticField Milligausses(this T value) #endif => MagneticField.FromMilligausses(Convert.ToDouble(value)); - /// + /// public static MagneticField Milliteslas(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MagneticField Milliteslas(this T value) #endif => MagneticField.FromMilliteslas(Convert.ToDouble(value)); - /// + /// public static MagneticField Nanoteslas(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MagneticField Nanoteslas(this T value) #endif => MagneticField.FromNanoteslas(Convert.ToDouble(value)); - /// + /// public static MagneticField Teslas(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs index 2c6e19b2b2..f3e5d70b71 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMagneticFlux /// public static class NumberToMagneticFluxExtensions { - /// + /// public static MagneticFlux Webers(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs index 114346ec96..b7849787bd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMagnetization /// public static class NumberToMagnetizationExtensions { - /// + /// public static Magnetization AmperesPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs index 6f8b73c46f..5d1995b851 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMassConcentration /// public static class NumberToMassConcentrationExtensions { - /// + /// public static MassConcentration CentigramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MassConcentration CentigramsPerDeciliter(this T value) #endif => MassConcentration.FromCentigramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration CentigramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MassConcentration CentigramsPerLiter(this T value) #endif => MassConcentration.FromCentigramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration CentigramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MassConcentration CentigramsPerMicroliter(this T value) #endif => MassConcentration.FromCentigramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration CentigramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MassConcentration CentigramsPerMilliliter(this T value) #endif => MassConcentration.FromCentigramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration DecigramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MassConcentration DecigramsPerDeciliter(this T value) #endif => MassConcentration.FromDecigramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration DecigramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MassConcentration DecigramsPerLiter(this T value) #endif => MassConcentration.FromDecigramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration DecigramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MassConcentration DecigramsPerMicroliter(this T value) #endif => MassConcentration.FromDecigramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration DecigramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MassConcentration DecigramsPerMilliliter(this T value) #endif => MassConcentration.FromDecigramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MassConcentration GramsPerCubicCentimeter(this T value) #endif => MassConcentration.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MassConcentration GramsPerCubicMeter(this T value) #endif => MassConcentration.FromGramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MassConcentration GramsPerCubicMillimeter(this T value) #endif => MassConcentration.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static MassConcentration GramsPerDeciliter(this T value) #endif => MassConcentration.FromGramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static MassConcentration GramsPerLiter(this T value) #endif => MassConcentration.FromGramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static MassConcentration GramsPerMicroliter(this T value) #endif => MassConcentration.FromGramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration GramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static MassConcentration GramsPerMilliliter(this T value) #endif => MassConcentration.FromGramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilogramsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static MassConcentration KilogramsPerCubicCentimeter(this T value) #endif => MassConcentration.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilogramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static MassConcentration KilogramsPerCubicMeter(this T value) #endif => MassConcentration.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilogramsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static MassConcentration KilogramsPerCubicMillimeter(this T value) #endif => MassConcentration.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static MassConcentration KilogramsPerLiter(this T value) #endif => MassConcentration.FromKilogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilopoundsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static MassConcentration KilopoundsPerCubicFoot(this T value) #endif => MassConcentration.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static MassConcentration KilopoundsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static MassConcentration KilopoundsPerCubicInch(this T value) #endif => MassConcentration.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static MassConcentration MicrogramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static MassConcentration MicrogramsPerCubicMeter(this T value) #endif => MassConcentration.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MicrogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static MassConcentration MicrogramsPerDeciliter(this T value) #endif => MassConcentration.FromMicrogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MicrogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static MassConcentration MicrogramsPerLiter(this T value) #endif => MassConcentration.FromMicrogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MicrogramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static MassConcentration MicrogramsPerMicroliter(this T value) #endif => MassConcentration.FromMicrogramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MicrogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static MassConcentration MicrogramsPerMilliliter(this T value) #endif => MassConcentration.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MilligramsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static MassConcentration MilligramsPerCubicMeter(this T value) #endif => MassConcentration.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MilligramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static MassConcentration MilligramsPerDeciliter(this T value) #endif => MassConcentration.FromMilligramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MilligramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static MassConcentration MilligramsPerLiter(this T value) #endif => MassConcentration.FromMilligramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MilligramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static MassConcentration MilligramsPerMicroliter(this T value) #endif => MassConcentration.FromMilligramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration MilligramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static MassConcentration MilligramsPerMilliliter(this T value) #endif => MassConcentration.FromMilligramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration NanogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static MassConcentration NanogramsPerDeciliter(this T value) #endif => MassConcentration.FromNanogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration NanogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static MassConcentration NanogramsPerLiter(this T value) #endif => MassConcentration.FromNanogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration NanogramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static MassConcentration NanogramsPerMicroliter(this T value) #endif => MassConcentration.FromNanogramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration NanogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static MassConcentration NanogramsPerMilliliter(this T value) #endif => MassConcentration.FromNanogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration OuncesPerImperialGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static MassConcentration OuncesPerImperialGallon(this T value) #endif => MassConcentration.FromOuncesPerImperialGallon(Convert.ToDouble(value)); - /// + /// public static MassConcentration OuncesPerUSGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static MassConcentration OuncesPerUSGallon(this T value) #endif => MassConcentration.FromOuncesPerUSGallon(Convert.ToDouble(value)); - /// + /// public static MassConcentration PicogramsPerDeciliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static MassConcentration PicogramsPerDeciliter(this T value) #endif => MassConcentration.FromPicogramsPerDeciliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration PicogramsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static MassConcentration PicogramsPerLiter(this T value) #endif => MassConcentration.FromPicogramsPerLiter(Convert.ToDouble(value)); - /// + /// public static MassConcentration PicogramsPerMicroliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static MassConcentration PicogramsPerMicroliter(this T value) #endif => MassConcentration.FromPicogramsPerMicroliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration PicogramsPerMilliliter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static MassConcentration PicogramsPerMilliliter(this T value) #endif => MassConcentration.FromPicogramsPerMilliliter(Convert.ToDouble(value)); - /// + /// public static MassConcentration PoundsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +368,7 @@ public static MassConcentration PoundsPerCubicFoot(this T value) #endif => MassConcentration.FromPoundsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static MassConcentration PoundsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +376,7 @@ public static MassConcentration PoundsPerCubicInch(this T value) #endif => MassConcentration.FromPoundsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static MassConcentration PoundsPerImperialGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -384,7 +384,7 @@ public static MassConcentration PoundsPerImperialGallon(this T value) #endif => MassConcentration.FromPoundsPerImperialGallon(Convert.ToDouble(value)); - /// + /// public static MassConcentration PoundsPerUSGallon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -392,7 +392,7 @@ public static MassConcentration PoundsPerUSGallon(this T value) #endif => MassConcentration.FromPoundsPerUSGallon(Convert.ToDouble(value)); - /// + /// public static MassConcentration SlugsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -400,7 +400,7 @@ public static MassConcentration SlugsPerCubicFoot(this T value) #endif => MassConcentration.FromSlugsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static MassConcentration TonnesPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -408,7 +408,7 @@ public static MassConcentration TonnesPerCubicCentimeter(this T value) #endif => MassConcentration.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration TonnesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -416,7 +416,7 @@ public static MassConcentration TonnesPerCubicMeter(this T value) #endif => MassConcentration.FromTonnesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static MassConcentration TonnesPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs index f170ad547f..25f61855c1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMass /// public static class NumberToMassExtensions { - /// + /// public static Mass Centigrams(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Mass Centigrams(this T value) #endif => Mass.FromCentigrams(Convert.ToDouble(value)); - /// + /// public static Mass Decagrams(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Mass Decagrams(this T value) #endif => Mass.FromDecagrams(Convert.ToDouble(value)); - /// + /// public static Mass Decigrams(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Mass Decigrams(this T value) #endif => Mass.FromDecigrams(Convert.ToDouble(value)); - /// + /// public static Mass EarthMasses(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Mass EarthMasses(this T value) #endif => Mass.FromEarthMasses(Convert.ToDouble(value)); - /// + /// public static Mass Femtograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Mass Femtograms(this T value) #endif => Mass.FromFemtograms(Convert.ToDouble(value)); - /// + /// public static Mass Grains(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Mass Grains(this T value) #endif => Mass.FromGrains(Convert.ToDouble(value)); - /// + /// public static Mass Grams(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Mass Grams(this T value) #endif => Mass.FromGrams(Convert.ToDouble(value)); - /// + /// public static Mass Hectograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Mass Hectograms(this T value) #endif => Mass.FromHectograms(Convert.ToDouble(value)); - /// + /// public static Mass Kilograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Mass Kilograms(this T value) #endif => Mass.FromKilograms(Convert.ToDouble(value)); - /// + /// public static Mass Kilopounds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Mass Kilopounds(this T value) #endif => Mass.FromKilopounds(Convert.ToDouble(value)); - /// + /// public static Mass Kilotonnes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Mass Kilotonnes(this T value) #endif => Mass.FromKilotonnes(Convert.ToDouble(value)); - /// + /// public static Mass LongHundredweight(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Mass LongHundredweight(this T value) #endif => Mass.FromLongHundredweight(Convert.ToDouble(value)); - /// + /// public static Mass LongTons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Mass LongTons(this T value) #endif => Mass.FromLongTons(Convert.ToDouble(value)); - /// + /// public static Mass Megapounds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Mass Megapounds(this T value) #endif => Mass.FromMegapounds(Convert.ToDouble(value)); - /// + /// public static Mass Megatonnes(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Mass Megatonnes(this T value) #endif => Mass.FromMegatonnes(Convert.ToDouble(value)); - /// + /// public static Mass Micrograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Mass Micrograms(this T value) #endif => Mass.FromMicrograms(Convert.ToDouble(value)); - /// + /// public static Mass Milligrams(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Mass Milligrams(this T value) #endif => Mass.FromMilligrams(Convert.ToDouble(value)); - /// + /// public static Mass Nanograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Mass Nanograms(this T value) #endif => Mass.FromNanograms(Convert.ToDouble(value)); - /// + /// public static Mass Ounces(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Mass Ounces(this T value) #endif => Mass.FromOunces(Convert.ToDouble(value)); - /// + /// public static Mass Picograms(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Mass Picograms(this T value) #endif => Mass.FromPicograms(Convert.ToDouble(value)); - /// + /// public static Mass Pounds(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Mass Pounds(this T value) #endif => Mass.FromPounds(Convert.ToDouble(value)); - /// + /// public static Mass ShortHundredweight(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Mass ShortHundredweight(this T value) #endif => Mass.FromShortHundredweight(Convert.ToDouble(value)); - /// + /// public static Mass ShortTons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Mass ShortTons(this T value) #endif => Mass.FromShortTons(Convert.ToDouble(value)); - /// + /// public static Mass Slugs(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Mass Slugs(this T value) #endif => Mass.FromSlugs(Convert.ToDouble(value)); - /// + /// public static Mass SolarMasses(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Mass SolarMasses(this T value) #endif => Mass.FromSolarMasses(Convert.ToDouble(value)); - /// + /// public static Mass Stone(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Mass Stone(this T value) #endif => Mass.FromStone(Convert.ToDouble(value)); - /// + /// public static Mass Tonnes(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs index 3f75371a85..4e2594c4e8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMassFlow /// public static class NumberToMassFlowExtensions { - /// + /// public static MassFlow CentigramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MassFlow CentigramsPerDay(this T value) #endif => MassFlow.FromCentigramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow CentigramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MassFlow CentigramsPerSecond(this T value) #endif => MassFlow.FromCentigramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow DecagramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MassFlow DecagramsPerDay(this T value) #endif => MassFlow.FromDecagramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow DecagramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MassFlow DecagramsPerSecond(this T value) #endif => MassFlow.FromDecagramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow DecigramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MassFlow DecigramsPerDay(this T value) #endif => MassFlow.FromDecigramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow DecigramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MassFlow DecigramsPerSecond(this T value) #endif => MassFlow.FromDecigramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow GramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MassFlow GramsPerDay(this T value) #endif => MassFlow.FromGramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow GramsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MassFlow GramsPerHour(this T value) #endif => MassFlow.FromGramsPerHour(Convert.ToDouble(value)); - /// + /// public static MassFlow GramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MassFlow GramsPerSecond(this T value) #endif => MassFlow.FromGramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow HectogramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MassFlow HectogramsPerDay(this T value) #endif => MassFlow.FromHectogramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow HectogramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MassFlow HectogramsPerSecond(this T value) #endif => MassFlow.FromHectogramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow KilogramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static MassFlow KilogramsPerDay(this T value) #endif => MassFlow.FromKilogramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow KilogramsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static MassFlow KilogramsPerHour(this T value) #endif => MassFlow.FromKilogramsPerHour(Convert.ToDouble(value)); - /// + /// public static MassFlow KilogramsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static MassFlow KilogramsPerMinute(this T value) #endif => MassFlow.FromKilogramsPerMinute(Convert.ToDouble(value)); - /// + /// public static MassFlow KilogramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static MassFlow KilogramsPerSecond(this T value) #endif => MassFlow.FromKilogramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow MegagramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static MassFlow MegagramsPerDay(this T value) #endif => MassFlow.FromMegagramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow MegapoundsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static MassFlow MegapoundsPerDay(this T value) #endif => MassFlow.FromMegapoundsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow MegapoundsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static MassFlow MegapoundsPerHour(this T value) #endif => MassFlow.FromMegapoundsPerHour(Convert.ToDouble(value)); - /// + /// public static MassFlow MegapoundsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static MassFlow MegapoundsPerMinute(this T value) #endif => MassFlow.FromMegapoundsPerMinute(Convert.ToDouble(value)); - /// + /// public static MassFlow MegapoundsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static MassFlow MegapoundsPerSecond(this T value) #endif => MassFlow.FromMegapoundsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow MicrogramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static MassFlow MicrogramsPerDay(this T value) #endif => MassFlow.FromMicrogramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow MicrogramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static MassFlow MicrogramsPerSecond(this T value) #endif => MassFlow.FromMicrogramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow MilligramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static MassFlow MilligramsPerDay(this T value) #endif => MassFlow.FromMilligramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow MilligramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static MassFlow MilligramsPerSecond(this T value) #endif => MassFlow.FromMilligramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow NanogramsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static MassFlow NanogramsPerDay(this T value) #endif => MassFlow.FromNanogramsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow NanogramsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static MassFlow NanogramsPerSecond(this T value) #endif => MassFlow.FromNanogramsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow PoundsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static MassFlow PoundsPerDay(this T value) #endif => MassFlow.FromPoundsPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow PoundsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static MassFlow PoundsPerHour(this T value) #endif => MassFlow.FromPoundsPerHour(Convert.ToDouble(value)); - /// + /// public static MassFlow PoundsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static MassFlow PoundsPerMinute(this T value) #endif => MassFlow.FromPoundsPerMinute(Convert.ToDouble(value)); - /// + /// public static MassFlow PoundsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static MassFlow PoundsPerSecond(this T value) #endif => MassFlow.FromPoundsPerSecond(Convert.ToDouble(value)); - /// + /// public static MassFlow ShortTonsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static MassFlow ShortTonsPerHour(this T value) #endif => MassFlow.FromShortTonsPerHour(Convert.ToDouble(value)); - /// + /// public static MassFlow TonnesPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static MassFlow TonnesPerDay(this T value) #endif => MassFlow.FromTonnesPerDay(Convert.ToDouble(value)); - /// + /// public static MassFlow TonnesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs index 2e8c63df81..183d04cf0e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMassFlux /// public static class NumberToMassFluxExtensions { - /// + /// public static MassFlux GramsPerHourPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MassFlux GramsPerHourPerSquareCentimeter(this T value) #endif => MassFlux.FromGramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux GramsPerHourPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MassFlux GramsPerHourPerSquareMeter(this T value) #endif => MassFlux.FromGramsPerHourPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static MassFlux GramsPerHourPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MassFlux GramsPerHourPerSquareMillimeter(this T value) #endif => MassFlux.FromGramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux GramsPerSecondPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MassFlux GramsPerSecondPerSquareCentimeter(this T value) #endif => MassFlux.FromGramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux GramsPerSecondPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MassFlux GramsPerSecondPerSquareMeter(this T value) #endif => MassFlux.FromGramsPerSecondPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static MassFlux GramsPerSecondPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MassFlux GramsPerSecondPerSquareMillimeter(this T value) #endif => MassFlux.FromGramsPerSecondPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerHourPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MassFlux KilogramsPerHourPerSquareCentimeter(this T value) #endif => MassFlux.FromKilogramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerHourPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MassFlux KilogramsPerHourPerSquareMeter(this T value) #endif => MassFlux.FromKilogramsPerHourPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerHourPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MassFlux KilogramsPerHourPerSquareMillimeter(this T value) #endif => MassFlux.FromKilogramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerSecondPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MassFlux KilogramsPerSecondPerSquareCentimeter(this T value) #endif => MassFlux.FromKilogramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerSecondPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MassFlux KilogramsPerSecondPerSquareMeter(this T value) #endif => MassFlux.FromKilogramsPerSecondPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static MassFlux KilogramsPerSecondPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs index 6f499b2090..72c81f182b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMassFraction /// public static class NumberToMassFractionExtensions { - /// + /// public static MassFraction CentigramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MassFraction CentigramsPerGram(this T value) #endif => MassFraction.FromCentigramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction CentigramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MassFraction CentigramsPerKilogram(this T value) #endif => MassFraction.FromCentigramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction DecagramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MassFraction DecagramsPerGram(this T value) #endif => MassFraction.FromDecagramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction DecagramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MassFraction DecagramsPerKilogram(this T value) #endif => MassFraction.FromDecagramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction DecigramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MassFraction DecigramsPerGram(this T value) #endif => MassFraction.FromDecigramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction DecigramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MassFraction DecigramsPerKilogram(this T value) #endif => MassFraction.FromDecigramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction DecimalFractions(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MassFraction DecimalFractions(this T value) #endif => MassFraction.FromDecimalFractions(Convert.ToDouble(value)); - /// + /// public static MassFraction GramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MassFraction GramsPerGram(this T value) #endif => MassFraction.FromGramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction GramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MassFraction GramsPerKilogram(this T value) #endif => MassFraction.FromGramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction HectogramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MassFraction HectogramsPerGram(this T value) #endif => MassFraction.FromHectogramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction HectogramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MassFraction HectogramsPerKilogram(this T value) #endif => MassFraction.FromHectogramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction KilogramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static MassFraction KilogramsPerGram(this T value) #endif => MassFraction.FromKilogramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction KilogramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static MassFraction KilogramsPerKilogram(this T value) #endif => MassFraction.FromKilogramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction MicrogramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static MassFraction MicrogramsPerGram(this T value) #endif => MassFraction.FromMicrogramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction MicrogramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static MassFraction MicrogramsPerKilogram(this T value) #endif => MassFraction.FromMicrogramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction MilligramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static MassFraction MilligramsPerGram(this T value) #endif => MassFraction.FromMilligramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction MilligramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static MassFraction MilligramsPerKilogram(this T value) #endif => MassFraction.FromMilligramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction NanogramsPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static MassFraction NanogramsPerGram(this T value) #endif => MassFraction.FromNanogramsPerGram(Convert.ToDouble(value)); - /// + /// public static MassFraction NanogramsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static MassFraction NanogramsPerKilogram(this T value) #endif => MassFraction.FromNanogramsPerKilogram(Convert.ToDouble(value)); - /// + /// public static MassFraction PartsPerBillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static MassFraction PartsPerBillion(this T value) #endif => MassFraction.FromPartsPerBillion(Convert.ToDouble(value)); - /// + /// public static MassFraction PartsPerMillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static MassFraction PartsPerMillion(this T value) #endif => MassFraction.FromPartsPerMillion(Convert.ToDouble(value)); - /// + /// public static MassFraction PartsPerThousand(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static MassFraction PartsPerThousand(this T value) #endif => MassFraction.FromPartsPerThousand(Convert.ToDouble(value)); - /// + /// public static MassFraction PartsPerTrillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static MassFraction PartsPerTrillion(this T value) #endif => MassFraction.FromPartsPerTrillion(Convert.ToDouble(value)); - /// + /// public static MassFraction Percent(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs index 1aae922769..fc3b58b964 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMassMomentOfInertia /// public static class NumberToMassMomentOfInertiaExtensions { - /// + /// public static MassMomentOfInertia GramSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MassMomentOfInertia GramSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromGramSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia GramSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MassMomentOfInertia GramSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromGramSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia GramSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MassMomentOfInertia GramSquareMeters(this T value) #endif => MassMomentOfInertia.FromGramSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia GramSquareMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MassMomentOfInertia GramSquareMillimeters(this T value) #endif => MassMomentOfInertia.FromGramSquareMillimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilogramSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MassMomentOfInertia KilogramSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromKilogramSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilogramSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MassMomentOfInertia KilogramSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromKilogramSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilogramSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MassMomentOfInertia KilogramSquareMeters(this T value) #endif => MassMomentOfInertia.FromKilogramSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilogramSquareMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MassMomentOfInertia KilogramSquareMillimeters(this T value) #endif => MassMomentOfInertia.FromKilogramSquareMillimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilotonneSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MassMomentOfInertia KilotonneSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromKilotonneSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilotonneSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MassMomentOfInertia KilotonneSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromKilotonneSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilotonneSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MassMomentOfInertia KilotonneSquareMeters(this T value) #endif => MassMomentOfInertia.FromKilotonneSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia KilotonneSquareMilimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static MassMomentOfInertia KilotonneSquareMilimeters(this T value) #endif => MassMomentOfInertia.FromKilotonneSquareMilimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MegatonneSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static MassMomentOfInertia MegatonneSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromMegatonneSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MegatonneSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static MassMomentOfInertia MegatonneSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromMegatonneSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MegatonneSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static MassMomentOfInertia MegatonneSquareMeters(this T value) #endif => MassMomentOfInertia.FromMegatonneSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MegatonneSquareMilimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static MassMomentOfInertia MegatonneSquareMilimeters(this T value) #endif => MassMomentOfInertia.FromMegatonneSquareMilimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MilligramSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static MassMomentOfInertia MilligramSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromMilligramSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MilligramSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static MassMomentOfInertia MilligramSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromMilligramSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MilligramSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static MassMomentOfInertia MilligramSquareMeters(this T value) #endif => MassMomentOfInertia.FromMilligramSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia MilligramSquareMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static MassMomentOfInertia MilligramSquareMillimeters(this T value) #endif => MassMomentOfInertia.FromMilligramSquareMillimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia PoundSquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static MassMomentOfInertia PoundSquareFeet(this T value) #endif => MassMomentOfInertia.FromPoundSquareFeet(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia PoundSquareInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static MassMomentOfInertia PoundSquareInches(this T value) #endif => MassMomentOfInertia.FromPoundSquareInches(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia SlugSquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static MassMomentOfInertia SlugSquareFeet(this T value) #endif => MassMomentOfInertia.FromSlugSquareFeet(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia SlugSquareInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static MassMomentOfInertia SlugSquareInches(this T value) #endif => MassMomentOfInertia.FromSlugSquareInches(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia TonneSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static MassMomentOfInertia TonneSquareCentimeters(this T value) #endif => MassMomentOfInertia.FromTonneSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia TonneSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static MassMomentOfInertia TonneSquareDecimeters(this T value) #endif => MassMomentOfInertia.FromTonneSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia TonneSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static MassMomentOfInertia TonneSquareMeters(this T value) #endif => MassMomentOfInertia.FromTonneSquareMeters(Convert.ToDouble(value)); - /// + /// public static MassMomentOfInertia TonneSquareMilimeters(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs index ce9fd27d4a..84e41c5834 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolalityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolality /// public static class NumberToMolalityExtensions { - /// + /// public static Molality MolesPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Molality MolesPerGram(this T value) #endif => Molality.FromMolesPerGram(Convert.ToDouble(value)); - /// + /// public static Molality MolesPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs index caf2e58733..58414acb63 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolarEnergy /// public static class NumberToMolarEnergyExtensions { - /// + /// public static MolarEnergy JoulesPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MolarEnergy JoulesPerMole(this T value) #endif => MolarEnergy.FromJoulesPerMole(Convert.ToDouble(value)); - /// + /// public static MolarEnergy KilojoulesPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MolarEnergy KilojoulesPerMole(this T value) #endif => MolarEnergy.FromKilojoulesPerMole(Convert.ToDouble(value)); - /// + /// public static MolarEnergy MegajoulesPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs index 27264a55b3..06db4fb3a8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolarEntropy /// public static class NumberToMolarEntropyExtensions { - /// + /// public static MolarEntropy JoulesPerMoleKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MolarEntropy JoulesPerMoleKelvin(this T value) #endif => MolarEntropy.FromJoulesPerMoleKelvin(Convert.ToDouble(value)); - /// + /// public static MolarEntropy KilojoulesPerMoleKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MolarEntropy KilojoulesPerMoleKelvin(this T value) #endif => MolarEntropy.FromKilojoulesPerMoleKelvin(Convert.ToDouble(value)); - /// + /// public static MolarEntropy MegajoulesPerMoleKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarFlowExtensions.g.cs index 0b2ab19d42..e17f9b134b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarFlowExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolarFlow /// public static class NumberToMolarFlowExtensions { - /// + /// public static MolarFlow KilomolesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MolarFlow KilomolesPerHour(this T value) #endif => MolarFlow.FromKilomolesPerHour(Convert.ToDouble(value)); - /// + /// public static MolarFlow KilomolesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MolarFlow KilomolesPerMinute(this T value) #endif => MolarFlow.FromKilomolesPerMinute(Convert.ToDouble(value)); - /// + /// public static MolarFlow KilomolesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MolarFlow KilomolesPerSecond(this T value) #endif => MolarFlow.FromKilomolesPerSecond(Convert.ToDouble(value)); - /// + /// public static MolarFlow MolesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MolarFlow MolesPerHour(this T value) #endif => MolarFlow.FromMolesPerHour(Convert.ToDouble(value)); - /// + /// public static MolarFlow MolesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MolarFlow MolesPerMinute(this T value) #endif => MolarFlow.FromMolesPerMinute(Convert.ToDouble(value)); - /// + /// public static MolarFlow MolesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MolarFlow MolesPerSecond(this T value) #endif => MolarFlow.FromMolesPerSecond(Convert.ToDouble(value)); - /// + /// public static MolarFlow PoundMolesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MolarFlow PoundMolesPerHour(this T value) #endif => MolarFlow.FromPoundMolesPerHour(Convert.ToDouble(value)); - /// + /// public static MolarFlow PoundMolesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MolarFlow PoundMolesPerMinute(this T value) #endif => MolarFlow.FromPoundMolesPerMinute(Convert.ToDouble(value)); - /// + /// public static MolarFlow PoundMolesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs index 42daf96a91..e9515d2971 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolarMass /// public static class NumberToMolarMassExtensions { - /// + /// public static MolarMass CentigramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static MolarMass CentigramsPerMole(this T value) #endif => MolarMass.FromCentigramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass DecagramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static MolarMass DecagramsPerMole(this T value) #endif => MolarMass.FromDecagramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass DecigramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static MolarMass DecigramsPerMole(this T value) #endif => MolarMass.FromDecigramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass GramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static MolarMass GramsPerMole(this T value) #endif => MolarMass.FromGramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass HectogramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static MolarMass HectogramsPerMole(this T value) #endif => MolarMass.FromHectogramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass KilogramsPerKilomole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static MolarMass KilogramsPerKilomole(this T value) #endif => MolarMass.FromKilogramsPerKilomole(Convert.ToDouble(value)); - /// + /// public static MolarMass KilogramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static MolarMass KilogramsPerMole(this T value) #endif => MolarMass.FromKilogramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass KilopoundsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static MolarMass KilopoundsPerMole(this T value) #endif => MolarMass.FromKilopoundsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass MegapoundsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static MolarMass MegapoundsPerMole(this T value) #endif => MolarMass.FromMegapoundsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass MicrogramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static MolarMass MicrogramsPerMole(this T value) #endif => MolarMass.FromMicrogramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass MilligramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static MolarMass MilligramsPerMole(this T value) #endif => MolarMass.FromMilligramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass NanogramsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static MolarMass NanogramsPerMole(this T value) #endif => MolarMass.FromNanogramsPerMole(Convert.ToDouble(value)); - /// + /// public static MolarMass PoundsPerMole(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs index eb2f51f2bb..5f07660139 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToMolarity /// public static class NumberToMolarityExtensions { - /// + /// public static Molarity CentimolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Molarity CentimolesPerLiter(this T value) #endif => Molarity.FromCentimolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity DecimolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Molarity DecimolesPerLiter(this T value) #endif => Molarity.FromDecimolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity FemtomolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Molarity FemtomolesPerLiter(this T value) #endif => Molarity.FromFemtomolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity KilomolesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Molarity KilomolesPerCubicMeter(this T value) #endif => Molarity.FromKilomolesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Molarity MicromolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Molarity MicromolesPerLiter(this T value) #endif => Molarity.FromMicromolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity MillimolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Molarity MillimolesPerLiter(this T value) #endif => Molarity.FromMillimolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity MolesPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Molarity MolesPerCubicMeter(this T value) #endif => Molarity.FromMolesPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static Molarity MolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Molarity MolesPerLiter(this T value) #endif => Molarity.FromMolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity NanomolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Molarity NanomolesPerLiter(this T value) #endif => Molarity.FromNanomolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity PicomolesPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Molarity PicomolesPerLiter(this T value) #endif => Molarity.FromPicomolesPerLiter(Convert.ToDouble(value)); - /// + /// public static Molarity PoundMolesPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs index c1c5f1b458..73206d5915 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPermeability /// public static class NumberToPermeabilityExtensions { - /// + /// public static Permeability HenriesPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs index 1c3b83a7b7..3428092588 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPermittivity /// public static class NumberToPermittivityExtensions { - /// + /// public static Permittivity FaradsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPorousMediumPermeabilityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPorousMediumPermeabilityExtensions.g.cs index 9198d7c7c3..761a4297dc 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPorousMediumPermeabilityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPorousMediumPermeabilityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPorousMediumPermeability /// public static class NumberToPorousMediumPermeabilityExtensions { - /// + /// public static PorousMediumPermeability Darcys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static PorousMediumPermeability Darcys(this T value) #endif => PorousMediumPermeability.FromDarcys(Convert.ToDouble(value)); - /// + /// public static PorousMediumPermeability Microdarcys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static PorousMediumPermeability Microdarcys(this T value) #endif => PorousMediumPermeability.FromMicrodarcys(Convert.ToDouble(value)); - /// + /// public static PorousMediumPermeability Millidarcys(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static PorousMediumPermeability Millidarcys(this T value) #endif => PorousMediumPermeability.FromMillidarcys(Convert.ToDouble(value)); - /// + /// public static PorousMediumPermeability SquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static PorousMediumPermeability SquareCentimeters(this T value) #endif => PorousMediumPermeability.FromSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static PorousMediumPermeability SquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs index 847b8babbe..a552df0ebd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPowerDensity /// public static class NumberToPowerDensityExtensions { - /// + /// public static PowerDensity DecawattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static PowerDensity DecawattsPerCubicFoot(this T value) #endif => PowerDensity.FromDecawattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity DecawattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static PowerDensity DecawattsPerCubicInch(this T value) #endif => PowerDensity.FromDecawattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity DecawattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static PowerDensity DecawattsPerCubicMeter(this T value) #endif => PowerDensity.FromDecawattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity DecawattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static PowerDensity DecawattsPerLiter(this T value) #endif => PowerDensity.FromDecawattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity DeciwattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static PowerDensity DeciwattsPerCubicFoot(this T value) #endif => PowerDensity.FromDeciwattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity DeciwattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static PowerDensity DeciwattsPerCubicInch(this T value) #endif => PowerDensity.FromDeciwattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity DeciwattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static PowerDensity DeciwattsPerCubicMeter(this T value) #endif => PowerDensity.FromDeciwattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity DeciwattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static PowerDensity DeciwattsPerLiter(this T value) #endif => PowerDensity.FromDeciwattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity GigawattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static PowerDensity GigawattsPerCubicFoot(this T value) #endif => PowerDensity.FromGigawattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity GigawattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static PowerDensity GigawattsPerCubicInch(this T value) #endif => PowerDensity.FromGigawattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity GigawattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static PowerDensity GigawattsPerCubicMeter(this T value) #endif => PowerDensity.FromGigawattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity GigawattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static PowerDensity GigawattsPerLiter(this T value) #endif => PowerDensity.FromGigawattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity KilowattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static PowerDensity KilowattsPerCubicFoot(this T value) #endif => PowerDensity.FromKilowattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity KilowattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static PowerDensity KilowattsPerCubicInch(this T value) #endif => PowerDensity.FromKilowattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity KilowattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static PowerDensity KilowattsPerCubicMeter(this T value) #endif => PowerDensity.FromKilowattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity KilowattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static PowerDensity KilowattsPerLiter(this T value) #endif => PowerDensity.FromKilowattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MegawattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static PowerDensity MegawattsPerCubicFoot(this T value) #endif => PowerDensity.FromMegawattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity MegawattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static PowerDensity MegawattsPerCubicInch(this T value) #endif => PowerDensity.FromMegawattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity MegawattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static PowerDensity MegawattsPerCubicMeter(this T value) #endif => PowerDensity.FromMegawattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MegawattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static PowerDensity MegawattsPerLiter(this T value) #endif => PowerDensity.FromMegawattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MicrowattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static PowerDensity MicrowattsPerCubicFoot(this T value) #endif => PowerDensity.FromMicrowattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity MicrowattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static PowerDensity MicrowattsPerCubicInch(this T value) #endif => PowerDensity.FromMicrowattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity MicrowattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static PowerDensity MicrowattsPerCubicMeter(this T value) #endif => PowerDensity.FromMicrowattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MicrowattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static PowerDensity MicrowattsPerLiter(this T value) #endif => PowerDensity.FromMicrowattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MilliwattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static PowerDensity MilliwattsPerCubicFoot(this T value) #endif => PowerDensity.FromMilliwattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity MilliwattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static PowerDensity MilliwattsPerCubicInch(this T value) #endif => PowerDensity.FromMilliwattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity MilliwattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static PowerDensity MilliwattsPerCubicMeter(this T value) #endif => PowerDensity.FromMilliwattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity MilliwattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static PowerDensity MilliwattsPerLiter(this T value) #endif => PowerDensity.FromMilliwattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity NanowattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static PowerDensity NanowattsPerCubicFoot(this T value) #endif => PowerDensity.FromNanowattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity NanowattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static PowerDensity NanowattsPerCubicInch(this T value) #endif => PowerDensity.FromNanowattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity NanowattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static PowerDensity NanowattsPerCubicMeter(this T value) #endif => PowerDensity.FromNanowattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity NanowattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static PowerDensity NanowattsPerLiter(this T value) #endif => PowerDensity.FromNanowattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity PicowattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static PowerDensity PicowattsPerCubicFoot(this T value) #endif => PowerDensity.FromPicowattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity PicowattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static PowerDensity PicowattsPerCubicInch(this T value) #endif => PowerDensity.FromPicowattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity PicowattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static PowerDensity PicowattsPerCubicMeter(this T value) #endif => PowerDensity.FromPicowattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity PicowattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static PowerDensity PicowattsPerLiter(this T value) #endif => PowerDensity.FromPicowattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity TerawattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static PowerDensity TerawattsPerCubicFoot(this T value) #endif => PowerDensity.FromTerawattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity TerawattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static PowerDensity TerawattsPerCubicInch(this T value) #endif => PowerDensity.FromTerawattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity TerawattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static PowerDensity TerawattsPerCubicMeter(this T value) #endif => PowerDensity.FromTerawattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity TerawattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static PowerDensity TerawattsPerLiter(this T value) #endif => PowerDensity.FromTerawattsPerLiter(Convert.ToDouble(value)); - /// + /// public static PowerDensity WattsPerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static PowerDensity WattsPerCubicFoot(this T value) #endif => PowerDensity.FromWattsPerCubicFoot(Convert.ToDouble(value)); - /// + /// public static PowerDensity WattsPerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +368,7 @@ public static PowerDensity WattsPerCubicInch(this T value) #endif => PowerDensity.FromWattsPerCubicInch(Convert.ToDouble(value)); - /// + /// public static PowerDensity WattsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +376,7 @@ public static PowerDensity WattsPerCubicMeter(this T value) #endif => PowerDensity.FromWattsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static PowerDensity WattsPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs index 8889adcf42..0906450f0b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPower /// public static class NumberToPowerExtensions { - /// + /// public static Power BoilerHorsepower(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Power BoilerHorsepower(this T value) #endif => Power.FromBoilerHorsepower(Convert.ToDouble(value)); - /// + /// public static Power BritishThermalUnitsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Power BritishThermalUnitsPerHour(this T value) #endif => Power.FromBritishThermalUnitsPerHour(Convert.ToDouble(value)); - /// + /// public static Power Decawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Power Decawatts(this T value) #endif => Power.FromDecawatts(Convert.ToDouble(value)); - /// + /// public static Power Deciwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Power Deciwatts(this T value) #endif => Power.FromDeciwatts(Convert.ToDouble(value)); - /// + /// public static Power ElectricalHorsepower(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Power ElectricalHorsepower(this T value) #endif => Power.FromElectricalHorsepower(Convert.ToDouble(value)); - /// + /// public static Power Femtowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Power Femtowatts(this T value) #endif => Power.FromFemtowatts(Convert.ToDouble(value)); - /// + /// public static Power GigajoulesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Power GigajoulesPerHour(this T value) #endif => Power.FromGigajoulesPerHour(Convert.ToDouble(value)); - /// + /// public static Power Gigawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Power Gigawatts(this T value) #endif => Power.FromGigawatts(Convert.ToDouble(value)); - /// + /// public static Power HydraulicHorsepower(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Power HydraulicHorsepower(this T value) #endif => Power.FromHydraulicHorsepower(Convert.ToDouble(value)); - /// + /// public static Power JoulesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Power JoulesPerHour(this T value) #endif => Power.FromJoulesPerHour(Convert.ToDouble(value)); - /// + /// public static Power KilobritishThermalUnitsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Power KilobritishThermalUnitsPerHour(this T value) #endif => Power.FromKilobritishThermalUnitsPerHour(Convert.ToDouble(value)); - /// + /// public static Power KilojoulesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Power KilojoulesPerHour(this T value) #endif => Power.FromKilojoulesPerHour(Convert.ToDouble(value)); - /// + /// public static Power Kilowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Power Kilowatts(this T value) #endif => Power.FromKilowatts(Convert.ToDouble(value)); - /// + /// public static Power MechanicalHorsepower(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Power MechanicalHorsepower(this T value) #endif => Power.FromMechanicalHorsepower(Convert.ToDouble(value)); - /// + /// public static Power MegabritishThermalUnitsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Power MegabritishThermalUnitsPerHour(this T value) #endif => Power.FromMegabritishThermalUnitsPerHour(Convert.ToDouble(value)); - /// + /// public static Power MegajoulesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Power MegajoulesPerHour(this T value) #endif => Power.FromMegajoulesPerHour(Convert.ToDouble(value)); - /// + /// public static Power Megawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Power Megawatts(this T value) #endif => Power.FromMegawatts(Convert.ToDouble(value)); - /// + /// public static Power MetricHorsepower(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Power MetricHorsepower(this T value) #endif => Power.FromMetricHorsepower(Convert.ToDouble(value)); - /// + /// public static Power Microwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Power Microwatts(this T value) #endif => Power.FromMicrowatts(Convert.ToDouble(value)); - /// + /// public static Power MillijoulesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Power MillijoulesPerHour(this T value) #endif => Power.FromMillijoulesPerHour(Convert.ToDouble(value)); - /// + /// public static Power Milliwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Power Milliwatts(this T value) #endif => Power.FromMilliwatts(Convert.ToDouble(value)); - /// + /// public static Power Nanowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Power Nanowatts(this T value) #endif => Power.FromNanowatts(Convert.ToDouble(value)); - /// + /// public static Power Petawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Power Petawatts(this T value) #endif => Power.FromPetawatts(Convert.ToDouble(value)); - /// + /// public static Power Picowatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Power Picowatts(this T value) #endif => Power.FromPicowatts(Convert.ToDouble(value)); - /// + /// public static Power Terawatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Power Terawatts(this T value) #endif => Power.FromTerawatts(Convert.ToDouble(value)); - /// + /// public static Power Watts(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs index 19128fa14d..5e3ac3a56b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPowerRatio /// public static class NumberToPowerRatioExtensions { - /// + /// public static PowerRatio DecibelMilliwatts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static PowerRatio DecibelMilliwatts(this T value) #endif => PowerRatio.FromDecibelMilliwatts(Convert.ToDouble(value)); - /// + /// public static PowerRatio DecibelWatts(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs index 3cc38f1321..c97412b805 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPressureChangeRate /// public static class NumberToPressureChangeRateExtensions { - /// + /// public static PressureChangeRate AtmospheresPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static PressureChangeRate AtmospheresPerSecond(this T value) #endif => PressureChangeRate.FromAtmospheresPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate BarsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static PressureChangeRate BarsPerMinute(this T value) #endif => PressureChangeRate.FromBarsPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate BarsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static PressureChangeRate BarsPerSecond(this T value) #endif => PressureChangeRate.FromBarsPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate KilopascalsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static PressureChangeRate KilopascalsPerMinute(this T value) #endif => PressureChangeRate.FromKilopascalsPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate KilopascalsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static PressureChangeRate KilopascalsPerSecond(this T value) #endif => PressureChangeRate.FromKilopascalsPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate KilopoundsForcePerSquareInchPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static PressureChangeRate KilopoundsForcePerSquareInchPerMinute(this T #endif => PressureChangeRate.FromKilopoundsForcePerSquareInchPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate KilopoundsForcePerSquareInchPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static PressureChangeRate KilopoundsForcePerSquareInchPerSecond(this T #endif => PressureChangeRate.FromKilopoundsForcePerSquareInchPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MegapascalsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static PressureChangeRate MegapascalsPerMinute(this T value) #endif => PressureChangeRate.FromMegapascalsPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MegapascalsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static PressureChangeRate MegapascalsPerSecond(this T value) #endif => PressureChangeRate.FromMegapascalsPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MegapoundsForcePerSquareInchPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static PressureChangeRate MegapoundsForcePerSquareInchPerMinute(this T #endif => PressureChangeRate.FromMegapoundsForcePerSquareInchPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MegapoundsForcePerSquareInchPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static PressureChangeRate MegapoundsForcePerSquareInchPerSecond(this T #endif => PressureChangeRate.FromMegapoundsForcePerSquareInchPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MillibarsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static PressureChangeRate MillibarsPerMinute(this T value) #endif => PressureChangeRate.FromMillibarsPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MillibarsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static PressureChangeRate MillibarsPerSecond(this T value) #endif => PressureChangeRate.FromMillibarsPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate MillimetersOfMercuryPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static PressureChangeRate MillimetersOfMercuryPerSecond(this T value) #endif => PressureChangeRate.FromMillimetersOfMercuryPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate PascalsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static PressureChangeRate PascalsPerMinute(this T value) #endif => PressureChangeRate.FromPascalsPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate PascalsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static PressureChangeRate PascalsPerSecond(this T value) #endif => PressureChangeRate.FromPascalsPerSecond(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate PoundsForcePerSquareInchPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static PressureChangeRate PoundsForcePerSquareInchPerMinute(this T val #endif => PressureChangeRate.FromPoundsForcePerSquareInchPerMinute(Convert.ToDouble(value)); - /// + /// public static PressureChangeRate PoundsForcePerSquareInchPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs index 3f3ef204b5..1301aad614 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToPressure /// public static class NumberToPressureExtensions { - /// + /// public static Pressure Atmospheres(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Pressure Atmospheres(this T value) #endif => Pressure.FromAtmospheres(Convert.ToDouble(value)); - /// + /// public static Pressure Bars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Pressure Bars(this T value) #endif => Pressure.FromBars(Convert.ToDouble(value)); - /// + /// public static Pressure Centibars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Pressure Centibars(this T value) #endif => Pressure.FromCentibars(Convert.ToDouble(value)); - /// + /// public static Pressure CentimetersOfWaterColumn(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Pressure CentimetersOfWaterColumn(this T value) #endif => Pressure.FromCentimetersOfWaterColumn(Convert.ToDouble(value)); - /// + /// public static Pressure Decapascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Pressure Decapascals(this T value) #endif => Pressure.FromDecapascals(Convert.ToDouble(value)); - /// + /// public static Pressure Decibars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Pressure Decibars(this T value) #endif => Pressure.FromDecibars(Convert.ToDouble(value)); - /// + /// public static Pressure DynesPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Pressure DynesPerSquareCentimeter(this T value) #endif => Pressure.FromDynesPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Pressure FeetOfElevation(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Pressure FeetOfElevation(this T value) #endif => Pressure.FromFeetOfElevation(Convert.ToDouble(value)); - /// + /// public static Pressure FeetOfHead(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Pressure FeetOfHead(this T value) #endif => Pressure.FromFeetOfHead(Convert.ToDouble(value)); - /// + /// public static Pressure Gigapascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Pressure Gigapascals(this T value) #endif => Pressure.FromGigapascals(Convert.ToDouble(value)); - /// + /// public static Pressure Hectopascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Pressure Hectopascals(this T value) #endif => Pressure.FromHectopascals(Convert.ToDouble(value)); - /// + /// public static Pressure InchesOfMercury(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Pressure InchesOfMercury(this T value) #endif => Pressure.FromInchesOfMercury(Convert.ToDouble(value)); - /// + /// public static Pressure InchesOfWaterColumn(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Pressure InchesOfWaterColumn(this T value) #endif => Pressure.FromInchesOfWaterColumn(Convert.ToDouble(value)); - /// + /// public static Pressure Kilobars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Pressure Kilobars(this T value) #endif => Pressure.FromKilobars(Convert.ToDouble(value)); - /// + /// public static Pressure KilogramsForcePerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Pressure KilogramsForcePerSquareCentimeter(this T value) #endif => Pressure.FromKilogramsForcePerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Pressure KilogramsForcePerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Pressure KilogramsForcePerSquareMeter(this T value) #endif => Pressure.FromKilogramsForcePerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Pressure KilogramsForcePerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Pressure KilogramsForcePerSquareMillimeter(this T value) #endif => Pressure.FromKilogramsForcePerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static Pressure KilonewtonsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Pressure KilonewtonsPerSquareCentimeter(this T value) #endif => Pressure.FromKilonewtonsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Pressure KilonewtonsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Pressure KilonewtonsPerSquareMeter(this T value) #endif => Pressure.FromKilonewtonsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Pressure KilonewtonsPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Pressure KilonewtonsPerSquareMillimeter(this T value) #endif => Pressure.FromKilonewtonsPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static Pressure Kilopascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Pressure Kilopascals(this T value) #endif => Pressure.FromKilopascals(Convert.ToDouble(value)); - /// + /// public static Pressure KilopoundsForcePerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Pressure KilopoundsForcePerSquareFoot(this T value) #endif => Pressure.FromKilopoundsForcePerSquareFoot(Convert.ToDouble(value)); - /// + /// public static Pressure KilopoundsForcePerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Pressure KilopoundsForcePerSquareInch(this T value) #endif => Pressure.FromKilopoundsForcePerSquareInch(Convert.ToDouble(value)); - /// + /// public static Pressure KilopoundsForcePerSquareMil(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Pressure KilopoundsForcePerSquareMil(this T value) #endif => Pressure.FromKilopoundsForcePerSquareMil(Convert.ToDouble(value)); - /// + /// public static Pressure Megabars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Pressure Megabars(this T value) #endif => Pressure.FromMegabars(Convert.ToDouble(value)); - /// + /// public static Pressure MeganewtonsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Pressure MeganewtonsPerSquareMeter(this T value) #endif => Pressure.FromMeganewtonsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Pressure Megapascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Pressure Megapascals(this T value) #endif => Pressure.FromMegapascals(Convert.ToDouble(value)); - /// + /// public static Pressure MetersOfElevation(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Pressure MetersOfElevation(this T value) #endif => Pressure.FromMetersOfElevation(Convert.ToDouble(value)); - /// + /// public static Pressure MetersOfHead(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Pressure MetersOfHead(this T value) #endif => Pressure.FromMetersOfHead(Convert.ToDouble(value)); - /// + /// public static Pressure MetersOfWaterColumn(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Pressure MetersOfWaterColumn(this T value) #endif => Pressure.FromMetersOfWaterColumn(Convert.ToDouble(value)); - /// + /// public static Pressure Microbars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Pressure Microbars(this T value) #endif => Pressure.FromMicrobars(Convert.ToDouble(value)); - /// + /// public static Pressure Micropascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Pressure Micropascals(this T value) #endif => Pressure.FromMicropascals(Convert.ToDouble(value)); - /// + /// public static Pressure Millibars(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static Pressure Millibars(this T value) #endif => Pressure.FromMillibars(Convert.ToDouble(value)); - /// + /// public static Pressure MillimetersOfMercury(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static Pressure MillimetersOfMercury(this T value) #endif => Pressure.FromMillimetersOfMercury(Convert.ToDouble(value)); - /// + /// public static Pressure MillimetersOfWaterColumn(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static Pressure MillimetersOfWaterColumn(this T value) #endif => Pressure.FromMillimetersOfWaterColumn(Convert.ToDouble(value)); - /// + /// public static Pressure Millipascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static Pressure Millipascals(this T value) #endif => Pressure.FromMillipascals(Convert.ToDouble(value)); - /// + /// public static Pressure NewtonsPerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static Pressure NewtonsPerSquareCentimeter(this T value) #endif => Pressure.FromNewtonsPerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Pressure NewtonsPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static Pressure NewtonsPerSquareMeter(this T value) #endif => Pressure.FromNewtonsPerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Pressure NewtonsPerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static Pressure NewtonsPerSquareMillimeter(this T value) #endif => Pressure.FromNewtonsPerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static Pressure Pascals(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static Pressure Pascals(this T value) #endif => Pressure.FromPascals(Convert.ToDouble(value)); - /// + /// public static Pressure PoundsForcePerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static Pressure PoundsForcePerSquareFoot(this T value) #endif => Pressure.FromPoundsForcePerSquareFoot(Convert.ToDouble(value)); - /// + /// public static Pressure PoundsForcePerSquareInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +368,7 @@ public static Pressure PoundsForcePerSquareInch(this T value) #endif => Pressure.FromPoundsForcePerSquareInch(Convert.ToDouble(value)); - /// + /// public static Pressure PoundsForcePerSquareMil(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +376,7 @@ public static Pressure PoundsForcePerSquareMil(this T value) #endif => Pressure.FromPoundsForcePerSquareMil(Convert.ToDouble(value)); - /// + /// public static Pressure PoundsPerInchSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -384,7 +384,7 @@ public static Pressure PoundsPerInchSecondSquared(this T value) #endif => Pressure.FromPoundsPerInchSecondSquared(Convert.ToDouble(value)); - /// + /// public static Pressure TechnicalAtmospheres(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -392,7 +392,7 @@ public static Pressure TechnicalAtmospheres(this T value) #endif => Pressure.FromTechnicalAtmospheres(Convert.ToDouble(value)); - /// + /// public static Pressure TonnesForcePerSquareCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -400,7 +400,7 @@ public static Pressure TonnesForcePerSquareCentimeter(this T value) #endif => Pressure.FromTonnesForcePerSquareCentimeter(Convert.ToDouble(value)); - /// + /// public static Pressure TonnesForcePerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -408,7 +408,7 @@ public static Pressure TonnesForcePerSquareMeter(this T value) #endif => Pressure.FromTonnesForcePerSquareMeter(Convert.ToDouble(value)); - /// + /// public static Pressure TonnesForcePerSquareMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -416,7 +416,7 @@ public static Pressure TonnesForcePerSquareMillimeter(this T value) #endif => Pressure.FromTonnesForcePerSquareMillimeter(Convert.ToDouble(value)); - /// + /// public static Pressure Torrs(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseExtensions.g.cs new file mode 100644 index 0000000000..833c5edf88 --- /dev/null +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseExtensions.g.cs @@ -0,0 +1,84 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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 NET7_0_OR_GREATER +using System.Numerics; +#endif + +#nullable enable + +namespace UnitsNet.NumberExtensions.NumberToRadiationEquivalentDose +{ + /// + /// A number to RadiationEquivalentDose Extensions + /// + public static class NumberToRadiationEquivalentDoseExtensions + { + /// + public static RadiationEquivalentDose Microsieverts(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromMicrosieverts(Convert.ToDouble(value)); + + /// + public static RadiationEquivalentDose MilliroentgensEquivalentMan(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromMilliroentgensEquivalentMan(Convert.ToDouble(value)); + + /// + public static RadiationEquivalentDose Millisieverts(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromMillisieverts(Convert.ToDouble(value)); + + /// + public static RadiationEquivalentDose Nanosieverts(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromNanosieverts(Convert.ToDouble(value)); + + /// + public static RadiationEquivalentDose RoentgensEquivalentMan(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromRoentgensEquivalentMan(Convert.ToDouble(value)); + + /// + public static RadiationEquivalentDose Sieverts(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDose.FromSieverts(Convert.ToDouble(value)); + + } +} diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationExposureExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationExposureExtensions.g.cs index 643106c73b..18f515b677 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationExposureExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationExposureExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRadiationExposure /// public static class NumberToRadiationExposureExtensions { - /// + /// public static RadiationExposure CoulombsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RadiationExposure CoulombsPerKilogram(this T value) #endif => RadiationExposure.FromCoulombsPerKilogram(Convert.ToDouble(value)); - /// + /// public static RadiationExposure MicrocoulombsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static RadiationExposure MicrocoulombsPerKilogram(this T value) #endif => RadiationExposure.FromMicrocoulombsPerKilogram(Convert.ToDouble(value)); - /// + /// public static RadiationExposure Microroentgens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static RadiationExposure Microroentgens(this T value) #endif => RadiationExposure.FromMicroroentgens(Convert.ToDouble(value)); - /// + /// public static RadiationExposure MillicoulombsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static RadiationExposure MillicoulombsPerKilogram(this T value) #endif => RadiationExposure.FromMillicoulombsPerKilogram(Convert.ToDouble(value)); - /// + /// public static RadiationExposure Milliroentgens(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static RadiationExposure Milliroentgens(this T value) #endif => RadiationExposure.FromMilliroentgens(Convert.ToDouble(value)); - /// + /// public static RadiationExposure NanocoulombsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static RadiationExposure NanocoulombsPerKilogram(this T value) #endif => RadiationExposure.FromNanocoulombsPerKilogram(Convert.ToDouble(value)); - /// + /// public static RadiationExposure PicocoulombsPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static RadiationExposure PicocoulombsPerKilogram(this T value) #endif => RadiationExposure.FromPicocoulombsPerKilogram(Convert.ToDouble(value)); - /// + /// public static RadiationExposure Roentgens(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadioactivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadioactivityExtensions.g.cs index b9ecd03de3..e89535da39 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadioactivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadioactivityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRadioactivity /// public static class NumberToRadioactivityExtensions { - /// + /// public static Radioactivity Becquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Radioactivity Becquerels(this T value) #endif => Radioactivity.FromBecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Curies(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Radioactivity Curies(this T value) #endif => Radioactivity.FromCuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Exabecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Radioactivity Exabecquerels(this T value) #endif => Radioactivity.FromExabecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Gigabecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Radioactivity Gigabecquerels(this T value) #endif => Radioactivity.FromGigabecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Gigacuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Radioactivity Gigacuries(this T value) #endif => Radioactivity.FromGigacuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Gigarutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Radioactivity Gigarutherfords(this T value) #endif => Radioactivity.FromGigarutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Kilobecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Radioactivity Kilobecquerels(this T value) #endif => Radioactivity.FromKilobecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Kilocuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Radioactivity Kilocuries(this T value) #endif => Radioactivity.FromKilocuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Kilorutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Radioactivity Kilorutherfords(this T value) #endif => Radioactivity.FromKilorutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Megabecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Radioactivity Megabecquerels(this T value) #endif => Radioactivity.FromMegabecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Megacuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Radioactivity Megacuries(this T value) #endif => Radioactivity.FromMegacuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Megarutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Radioactivity Megarutherfords(this T value) #endif => Radioactivity.FromMegarutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Microbecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Radioactivity Microbecquerels(this T value) #endif => Radioactivity.FromMicrobecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Microcuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Radioactivity Microcuries(this T value) #endif => Radioactivity.FromMicrocuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Microrutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Radioactivity Microrutherfords(this T value) #endif => Radioactivity.FromMicrorutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Millibecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Radioactivity Millibecquerels(this T value) #endif => Radioactivity.FromMillibecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Millicuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Radioactivity Millicuries(this T value) #endif => Radioactivity.FromMillicuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Millirutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Radioactivity Millirutherfords(this T value) #endif => Radioactivity.FromMillirutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Nanobecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Radioactivity Nanobecquerels(this T value) #endif => Radioactivity.FromNanobecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Nanocuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Radioactivity Nanocuries(this T value) #endif => Radioactivity.FromNanocuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Nanorutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Radioactivity Nanorutherfords(this T value) #endif => Radioactivity.FromNanorutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Petabecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Radioactivity Petabecquerels(this T value) #endif => Radioactivity.FromPetabecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Picobecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Radioactivity Picobecquerels(this T value) #endif => Radioactivity.FromPicobecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Picocuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Radioactivity Picocuries(this T value) #endif => Radioactivity.FromPicocuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Picorutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Radioactivity Picorutherfords(this T value) #endif => Radioactivity.FromPicorutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Rutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Radioactivity Rutherfords(this T value) #endif => Radioactivity.FromRutherfords(Convert.ToDouble(value)); - /// + /// public static Radioactivity Terabecquerels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Radioactivity Terabecquerels(this T value) #endif => Radioactivity.FromTerabecquerels(Convert.ToDouble(value)); - /// + /// public static Radioactivity Teracuries(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Radioactivity Teracuries(this T value) #endif => Radioactivity.FromTeracuries(Convert.ToDouble(value)); - /// + /// public static Radioactivity Terarutherfords(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs index 19bff685ff..b79c6f1b04 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRatioChangeRate /// public static class NumberToRatioChangeRateExtensions { - /// + /// public static RatioChangeRate DecimalFractionsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RatioChangeRate DecimalFractionsPerSecond(this T value) #endif => RatioChangeRate.FromDecimalFractionsPerSecond(Convert.ToDouble(value)); - /// + /// public static RatioChangeRate PercentsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs index 4e13937c48..ddbc29c1a5 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRatio /// public static class NumberToRatioExtensions { - /// + /// public static Ratio DecimalFractions(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Ratio DecimalFractions(this T value) #endif => Ratio.FromDecimalFractions(Convert.ToDouble(value)); - /// + /// public static Ratio PartsPerBillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Ratio PartsPerBillion(this T value) #endif => Ratio.FromPartsPerBillion(Convert.ToDouble(value)); - /// + /// public static Ratio PartsPerMillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Ratio PartsPerMillion(this T value) #endif => Ratio.FromPartsPerMillion(Convert.ToDouble(value)); - /// + /// public static Ratio PartsPerThousand(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Ratio PartsPerThousand(this T value) #endif => Ratio.FromPartsPerThousand(Convert.ToDouble(value)); - /// + /// public static Ratio PartsPerTrillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Ratio PartsPerTrillion(this T value) #endif => Ratio.FromPartsPerTrillion(Convert.ToDouble(value)); - /// + /// public static Ratio Percent(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs index 57e2c4ee3f..60eb880038 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToReactiveEnergy /// public static class NumberToReactiveEnergyExtensions { - /// + /// public static ReactiveEnergy KilovoltampereReactiveHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ReactiveEnergy KilovoltampereReactiveHours(this T value) #endif => ReactiveEnergy.FromKilovoltampereReactiveHours(Convert.ToDouble(value)); - /// + /// public static ReactiveEnergy MegavoltampereReactiveHours(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ReactiveEnergy MegavoltampereReactiveHours(this T value) #endif => ReactiveEnergy.FromMegavoltampereReactiveHours(Convert.ToDouble(value)); - /// + /// public static ReactiveEnergy VoltampereReactiveHours(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs index 70ffc0b7b0..5a5bc6af46 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToReactivePower /// public static class NumberToReactivePowerExtensions { - /// + /// public static ReactivePower GigavoltamperesReactive(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ReactivePower GigavoltamperesReactive(this T value) #endif => ReactivePower.FromGigavoltamperesReactive(Convert.ToDouble(value)); - /// + /// public static ReactivePower KilovoltamperesReactive(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ReactivePower KilovoltamperesReactive(this T value) #endif => ReactivePower.FromKilovoltamperesReactive(Convert.ToDouble(value)); - /// + /// public static ReactivePower MegavoltamperesReactive(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ReactivePower MegavoltamperesReactive(this T value) #endif => ReactivePower.FromMegavoltamperesReactive(Convert.ToDouble(value)); - /// + /// public static ReactivePower VoltamperesReactive(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalAreaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalAreaExtensions.g.cs index 85b4bb1803..9fad600616 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalAreaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalAreaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToReciprocalArea /// public static class NumberToReciprocalAreaExtensions { - /// + /// public static ReciprocalArea InverseSquareCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ReciprocalArea InverseSquareCentimeters(this T value) #endif => ReciprocalArea.FromInverseSquareCentimeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ReciprocalArea InverseSquareDecimeters(this T value) #endif => ReciprocalArea.FromInverseSquareDecimeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ReciprocalArea InverseSquareFeet(this T value) #endif => ReciprocalArea.FromInverseSquareFeet(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ReciprocalArea InverseSquareInches(this T value) #endif => ReciprocalArea.FromInverseSquareInches(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareKilometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ReciprocalArea InverseSquareKilometers(this T value) #endif => ReciprocalArea.FromInverseSquareKilometers(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ReciprocalArea InverseSquareMeters(this T value) #endif => ReciprocalArea.FromInverseSquareMeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareMicrometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ReciprocalArea InverseSquareMicrometers(this T value) #endif => ReciprocalArea.FromInverseSquareMicrometers(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ReciprocalArea InverseSquareMiles(this T value) #endif => ReciprocalArea.FromInverseSquareMiles(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ReciprocalArea InverseSquareMillimeters(this T value) #endif => ReciprocalArea.FromInverseSquareMillimeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseSquareYards(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static ReciprocalArea InverseSquareYards(this T value) #endif => ReciprocalArea.FromInverseSquareYards(Convert.ToDouble(value)); - /// + /// public static ReciprocalArea InverseUsSurveySquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalLengthExtensions.g.cs index 961f505c4c..a4450d8b9f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReciprocalLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToReciprocalLength /// public static class NumberToReciprocalLengthExtensions { - /// + /// public static ReciprocalLength InverseCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ReciprocalLength InverseCentimeters(this T value) #endif => ReciprocalLength.FromInverseCentimeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ReciprocalLength InverseFeet(this T value) #endif => ReciprocalLength.FromInverseFeet(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ReciprocalLength InverseInches(this T value) #endif => ReciprocalLength.FromInverseInches(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ReciprocalLength InverseMeters(this T value) #endif => ReciprocalLength.FromInverseMeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseMicroinches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ReciprocalLength InverseMicroinches(this T value) #endif => ReciprocalLength.FromInverseMicroinches(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseMils(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static ReciprocalLength InverseMils(this T value) #endif => ReciprocalLength.FromInverseMils(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static ReciprocalLength InverseMiles(this T value) #endif => ReciprocalLength.FromInverseMiles(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static ReciprocalLength InverseMillimeters(this T value) #endif => ReciprocalLength.FromInverseMillimeters(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseUsSurveyFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static ReciprocalLength InverseUsSurveyFeet(this T value) #endif => ReciprocalLength.FromInverseUsSurveyFeet(Convert.ToDouble(value)); - /// + /// public static ReciprocalLength InverseYards(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs index a218c2130e..2c0ff455a2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRelativeHumidity /// public static class NumberToRelativeHumidityExtensions { - /// + /// public static RelativeHumidity Percent(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs index 2fb64ce3fa..e05d1d975b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalAcceleration /// public static class NumberToRotationalAccelerationExtensions { - /// + /// public static RotationalAcceleration DegreesPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RotationalAcceleration DegreesPerSecondSquared(this T value) #endif => RotationalAcceleration.FromDegreesPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static RotationalAcceleration RadiansPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static RotationalAcceleration RadiansPerSecondSquared(this T value) #endif => RotationalAcceleration.FromRadiansPerSecondSquared(Convert.ToDouble(value)); - /// + /// public static RotationalAcceleration RevolutionsPerMinutePerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static RotationalAcceleration RevolutionsPerMinutePerSecond(this T val #endif => RotationalAcceleration.FromRevolutionsPerMinutePerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalAcceleration RevolutionsPerSecondSquared(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs index 2435e30aa9..ab47fa84c8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalSpeed /// public static class NumberToRotationalSpeedExtensions { - /// + /// public static RotationalSpeed CentiradiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RotationalSpeed CentiradiansPerSecond(this T value) #endif => RotationalSpeed.FromCentiradiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed DeciradiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static RotationalSpeed DeciradiansPerSecond(this T value) #endif => RotationalSpeed.FromDeciradiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed DegreesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static RotationalSpeed DegreesPerMinute(this T value) #endif => RotationalSpeed.FromDegreesPerMinute(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed DegreesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static RotationalSpeed DegreesPerSecond(this T value) #endif => RotationalSpeed.FromDegreesPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed MicrodegreesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static RotationalSpeed MicrodegreesPerSecond(this T value) #endif => RotationalSpeed.FromMicrodegreesPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed MicroradiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static RotationalSpeed MicroradiansPerSecond(this T value) #endif => RotationalSpeed.FromMicroradiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed MillidegreesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static RotationalSpeed MillidegreesPerSecond(this T value) #endif => RotationalSpeed.FromMillidegreesPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed MilliradiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static RotationalSpeed MilliradiansPerSecond(this T value) #endif => RotationalSpeed.FromMilliradiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed NanodegreesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static RotationalSpeed NanodegreesPerSecond(this T value) #endif => RotationalSpeed.FromNanodegreesPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed NanoradiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static RotationalSpeed NanoradiansPerSecond(this T value) #endif => RotationalSpeed.FromNanoradiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed RadiansPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static RotationalSpeed RadiansPerSecond(this T value) #endif => RotationalSpeed.FromRadiansPerSecond(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed RevolutionsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static RotationalSpeed RevolutionsPerMinute(this T value) #endif => RotationalSpeed.FromRevolutionsPerMinute(Convert.ToDouble(value)); - /// + /// public static RotationalSpeed RevolutionsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs index fa713661cb..94a232adba 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalStiffness /// public static class NumberToRotationalStiffnessExtensions { - /// + /// public static RotationalStiffness CentinewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RotationalStiffness CentinewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromCentinewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness CentinewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static RotationalStiffness CentinewtonMillimetersPerDegree(this T valu #endif => RotationalStiffness.FromCentinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness CentinewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static RotationalStiffness CentinewtonMillimetersPerRadian(this T valu #endif => RotationalStiffness.FromCentinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecanewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static RotationalStiffness DecanewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromDecanewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecanewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static RotationalStiffness DecanewtonMillimetersPerDegree(this T value #endif => RotationalStiffness.FromDecanewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecanewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static RotationalStiffness DecanewtonMillimetersPerRadian(this T value #endif => RotationalStiffness.FromDecanewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecinewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static RotationalStiffness DecinewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromDecinewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecinewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static RotationalStiffness DecinewtonMillimetersPerDegree(this T value #endif => RotationalStiffness.FromDecinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness DecinewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static RotationalStiffness DecinewtonMillimetersPerRadian(this T value #endif => RotationalStiffness.FromDecinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness KilonewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static RotationalStiffness KilonewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromKilonewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness KilonewtonMetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static RotationalStiffness KilonewtonMetersPerRadian(this T value) #endif => RotationalStiffness.FromKilonewtonMetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness KilonewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static RotationalStiffness KilonewtonMillimetersPerDegree(this T value #endif => RotationalStiffness.FromKilonewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness KilonewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static RotationalStiffness KilonewtonMillimetersPerRadian(this T value #endif => RotationalStiffness.FromKilonewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness KilopoundForceFeetPerDegrees(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static RotationalStiffness KilopoundForceFeetPerDegrees(this T value) #endif => RotationalStiffness.FromKilopoundForceFeetPerDegrees(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MeganewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static RotationalStiffness MeganewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromMeganewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MeganewtonMetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static RotationalStiffness MeganewtonMetersPerRadian(this T value) #endif => RotationalStiffness.FromMeganewtonMetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MeganewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static RotationalStiffness MeganewtonMillimetersPerDegree(this T value #endif => RotationalStiffness.FromMeganewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MeganewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static RotationalStiffness MeganewtonMillimetersPerRadian(this T value #endif => RotationalStiffness.FromMeganewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MicronewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static RotationalStiffness MicronewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromMicronewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MicronewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static RotationalStiffness MicronewtonMillimetersPerDegree(this T valu #endif => RotationalStiffness.FromMicronewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MicronewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static RotationalStiffness MicronewtonMillimetersPerRadian(this T valu #endif => RotationalStiffness.FromMicronewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MillinewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static RotationalStiffness MillinewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromMillinewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MillinewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static RotationalStiffness MillinewtonMillimetersPerDegree(this T valu #endif => RotationalStiffness.FromMillinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness MillinewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static RotationalStiffness MillinewtonMillimetersPerRadian(this T valu #endif => RotationalStiffness.FromMillinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NanonewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static RotationalStiffness NanonewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromNanonewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NanonewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static RotationalStiffness NanonewtonMillimetersPerDegree(this T value #endif => RotationalStiffness.FromNanonewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NanonewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static RotationalStiffness NanonewtonMillimetersPerRadian(this T value #endif => RotationalStiffness.FromNanonewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NewtonMetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static RotationalStiffness NewtonMetersPerDegree(this T value) #endif => RotationalStiffness.FromNewtonMetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NewtonMetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static RotationalStiffness NewtonMetersPerRadian(this T value) #endif => RotationalStiffness.FromNewtonMetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NewtonMillimetersPerDegree(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static RotationalStiffness NewtonMillimetersPerDegree(this T value) #endif => RotationalStiffness.FromNewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness NewtonMillimetersPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static RotationalStiffness NewtonMillimetersPerRadian(this T value) #endif => RotationalStiffness.FromNewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness PoundForceFeetPerRadian(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static RotationalStiffness PoundForceFeetPerRadian(this T value) #endif => RotationalStiffness.FromPoundForceFeetPerRadian(Convert.ToDouble(value)); - /// + /// public static RotationalStiffness PoundForceFeetPerDegrees(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs index 61ca08cb9e..37e66c3d73 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalStiffnessPerLength /// public static class NumberToRotationalStiffnessPerLengthExtensions { - /// + /// public static RotationalStiffnessPerLength KilonewtonMetersPerRadianPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static RotationalStiffnessPerLength KilonewtonMetersPerRadianPerMeter( #endif => RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// + /// public static RotationalStiffnessPerLength KilopoundForceFeetPerDegreesPerFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static RotationalStiffnessPerLength KilopoundForceFeetPerDegreesPerFeet RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(Convert.ToDouble(value)); - /// + /// public static RotationalStiffnessPerLength MeganewtonMetersPerRadianPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static RotationalStiffnessPerLength MeganewtonMetersPerRadianPerMeter( #endif => RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// + /// public static RotationalStiffnessPerLength NewtonMetersPerRadianPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static RotationalStiffnessPerLength NewtonMetersPerRadianPerMeter(this #endif => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// + /// public static RotationalStiffnessPerLength PoundForceFeetPerDegreesPerFeet(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToScalarExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToScalarExtensions.g.cs index 36ff683ac4..5a0a3543f2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToScalarExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToScalarExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToScalar /// public static class NumberToScalarExtensions { - /// + /// public static Scalar Amount(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs index 769ebf0a67..8eed0d5cad 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSolidAngle /// public static class NumberToSolidAngleExtensions { - /// + /// public static SolidAngle Steradians(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs index f94c47ccc1..a3dd8ea1d4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificEnergy /// public static class NumberToSpecificEnergyExtensions { - /// + /// public static SpecificEnergy BtuPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static SpecificEnergy BtuPerPound(this T value) #endif => SpecificEnergy.FromBtuPerPound(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy CaloriesPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static SpecificEnergy CaloriesPerGram(this T value) #endif => SpecificEnergy.FromCaloriesPerGram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy GigawattDaysPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static SpecificEnergy GigawattDaysPerKilogram(this T value) #endif => SpecificEnergy.FromGigawattDaysPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy GigawattDaysPerShortTon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static SpecificEnergy GigawattDaysPerShortTon(this T value) #endif => SpecificEnergy.FromGigawattDaysPerShortTon(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy GigawattDaysPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static SpecificEnergy GigawattDaysPerTonne(this T value) #endif => SpecificEnergy.FromGigawattDaysPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy GigawattHoursPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static SpecificEnergy GigawattHoursPerKilogram(this T value) #endif => SpecificEnergy.FromGigawattHoursPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy GigawattHoursPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static SpecificEnergy GigawattHoursPerPound(this T value) #endif => SpecificEnergy.FromGigawattHoursPerPound(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy JoulesPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static SpecificEnergy JoulesPerKilogram(this T value) #endif => SpecificEnergy.FromJoulesPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilocaloriesPerGram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static SpecificEnergy KilocaloriesPerGram(this T value) #endif => SpecificEnergy.FromKilocaloriesPerGram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilojoulesPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static SpecificEnergy KilojoulesPerKilogram(this T value) #endif => SpecificEnergy.FromKilojoulesPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilowattDaysPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static SpecificEnergy KilowattDaysPerKilogram(this T value) #endif => SpecificEnergy.FromKilowattDaysPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilowattDaysPerShortTon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static SpecificEnergy KilowattDaysPerShortTon(this T value) #endif => SpecificEnergy.FromKilowattDaysPerShortTon(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilowattDaysPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static SpecificEnergy KilowattDaysPerTonne(this T value) #endif => SpecificEnergy.FromKilowattDaysPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilowattHoursPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static SpecificEnergy KilowattHoursPerKilogram(this T value) #endif => SpecificEnergy.FromKilowattHoursPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy KilowattHoursPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static SpecificEnergy KilowattHoursPerPound(this T value) #endif => SpecificEnergy.FromKilowattHoursPerPound(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegajoulesPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static SpecificEnergy MegajoulesPerKilogram(this T value) #endif => SpecificEnergy.FromMegajoulesPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegaJoulesPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static SpecificEnergy MegaJoulesPerTonne(this T value) #endif => SpecificEnergy.FromMegaJoulesPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegawattDaysPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static SpecificEnergy MegawattDaysPerKilogram(this T value) #endif => SpecificEnergy.FromMegawattDaysPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegawattDaysPerShortTon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static SpecificEnergy MegawattDaysPerShortTon(this T value) #endif => SpecificEnergy.FromMegawattDaysPerShortTon(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegawattDaysPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static SpecificEnergy MegawattDaysPerTonne(this T value) #endif => SpecificEnergy.FromMegawattDaysPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegawattHoursPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static SpecificEnergy MegawattHoursPerKilogram(this T value) #endif => SpecificEnergy.FromMegawattHoursPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy MegawattHoursPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static SpecificEnergy MegawattHoursPerPound(this T value) #endif => SpecificEnergy.FromMegawattHoursPerPound(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy TerawattDaysPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static SpecificEnergy TerawattDaysPerKilogram(this T value) #endif => SpecificEnergy.FromTerawattDaysPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy TerawattDaysPerShortTon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static SpecificEnergy TerawattDaysPerShortTon(this T value) #endif => SpecificEnergy.FromTerawattDaysPerShortTon(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy TerawattDaysPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static SpecificEnergy TerawattDaysPerTonne(this T value) #endif => SpecificEnergy.FromTerawattDaysPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy WattDaysPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static SpecificEnergy WattDaysPerKilogram(this T value) #endif => SpecificEnergy.FromWattDaysPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy WattDaysPerShortTon(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static SpecificEnergy WattDaysPerShortTon(this T value) #endif => SpecificEnergy.FromWattDaysPerShortTon(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy WattDaysPerTonne(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static SpecificEnergy WattDaysPerTonne(this T value) #endif => SpecificEnergy.FromWattDaysPerTonne(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy WattHoursPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static SpecificEnergy WattHoursPerKilogram(this T value) #endif => SpecificEnergy.FromWattHoursPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificEnergy WattHoursPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs index b84168a527..1d9a4d78af 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificEntropy /// public static class NumberToSpecificEntropyExtensions { - /// + /// public static SpecificEntropy BtusPerPoundFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static SpecificEntropy BtusPerPoundFahrenheit(this T value) #endif => SpecificEntropy.FromBtusPerPoundFahrenheit(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy CaloriesPerGramKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static SpecificEntropy CaloriesPerGramKelvin(this T value) #endif => SpecificEntropy.FromCaloriesPerGramKelvin(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy JoulesPerKilogramDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static SpecificEntropy JoulesPerKilogramDegreeCelsius(this T value) #endif => SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy JoulesPerKilogramKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static SpecificEntropy JoulesPerKilogramKelvin(this T value) #endif => SpecificEntropy.FromJoulesPerKilogramKelvin(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy KilocaloriesPerGramKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static SpecificEntropy KilocaloriesPerGramKelvin(this T value) #endif => SpecificEntropy.FromKilocaloriesPerGramKelvin(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy KilojoulesPerKilogramDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static SpecificEntropy KilojoulesPerKilogramDegreeCelsius(this T value #endif => SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy KilojoulesPerKilogramKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static SpecificEntropy KilojoulesPerKilogramKelvin(this T value) #endif => SpecificEntropy.FromKilojoulesPerKilogramKelvin(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy MegajoulesPerKilogramDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static SpecificEntropy MegajoulesPerKilogramDegreeCelsius(this T value #endif => SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static SpecificEntropy MegajoulesPerKilogramKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificFuelConsumptionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificFuelConsumptionExtensions.g.cs index 0d6dc5a674..9d41c4be0a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificFuelConsumptionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificFuelConsumptionExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificFuelConsumption /// public static class NumberToSpecificFuelConsumptionExtensions { - /// + /// public static SpecificFuelConsumption GramsPerKiloNewtonSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static SpecificFuelConsumption GramsPerKiloNewtonSecond(this T value) #endif => SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(Convert.ToDouble(value)); - /// + /// public static SpecificFuelConsumption KilogramsPerKilogramForceHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static SpecificFuelConsumption KilogramsPerKilogramForceHour(this T va #endif => SpecificFuelConsumption.FromKilogramsPerKilogramForceHour(Convert.ToDouble(value)); - /// + /// public static SpecificFuelConsumption KilogramsPerKiloNewtonSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static SpecificFuelConsumption KilogramsPerKiloNewtonSecond(this T val #endif => SpecificFuelConsumption.FromKilogramsPerKiloNewtonSecond(Convert.ToDouble(value)); - /// + /// public static SpecificFuelConsumption PoundsMassPerPoundForceHour(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs index 786ff59b03..f16001700f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificVolume /// public static class NumberToSpecificVolumeExtensions { - /// + /// public static SpecificVolume CubicFeetPerPound(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static SpecificVolume CubicFeetPerPound(this T value) #endif => SpecificVolume.FromCubicFeetPerPound(Convert.ToDouble(value)); - /// + /// public static SpecificVolume CubicMetersPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static SpecificVolume CubicMetersPerKilogram(this T value) #endif => SpecificVolume.FromCubicMetersPerKilogram(Convert.ToDouble(value)); - /// + /// public static SpecificVolume MillicubicMetersPerKilogram(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs index 5a77413b77..7e59da6340 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificWeight /// public static class NumberToSpecificWeightExtensions { - /// + /// public static SpecificWeight KilogramsForcePerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static SpecificWeight KilogramsForcePerCubicCentimeter(this T value) #endif => SpecificWeight.FromKilogramsForcePerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilogramsForcePerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static SpecificWeight KilogramsForcePerCubicMeter(this T value) #endif => SpecificWeight.FromKilogramsForcePerCubicMeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilogramsForcePerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static SpecificWeight KilogramsForcePerCubicMillimeter(this T value) #endif => SpecificWeight.FromKilogramsForcePerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilonewtonsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static SpecificWeight KilonewtonsPerCubicCentimeter(this T value) #endif => SpecificWeight.FromKilonewtonsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilonewtonsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static SpecificWeight KilonewtonsPerCubicMeter(this T value) #endif => SpecificWeight.FromKilonewtonsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilonewtonsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static SpecificWeight KilonewtonsPerCubicMillimeter(this T value) #endif => SpecificWeight.FromKilonewtonsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilopoundsForcePerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static SpecificWeight KilopoundsForcePerCubicFoot(this T value) #endif => SpecificWeight.FromKilopoundsForcePerCubicFoot(Convert.ToDouble(value)); - /// + /// public static SpecificWeight KilopoundsForcePerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static SpecificWeight KilopoundsForcePerCubicInch(this T value) #endif => SpecificWeight.FromKilopoundsForcePerCubicInch(Convert.ToDouble(value)); - /// + /// public static SpecificWeight MeganewtonsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static SpecificWeight MeganewtonsPerCubicMeter(this T value) #endif => SpecificWeight.FromMeganewtonsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight NewtonsPerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static SpecificWeight NewtonsPerCubicCentimeter(this T value) #endif => SpecificWeight.FromNewtonsPerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight NewtonsPerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static SpecificWeight NewtonsPerCubicMeter(this T value) #endif => SpecificWeight.FromNewtonsPerCubicMeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight NewtonsPerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static SpecificWeight NewtonsPerCubicMillimeter(this T value) #endif => SpecificWeight.FromNewtonsPerCubicMillimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight PoundsForcePerCubicFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static SpecificWeight PoundsForcePerCubicFoot(this T value) #endif => SpecificWeight.FromPoundsForcePerCubicFoot(Convert.ToDouble(value)); - /// + /// public static SpecificWeight PoundsForcePerCubicInch(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static SpecificWeight PoundsForcePerCubicInch(this T value) #endif => SpecificWeight.FromPoundsForcePerCubicInch(Convert.ToDouble(value)); - /// + /// public static SpecificWeight TonnesForcePerCubicCentimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static SpecificWeight TonnesForcePerCubicCentimeter(this T value) #endif => SpecificWeight.FromTonnesForcePerCubicCentimeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight TonnesForcePerCubicMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static SpecificWeight TonnesForcePerCubicMeter(this T value) #endif => SpecificWeight.FromTonnesForcePerCubicMeter(Convert.ToDouble(value)); - /// + /// public static SpecificWeight TonnesForcePerCubicMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs index eacd11c94f..5c5e3d3a61 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToSpeed /// public static class NumberToSpeedExtensions { - /// + /// public static Speed CentimetersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Speed CentimetersPerHour(this T value) #endif => Speed.FromCentimetersPerHour(Convert.ToDouble(value)); - /// + /// public static Speed CentimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Speed CentimetersPerMinute(this T value) #endif => Speed.FromCentimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed CentimetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Speed CentimetersPerSecond(this T value) #endif => Speed.FromCentimetersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed DecimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Speed DecimetersPerMinute(this T value) #endif => Speed.FromDecimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed DecimetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Speed DecimetersPerSecond(this T value) #endif => Speed.FromDecimetersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed FeetPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Speed FeetPerHour(this T value) #endif => Speed.FromFeetPerHour(Convert.ToDouble(value)); - /// + /// public static Speed FeetPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Speed FeetPerMinute(this T value) #endif => Speed.FromFeetPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed FeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Speed FeetPerSecond(this T value) #endif => Speed.FromFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed InchesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Speed InchesPerHour(this T value) #endif => Speed.FromInchesPerHour(Convert.ToDouble(value)); - /// + /// public static Speed InchesPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Speed InchesPerMinute(this T value) #endif => Speed.FromInchesPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed InchesPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Speed InchesPerSecond(this T value) #endif => Speed.FromInchesPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed KilometersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Speed KilometersPerHour(this T value) #endif => Speed.FromKilometersPerHour(Convert.ToDouble(value)); - /// + /// public static Speed KilometersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Speed KilometersPerMinute(this T value) #endif => Speed.FromKilometersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed KilometersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Speed KilometersPerSecond(this T value) #endif => Speed.FromKilometersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed Knots(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Speed Knots(this T value) #endif => Speed.FromKnots(Convert.ToDouble(value)); - /// + /// public static Speed Mach(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Speed Mach(this T value) #endif => Speed.FromMach(Convert.ToDouble(value)); - /// + /// public static Speed MetersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Speed MetersPerHour(this T value) #endif => Speed.FromMetersPerHour(Convert.ToDouble(value)); - /// + /// public static Speed MetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Speed MetersPerMinute(this T value) #endif => Speed.FromMetersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed MetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Speed MetersPerSecond(this T value) #endif => Speed.FromMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed MicrometersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Speed MicrometersPerMinute(this T value) #endif => Speed.FromMicrometersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed MicrometersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Speed MicrometersPerSecond(this T value) #endif => Speed.FromMicrometersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed MilesPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Speed MilesPerHour(this T value) #endif => Speed.FromMilesPerHour(Convert.ToDouble(value)); - /// + /// public static Speed MillimetersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Speed MillimetersPerHour(this T value) #endif => Speed.FromMillimetersPerHour(Convert.ToDouble(value)); - /// + /// public static Speed MillimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Speed MillimetersPerMinute(this T value) #endif => Speed.FromMillimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed MillimetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Speed MillimetersPerSecond(this T value) #endif => Speed.FromMillimetersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed NanometersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Speed NanometersPerMinute(this T value) #endif => Speed.FromNanometersPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed NanometersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Speed NanometersPerSecond(this T value) #endif => Speed.FromNanometersPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed UsSurveyFeetPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Speed UsSurveyFeetPerHour(this T value) #endif => Speed.FromUsSurveyFeetPerHour(Convert.ToDouble(value)); - /// + /// public static Speed UsSurveyFeetPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Speed UsSurveyFeetPerMinute(this T value) #endif => Speed.FromUsSurveyFeetPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed UsSurveyFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Speed UsSurveyFeetPerSecond(this T value) #endif => Speed.FromUsSurveyFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static Speed YardsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Speed YardsPerHour(this T value) #endif => Speed.FromYardsPerHour(Convert.ToDouble(value)); - /// + /// public static Speed YardsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Speed YardsPerMinute(this T value) #endif => Speed.FromYardsPerMinute(Convert.ToDouble(value)); - /// + /// public static Speed YardsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToStandardVolumeFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToStandardVolumeFlowExtensions.g.cs index f16a65fe3b..a9a2f6cf88 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToStandardVolumeFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToStandardVolumeFlowExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToStandardVolumeFlow /// public static class NumberToStandardVolumeFlowExtensions { - /// + /// public static StandardVolumeFlow StandardCubicCentimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static StandardVolumeFlow StandardCubicCentimetersPerMinute(this T val #endif => StandardVolumeFlow.FromStandardCubicCentimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicFeetPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static StandardVolumeFlow StandardCubicFeetPerHour(this T value) #endif => StandardVolumeFlow.FromStandardCubicFeetPerHour(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicFeetPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static StandardVolumeFlow StandardCubicFeetPerMinute(this T value) #endif => StandardVolumeFlow.FromStandardCubicFeetPerMinute(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static StandardVolumeFlow StandardCubicFeetPerSecond(this T value) #endif => StandardVolumeFlow.FromStandardCubicFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicMetersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static StandardVolumeFlow StandardCubicMetersPerDay(this T value) #endif => StandardVolumeFlow.FromStandardCubicMetersPerDay(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicMetersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static StandardVolumeFlow StandardCubicMetersPerHour(this T value) #endif => StandardVolumeFlow.FromStandardCubicMetersPerHour(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicMetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static StandardVolumeFlow StandardCubicMetersPerMinute(this T value) #endif => StandardVolumeFlow.FromStandardCubicMetersPerMinute(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardCubicMetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static StandardVolumeFlow StandardCubicMetersPerSecond(this T value) #endif => StandardVolumeFlow.FromStandardCubicMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static StandardVolumeFlow StandardLitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs index c54cba19b9..572ba2bcb8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTemperatureChangeRate /// public static class NumberToTemperatureChangeRateExtensions { - /// + /// public static TemperatureChangeRate CentidegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static TemperatureChangeRate CentidegreesCelsiusPerSecond(this T value #endif => TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate DecadegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static TemperatureChangeRate DecadegreesCelsiusPerSecond(this T value) #endif => TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate DecidegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static TemperatureChangeRate DecidegreesCelsiusPerSecond(this T value) #endif => TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate DegreesCelsiusPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static TemperatureChangeRate DegreesCelsiusPerMinute(this T value) #endif => TemperatureChangeRate.FromDegreesCelsiusPerMinute(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate DegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static TemperatureChangeRate DegreesCelsiusPerSecond(this T value) #endif => TemperatureChangeRate.FromDegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate HectodegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static TemperatureChangeRate HectodegreesCelsiusPerSecond(this T value #endif => TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate KilodegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static TemperatureChangeRate KilodegreesCelsiusPerSecond(this T value) #endif => TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate MicrodegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static TemperatureChangeRate MicrodegreesCelsiusPerSecond(this T value #endif => TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate MillidegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static TemperatureChangeRate MillidegreesCelsiusPerSecond(this T value #endif => TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// + /// public static TemperatureChangeRate NanodegreesCelsiusPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs index 1411f8e573..63da7b0482 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTemperatureDelta /// public static class NumberToTemperatureDeltaExtensions { - /// + /// public static TemperatureDelta DegreesCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static TemperatureDelta DegreesCelsius(this T value) #endif => TemperatureDelta.FromDegreesCelsius(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesDelisle(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static TemperatureDelta DegreesDelisle(this T value) #endif => TemperatureDelta.FromDegreesDelisle(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static TemperatureDelta DegreesFahrenheit(this T value) #endif => TemperatureDelta.FromDegreesFahrenheit(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesNewton(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static TemperatureDelta DegreesNewton(this T value) #endif => TemperatureDelta.FromDegreesNewton(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesRankine(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static TemperatureDelta DegreesRankine(this T value) #endif => TemperatureDelta.FromDegreesRankine(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesReaumur(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static TemperatureDelta DegreesReaumur(this T value) #endif => TemperatureDelta.FromDegreesReaumur(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta DegreesRoemer(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static TemperatureDelta DegreesRoemer(this T value) #endif => TemperatureDelta.FromDegreesRoemer(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta Kelvins(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static TemperatureDelta Kelvins(this T value) #endif => TemperatureDelta.FromKelvins(Convert.ToDouble(value)); - /// + /// public static TemperatureDelta MillidegreesCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs index c49aa4c8a2..5608ab80d8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTemperature /// public static class NumberToTemperatureExtensions { - /// + /// public static Temperature DegreesCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Temperature DegreesCelsius(this T value) #endif => Temperature.FromDegreesCelsius(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesDelisle(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Temperature DegreesDelisle(this T value) #endif => Temperature.FromDegreesDelisle(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Temperature DegreesFahrenheit(this T value) #endif => Temperature.FromDegreesFahrenheit(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesNewton(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Temperature DegreesNewton(this T value) #endif => Temperature.FromDegreesNewton(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesRankine(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Temperature DegreesRankine(this T value) #endif => Temperature.FromDegreesRankine(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesReaumur(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Temperature DegreesReaumur(this T value) #endif => Temperature.FromDegreesReaumur(Convert.ToDouble(value)); - /// + /// public static Temperature DegreesRoemer(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Temperature DegreesRoemer(this T value) #endif => Temperature.FromDegreesRoemer(Convert.ToDouble(value)); - /// + /// public static Temperature Kelvins(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Temperature Kelvins(this T value) #endif => Temperature.FromKelvins(Convert.ToDouble(value)); - /// + /// public static Temperature MillidegreesCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Temperature MillidegreesCelsius(this T value) #endif => Temperature.FromMillidegreesCelsius(Convert.ToDouble(value)); - /// + /// public static Temperature SolarTemperatures(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureGradientExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureGradientExtensions.g.cs index 72f787a472..c25fb1cab5 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureGradientExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureGradientExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTemperatureGradient /// public static class NumberToTemperatureGradientExtensions { - /// + /// public static TemperatureGradient DegreesCelsiusPerKilometer(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static TemperatureGradient DegreesCelsiusPerKilometer(this T value) #endif => TemperatureGradient.FromDegreesCelsiusPerKilometer(Convert.ToDouble(value)); - /// + /// public static TemperatureGradient DegreesCelsiusPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static TemperatureGradient DegreesCelsiusPerMeter(this T value) #endif => TemperatureGradient.FromDegreesCelsiusPerMeter(Convert.ToDouble(value)); - /// + /// public static TemperatureGradient DegreesFahrenheitPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static TemperatureGradient DegreesFahrenheitPerFoot(this T value) #endif => TemperatureGradient.FromDegreesFahrenheitPerFoot(Convert.ToDouble(value)); - /// + /// public static TemperatureGradient KelvinsPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs index 1342e6ed08..e54f9ad81c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToThermalConductivity /// public static class NumberToThermalConductivityExtensions { - /// + /// public static ThermalConductivity BtusPerHourFootFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ThermalConductivity BtusPerHourFootFahrenheit(this T value) #endif => ThermalConductivity.FromBtusPerHourFootFahrenheit(Convert.ToDouble(value)); - /// + /// public static ThermalConductivity WattsPerMeterKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs index c2750af1da..8a7704fe6c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToThermalResistance /// public static class NumberToThermalResistanceExtensions { - /// + /// public static ThermalResistance HourSquareFeetDegreesFahrenheitPerBtu(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static ThermalResistance HourSquareFeetDegreesFahrenheitPerBtu(this T #endif => ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(Convert.ToDouble(value)); - /// + /// public static ThermalResistance SquareCentimeterHourDegreesCelsiusPerKilocalorie(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static ThermalResistance SquareCentimeterHourDegreesCelsiusPerKilocalorie #endif => ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(Convert.ToDouble(value)); - /// + /// public static ThermalResistance SquareCentimeterKelvinsPerWatt(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static ThermalResistance SquareCentimeterKelvinsPerWatt(this T value) #endif => ThermalResistance.FromSquareCentimeterKelvinsPerWatt(Convert.ToDouble(value)); - /// + /// public static ThermalResistance SquareMeterDegreesCelsiusPerWatt(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static ThermalResistance SquareMeterDegreesCelsiusPerWatt(this T value #endif => ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(Convert.ToDouble(value)); - /// + /// public static ThermalResistance SquareMeterKelvinsPerKilowatt(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static ThermalResistance SquareMeterKelvinsPerKilowatt(this T value) #endif => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(Convert.ToDouble(value)); - /// + /// public static ThermalResistance SquareMeterKelvinsPerWatt(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs index b3cee45718..805bc13fc1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTorque /// public static class NumberToTorqueExtensions { - /// + /// public static Torque GramForceCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Torque GramForceCentimeters(this T value) #endif => Torque.FromGramForceCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque GramForceMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Torque GramForceMeters(this T value) #endif => Torque.FromGramForceMeters(Convert.ToDouble(value)); - /// + /// public static Torque GramForceMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Torque GramForceMillimeters(this T value) #endif => Torque.FromGramForceMillimeters(Convert.ToDouble(value)); - /// + /// public static Torque KilogramForceCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Torque KilogramForceCentimeters(this T value) #endif => Torque.FromKilogramForceCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque KilogramForceMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Torque KilogramForceMeters(this T value) #endif => Torque.FromKilogramForceMeters(Convert.ToDouble(value)); - /// + /// public static Torque KilogramForceMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Torque KilogramForceMillimeters(this T value) #endif => Torque.FromKilogramForceMillimeters(Convert.ToDouble(value)); - /// + /// public static Torque KilonewtonCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Torque KilonewtonCentimeters(this T value) #endif => Torque.FromKilonewtonCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque KilonewtonMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Torque KilonewtonMeters(this T value) #endif => Torque.FromKilonewtonMeters(Convert.ToDouble(value)); - /// + /// public static Torque KilonewtonMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Torque KilonewtonMillimeters(this T value) #endif => Torque.FromKilonewtonMillimeters(Convert.ToDouble(value)); - /// + /// public static Torque KilopoundForceFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Torque KilopoundForceFeet(this T value) #endif => Torque.FromKilopoundForceFeet(Convert.ToDouble(value)); - /// + /// public static Torque KilopoundForceInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Torque KilopoundForceInches(this T value) #endif => Torque.FromKilopoundForceInches(Convert.ToDouble(value)); - /// + /// public static Torque MeganewtonCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Torque MeganewtonCentimeters(this T value) #endif => Torque.FromMeganewtonCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque MeganewtonMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Torque MeganewtonMeters(this T value) #endif => Torque.FromMeganewtonMeters(Convert.ToDouble(value)); - /// + /// public static Torque MeganewtonMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Torque MeganewtonMillimeters(this T value) #endif => Torque.FromMeganewtonMillimeters(Convert.ToDouble(value)); - /// + /// public static Torque MegapoundForceFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Torque MegapoundForceFeet(this T value) #endif => Torque.FromMegapoundForceFeet(Convert.ToDouble(value)); - /// + /// public static Torque MegapoundForceInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Torque MegapoundForceInches(this T value) #endif => Torque.FromMegapoundForceInches(Convert.ToDouble(value)); - /// + /// public static Torque NewtonCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Torque NewtonCentimeters(this T value) #endif => Torque.FromNewtonCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque NewtonMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Torque NewtonMeters(this T value) #endif => Torque.FromNewtonMeters(Convert.ToDouble(value)); - /// + /// public static Torque NewtonMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Torque NewtonMillimeters(this T value) #endif => Torque.FromNewtonMillimeters(Convert.ToDouble(value)); - /// + /// public static Torque PoundalFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Torque PoundalFeet(this T value) #endif => Torque.FromPoundalFeet(Convert.ToDouble(value)); - /// + /// public static Torque PoundForceFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Torque PoundForceFeet(this T value) #endif => Torque.FromPoundForceFeet(Convert.ToDouble(value)); - /// + /// public static Torque PoundForceInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Torque PoundForceInches(this T value) #endif => Torque.FromPoundForceInches(Convert.ToDouble(value)); - /// + /// public static Torque TonneForceCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Torque TonneForceCentimeters(this T value) #endif => Torque.FromTonneForceCentimeters(Convert.ToDouble(value)); - /// + /// public static Torque TonneForceMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Torque TonneForceMeters(this T value) #endif => Torque.FromTonneForceMeters(Convert.ToDouble(value)); - /// + /// public static Torque TonneForceMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs index c5d1cb1107..9a369805ce 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTorquePerLength /// public static class NumberToTorquePerLengthExtensions { - /// + /// public static TorquePerLength KilogramForceCentimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static TorquePerLength KilogramForceCentimetersPerMeter(this T value) #endif => TorquePerLength.FromKilogramForceCentimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilogramForceMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static TorquePerLength KilogramForceMetersPerMeter(this T value) #endif => TorquePerLength.FromKilogramForceMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilogramForceMillimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static TorquePerLength KilogramForceMillimetersPerMeter(this T value) #endif => TorquePerLength.FromKilogramForceMillimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilonewtonCentimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static TorquePerLength KilonewtonCentimetersPerMeter(this T value) #endif => TorquePerLength.FromKilonewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilonewtonMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static TorquePerLength KilonewtonMetersPerMeter(this T value) #endif => TorquePerLength.FromKilonewtonMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilonewtonMillimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static TorquePerLength KilonewtonMillimetersPerMeter(this T value) #endif => TorquePerLength.FromKilonewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilopoundForceFeetPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static TorquePerLength KilopoundForceFeetPerFoot(this T value) #endif => TorquePerLength.FromKilopoundForceFeetPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength KilopoundForceInchesPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static TorquePerLength KilopoundForceInchesPerFoot(this T value) #endif => TorquePerLength.FromKilopoundForceInchesPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength MeganewtonCentimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static TorquePerLength MeganewtonCentimetersPerMeter(this T value) #endif => TorquePerLength.FromMeganewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength MeganewtonMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static TorquePerLength MeganewtonMetersPerMeter(this T value) #endif => TorquePerLength.FromMeganewtonMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength MeganewtonMillimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static TorquePerLength MeganewtonMillimetersPerMeter(this T value) #endif => TorquePerLength.FromMeganewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength MegapoundForceFeetPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static TorquePerLength MegapoundForceFeetPerFoot(this T value) #endif => TorquePerLength.FromMegapoundForceFeetPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength MegapoundForceInchesPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static TorquePerLength MegapoundForceInchesPerFoot(this T value) #endif => TorquePerLength.FromMegapoundForceInchesPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength NewtonCentimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static TorquePerLength NewtonCentimetersPerMeter(this T value) #endif => TorquePerLength.FromNewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength NewtonMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static TorquePerLength NewtonMetersPerMeter(this T value) #endif => TorquePerLength.FromNewtonMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength NewtonMillimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static TorquePerLength NewtonMillimetersPerMeter(this T value) #endif => TorquePerLength.FromNewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength PoundForceFeetPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static TorquePerLength PoundForceFeetPerFoot(this T value) #endif => TorquePerLength.FromPoundForceFeetPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength PoundForceInchesPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static TorquePerLength PoundForceInchesPerFoot(this T value) #endif => TorquePerLength.FromPoundForceInchesPerFoot(Convert.ToDouble(value)); - /// + /// public static TorquePerLength TonneForceCentimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static TorquePerLength TonneForceCentimetersPerMeter(this T value) #endif => TorquePerLength.FromTonneForceCentimetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength TonneForceMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static TorquePerLength TonneForceMetersPerMeter(this T value) #endif => TorquePerLength.FromTonneForceMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static TorquePerLength TonneForceMillimetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs index a5f16f99cc..b232d3b1a3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToTurbidity /// public static class NumberToTurbidityExtensions { - /// + /// public static Turbidity NTU(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs index ff518abba9..e2c2418739 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVitaminA /// public static class NumberToVitaminAExtensions { - /// + /// public static VitaminA InternationalUnits(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs index d3faaab660..92992ee547 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolumeConcentration /// public static class NumberToVolumeConcentrationExtensions { - /// + /// public static VolumeConcentration CentilitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static VolumeConcentration CentilitersPerLiter(this T value) #endif => VolumeConcentration.FromCentilitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration CentilitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static VolumeConcentration CentilitersPerMililiter(this T value) #endif => VolumeConcentration.FromCentilitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration DecilitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static VolumeConcentration DecilitersPerLiter(this T value) #endif => VolumeConcentration.FromDecilitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration DecilitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static VolumeConcentration DecilitersPerMililiter(this T value) #endif => VolumeConcentration.FromDecilitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration DecimalFractions(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static VolumeConcentration DecimalFractions(this T value) #endif => VolumeConcentration.FromDecimalFractions(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration LitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static VolumeConcentration LitersPerLiter(this T value) #endif => VolumeConcentration.FromLitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration LitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static VolumeConcentration LitersPerMililiter(this T value) #endif => VolumeConcentration.FromLitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration MicrolitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static VolumeConcentration MicrolitersPerLiter(this T value) #endif => VolumeConcentration.FromMicrolitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration MicrolitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static VolumeConcentration MicrolitersPerMililiter(this T value) #endif => VolumeConcentration.FromMicrolitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration MillilitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static VolumeConcentration MillilitersPerLiter(this T value) #endif => VolumeConcentration.FromMillilitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration MillilitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static VolumeConcentration MillilitersPerMililiter(this T value) #endif => VolumeConcentration.FromMillilitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration NanolitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static VolumeConcentration NanolitersPerLiter(this T value) #endif => VolumeConcentration.FromNanolitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration NanolitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static VolumeConcentration NanolitersPerMililiter(this T value) #endif => VolumeConcentration.FromNanolitersPerMililiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PartsPerBillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static VolumeConcentration PartsPerBillion(this T value) #endif => VolumeConcentration.FromPartsPerBillion(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PartsPerMillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static VolumeConcentration PartsPerMillion(this T value) #endif => VolumeConcentration.FromPartsPerMillion(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PartsPerThousand(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static VolumeConcentration PartsPerThousand(this T value) #endif => VolumeConcentration.FromPartsPerThousand(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PartsPerTrillion(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static VolumeConcentration PartsPerTrillion(this T value) #endif => VolumeConcentration.FromPartsPerTrillion(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration Percent(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static VolumeConcentration Percent(this T value) #endif => VolumeConcentration.FromPercent(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PicolitersPerLiter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static VolumeConcentration PicolitersPerLiter(this T value) #endif => VolumeConcentration.FromPicolitersPerLiter(Convert.ToDouble(value)); - /// + /// public static VolumeConcentration PicolitersPerMililiter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs index c979f5644b..16064ac6c9 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolume /// public static class NumberToVolumeExtensions { - /// + /// public static Volume AcreFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static Volume AcreFeet(this T value) #endif => Volume.FromAcreFeet(Convert.ToDouble(value)); - /// + /// public static Volume AuTablespoons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static Volume AuTablespoons(this T value) #endif => Volume.FromAuTablespoons(Convert.ToDouble(value)); - /// + /// public static Volume BoardFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static Volume BoardFeet(this T value) #endif => Volume.FromBoardFeet(Convert.ToDouble(value)); - /// + /// public static Volume Centiliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static Volume Centiliters(this T value) #endif => Volume.FromCentiliters(Convert.ToDouble(value)); - /// + /// public static Volume CubicCentimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static Volume CubicCentimeters(this T value) #endif => Volume.FromCubicCentimeters(Convert.ToDouble(value)); - /// + /// public static Volume CubicDecimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static Volume CubicDecimeters(this T value) #endif => Volume.FromCubicDecimeters(Convert.ToDouble(value)); - /// + /// public static Volume CubicFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static Volume CubicFeet(this T value) #endif => Volume.FromCubicFeet(Convert.ToDouble(value)); - /// + /// public static Volume CubicHectometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static Volume CubicHectometers(this T value) #endif => Volume.FromCubicHectometers(Convert.ToDouble(value)); - /// + /// public static Volume CubicInches(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static Volume CubicInches(this T value) #endif => Volume.FromCubicInches(Convert.ToDouble(value)); - /// + /// public static Volume CubicKilometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static Volume CubicKilometers(this T value) #endif => Volume.FromCubicKilometers(Convert.ToDouble(value)); - /// + /// public static Volume CubicMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static Volume CubicMeters(this T value) #endif => Volume.FromCubicMeters(Convert.ToDouble(value)); - /// + /// public static Volume CubicMicrometers(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static Volume CubicMicrometers(this T value) #endif => Volume.FromCubicMicrometers(Convert.ToDouble(value)); - /// + /// public static Volume CubicMiles(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static Volume CubicMiles(this T value) #endif => Volume.FromCubicMiles(Convert.ToDouble(value)); - /// + /// public static Volume CubicMillimeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static Volume CubicMillimeters(this T value) #endif => Volume.FromCubicMillimeters(Convert.ToDouble(value)); - /// + /// public static Volume CubicYards(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static Volume CubicYards(this T value) #endif => Volume.FromCubicYards(Convert.ToDouble(value)); - /// + /// public static Volume Decaliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static Volume Decaliters(this T value) #endif => Volume.FromDecaliters(Convert.ToDouble(value)); - /// + /// public static Volume DecausGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static Volume DecausGallons(this T value) #endif => Volume.FromDecausGallons(Convert.ToDouble(value)); - /// + /// public static Volume Deciliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static Volume Deciliters(this T value) #endif => Volume.FromDeciliters(Convert.ToDouble(value)); - /// + /// public static Volume DeciusGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static Volume DeciusGallons(this T value) #endif => Volume.FromDeciusGallons(Convert.ToDouble(value)); - /// + /// public static Volume HectocubicFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static Volume HectocubicFeet(this T value) #endif => Volume.FromHectocubicFeet(Convert.ToDouble(value)); - /// + /// public static Volume HectocubicMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static Volume HectocubicMeters(this T value) #endif => Volume.FromHectocubicMeters(Convert.ToDouble(value)); - /// + /// public static Volume Hectoliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,7 @@ public static Volume Hectoliters(this T value) #endif => Volume.FromHectoliters(Convert.ToDouble(value)); - /// + /// public static Volume HectousGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +216,7 @@ public static Volume HectousGallons(this T value) #endif => Volume.FromHectousGallons(Convert.ToDouble(value)); - /// + /// public static Volume ImperialBeerBarrels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +224,7 @@ public static Volume ImperialBeerBarrels(this T value) #endif => Volume.FromImperialBeerBarrels(Convert.ToDouble(value)); - /// + /// public static Volume ImperialGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +232,7 @@ public static Volume ImperialGallons(this T value) #endif => Volume.FromImperialGallons(Convert.ToDouble(value)); - /// + /// public static Volume ImperialOunces(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +240,7 @@ public static Volume ImperialOunces(this T value) #endif => Volume.FromImperialOunces(Convert.ToDouble(value)); - /// + /// public static Volume ImperialPints(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +248,7 @@ public static Volume ImperialPints(this T value) #endif => Volume.FromImperialPints(Convert.ToDouble(value)); - /// + /// public static Volume ImperialQuarts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +256,7 @@ public static Volume ImperialQuarts(this T value) #endif => Volume.FromImperialQuarts(Convert.ToDouble(value)); - /// + /// public static Volume KilocubicFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +264,7 @@ public static Volume KilocubicFeet(this T value) #endif => Volume.FromKilocubicFeet(Convert.ToDouble(value)); - /// + /// public static Volume KilocubicMeters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +272,7 @@ public static Volume KilocubicMeters(this T value) #endif => Volume.FromKilocubicMeters(Convert.ToDouble(value)); - /// + /// public static Volume KiloimperialGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +280,7 @@ public static Volume KiloimperialGallons(this T value) #endif => Volume.FromKiloimperialGallons(Convert.ToDouble(value)); - /// + /// public static Volume Kiloliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +288,7 @@ public static Volume Kiloliters(this T value) #endif => Volume.FromKiloliters(Convert.ToDouble(value)); - /// + /// public static Volume KilousGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +296,7 @@ public static Volume KilousGallons(this T value) #endif => Volume.FromKilousGallons(Convert.ToDouble(value)); - /// + /// public static Volume Liters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +304,7 @@ public static Volume Liters(this T value) #endif => Volume.FromLiters(Convert.ToDouble(value)); - /// + /// public static Volume MegacubicFeet(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +312,7 @@ public static Volume MegacubicFeet(this T value) #endif => Volume.FromMegacubicFeet(Convert.ToDouble(value)); - /// + /// public static Volume MegaimperialGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +320,7 @@ public static Volume MegaimperialGallons(this T value) #endif => Volume.FromMegaimperialGallons(Convert.ToDouble(value)); - /// + /// public static Volume Megaliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +328,7 @@ public static Volume Megaliters(this T value) #endif => Volume.FromMegaliters(Convert.ToDouble(value)); - /// + /// public static Volume MegausGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +336,7 @@ public static Volume MegausGallons(this T value) #endif => Volume.FromMegausGallons(Convert.ToDouble(value)); - /// + /// public static Volume MetricCups(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +344,7 @@ public static Volume MetricCups(this T value) #endif => Volume.FromMetricCups(Convert.ToDouble(value)); - /// + /// public static Volume MetricTeaspoons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +352,7 @@ public static Volume MetricTeaspoons(this T value) #endif => Volume.FromMetricTeaspoons(Convert.ToDouble(value)); - /// + /// public static Volume Microliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +360,7 @@ public static Volume Microliters(this T value) #endif => Volume.FromMicroliters(Convert.ToDouble(value)); - /// + /// public static Volume Milliliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +368,7 @@ public static Volume Milliliters(this T value) #endif => Volume.FromMilliliters(Convert.ToDouble(value)); - /// + /// public static Volume Nanoliters(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +376,7 @@ public static Volume Nanoliters(this T value) #endif => Volume.FromNanoliters(Convert.ToDouble(value)); - /// + /// public static Volume OilBarrels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -384,7 +384,7 @@ public static Volume OilBarrels(this T value) #endif => Volume.FromOilBarrels(Convert.ToDouble(value)); - /// + /// public static Volume UkTablespoons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -392,7 +392,7 @@ public static Volume UkTablespoons(this T value) #endif => Volume.FromUkTablespoons(Convert.ToDouble(value)); - /// + /// public static Volume UsBeerBarrels(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -400,7 +400,7 @@ public static Volume UsBeerBarrels(this T value) #endif => Volume.FromUsBeerBarrels(Convert.ToDouble(value)); - /// + /// public static Volume UsCustomaryCups(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -408,7 +408,7 @@ public static Volume UsCustomaryCups(this T value) #endif => Volume.FromUsCustomaryCups(Convert.ToDouble(value)); - /// + /// public static Volume UsGallons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -416,7 +416,7 @@ public static Volume UsGallons(this T value) #endif => Volume.FromUsGallons(Convert.ToDouble(value)); - /// + /// public static Volume UsLegalCups(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -424,7 +424,7 @@ public static Volume UsLegalCups(this T value) #endif => Volume.FromUsLegalCups(Convert.ToDouble(value)); - /// + /// public static Volume UsOunces(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -432,7 +432,7 @@ public static Volume UsOunces(this T value) #endif => Volume.FromUsOunces(Convert.ToDouble(value)); - /// + /// public static Volume UsPints(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -440,7 +440,7 @@ public static Volume UsPints(this T value) #endif => Volume.FromUsPints(Convert.ToDouble(value)); - /// + /// public static Volume UsQuarts(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -448,7 +448,7 @@ public static Volume UsQuarts(this T value) #endif => Volume.FromUsQuarts(Convert.ToDouble(value)); - /// + /// public static Volume UsTablespoons(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -456,7 +456,7 @@ public static Volume UsTablespoons(this T value) #endif => Volume.FromUsTablespoons(Convert.ToDouble(value)); - /// + /// public static Volume UsTeaspoons(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs index 0640c22d9f..d9669438ba 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolumeFlow /// public static class NumberToVolumeFlowExtensions { - /// + /// public static VolumeFlow AcreFeetPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static VolumeFlow AcreFeetPerDay(this T value) #endif => VolumeFlow.FromAcreFeetPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow AcreFeetPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static VolumeFlow AcreFeetPerHour(this T value) #endif => VolumeFlow.FromAcreFeetPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow AcreFeetPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static VolumeFlow AcreFeetPerMinute(this T value) #endif => VolumeFlow.FromAcreFeetPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow AcreFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static VolumeFlow AcreFeetPerSecond(this T value) #endif => VolumeFlow.FromAcreFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CentilitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static VolumeFlow CentilitersPerDay(this T value) #endif => VolumeFlow.FromCentilitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CentilitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static VolumeFlow CentilitersPerHour(this T value) #endif => VolumeFlow.FromCentilitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CentilitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static VolumeFlow CentilitersPerMinute(this T value) #endif => VolumeFlow.FromCentilitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CentilitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static VolumeFlow CentilitersPerSecond(this T value) #endif => VolumeFlow.FromCentilitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicCentimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -104,7 +104,7 @@ public static VolumeFlow CubicCentimetersPerMinute(this T value) #endif => VolumeFlow.FromCubicCentimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicDecimetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -112,7 +112,7 @@ public static VolumeFlow CubicDecimetersPerMinute(this T value) #endif => VolumeFlow.FromCubicDecimetersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicFeetPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -120,7 +120,7 @@ public static VolumeFlow CubicFeetPerHour(this T value) #endif => VolumeFlow.FromCubicFeetPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicFeetPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -128,7 +128,7 @@ public static VolumeFlow CubicFeetPerMinute(this T value) #endif => VolumeFlow.FromCubicFeetPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicFeetPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -136,7 +136,7 @@ public static VolumeFlow CubicFeetPerSecond(this T value) #endif => VolumeFlow.FromCubicFeetPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicMetersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -144,7 +144,7 @@ public static VolumeFlow CubicMetersPerDay(this T value) #endif => VolumeFlow.FromCubicMetersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicMetersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -152,7 +152,7 @@ public static VolumeFlow CubicMetersPerHour(this T value) #endif => VolumeFlow.FromCubicMetersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicMetersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -160,7 +160,7 @@ public static VolumeFlow CubicMetersPerMinute(this T value) #endif => VolumeFlow.FromCubicMetersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicMetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -168,7 +168,7 @@ public static VolumeFlow CubicMetersPerSecond(this T value) #endif => VolumeFlow.FromCubicMetersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicMillimetersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -176,7 +176,7 @@ public static VolumeFlow CubicMillimetersPerSecond(this T value) #endif => VolumeFlow.FromCubicMillimetersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicYardsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -184,7 +184,7 @@ public static VolumeFlow CubicYardsPerDay(this T value) #endif => VolumeFlow.FromCubicYardsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicYardsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -192,7 +192,7 @@ public static VolumeFlow CubicYardsPerHour(this T value) #endif => VolumeFlow.FromCubicYardsPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicYardsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -200,7 +200,7 @@ public static VolumeFlow CubicYardsPerMinute(this T value) #endif => VolumeFlow.FromCubicYardsPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow CubicYardsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -208,7 +208,39 @@ public static VolumeFlow CubicYardsPerSecond(this T value) #endif => VolumeFlow.FromCubicYardsPerSecond(Convert.ToDouble(value)); - /// + /// + public static VolumeFlow DecalitersPerDay(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromDecalitersPerDay(Convert.ToDouble(value)); + + /// + public static VolumeFlow DecalitersPerHour(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromDecalitersPerHour(Convert.ToDouble(value)); + + /// + public static VolumeFlow DecalitersPerMinute(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromDecalitersPerMinute(Convert.ToDouble(value)); + + /// + public static VolumeFlow DecalitersPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromDecalitersPerSecond(Convert.ToDouble(value)); + + /// public static VolumeFlow DecilitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -216,7 +248,7 @@ public static VolumeFlow DecilitersPerDay(this T value) #endif => VolumeFlow.FromDecilitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow DecilitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -224,7 +256,7 @@ public static VolumeFlow DecilitersPerHour(this T value) #endif => VolumeFlow.FromDecilitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow DecilitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -232,7 +264,7 @@ public static VolumeFlow DecilitersPerMinute(this T value) #endif => VolumeFlow.FromDecilitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow DecilitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -240,7 +272,39 @@ public static VolumeFlow DecilitersPerSecond(this T value) #endif => VolumeFlow.FromDecilitersPerSecond(Convert.ToDouble(value)); - /// + /// + public static VolumeFlow HectolitersPerDay(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromHectolitersPerDay(Convert.ToDouble(value)); + + /// + public static VolumeFlow HectolitersPerHour(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromHectolitersPerHour(Convert.ToDouble(value)); + + /// + public static VolumeFlow HectolitersPerMinute(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromHectolitersPerMinute(Convert.ToDouble(value)); + + /// + public static VolumeFlow HectolitersPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => VolumeFlow.FromHectolitersPerSecond(Convert.ToDouble(value)); + + /// public static VolumeFlow KilolitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -248,7 +312,7 @@ public static VolumeFlow KilolitersPerDay(this T value) #endif => VolumeFlow.FromKilolitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow KilolitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -256,7 +320,7 @@ public static VolumeFlow KilolitersPerHour(this T value) #endif => VolumeFlow.FromKilolitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow KilolitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -264,7 +328,7 @@ public static VolumeFlow KilolitersPerMinute(this T value) #endif => VolumeFlow.FromKilolitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow KilolitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -272,7 +336,7 @@ public static VolumeFlow KilolitersPerSecond(this T value) #endif => VolumeFlow.FromKilolitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow KilousGallonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -280,7 +344,7 @@ public static VolumeFlow KilousGallonsPerMinute(this T value) #endif => VolumeFlow.FromKilousGallonsPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow LitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -288,7 +352,7 @@ public static VolumeFlow LitersPerDay(this T value) #endif => VolumeFlow.FromLitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow LitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -296,7 +360,7 @@ public static VolumeFlow LitersPerHour(this T value) #endif => VolumeFlow.FromLitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow LitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -304,7 +368,7 @@ public static VolumeFlow LitersPerMinute(this T value) #endif => VolumeFlow.FromLitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow LitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -312,7 +376,7 @@ public static VolumeFlow LitersPerSecond(this T value) #endif => VolumeFlow.FromLitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegalitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -320,7 +384,7 @@ public static VolumeFlow MegalitersPerDay(this T value) #endif => VolumeFlow.FromMegalitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegalitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -328,7 +392,7 @@ public static VolumeFlow MegalitersPerHour(this T value) #endif => VolumeFlow.FromMegalitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegalitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -336,7 +400,7 @@ public static VolumeFlow MegalitersPerMinute(this T value) #endif => VolumeFlow.FromMegalitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegalitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -344,7 +408,7 @@ public static VolumeFlow MegalitersPerSecond(this T value) #endif => VolumeFlow.FromMegalitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegaukGallonsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -352,7 +416,7 @@ public static VolumeFlow MegaukGallonsPerDay(this T value) #endif => VolumeFlow.FromMegaukGallonsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegaukGallonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -360,7 +424,7 @@ public static VolumeFlow MegaukGallonsPerSecond(this T value) #endif => VolumeFlow.FromMegaukGallonsPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MegausGallonsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -368,7 +432,7 @@ public static VolumeFlow MegausGallonsPerDay(this T value) #endif => VolumeFlow.FromMegausGallonsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MicrolitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -376,7 +440,7 @@ public static VolumeFlow MicrolitersPerDay(this T value) #endif => VolumeFlow.FromMicrolitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MicrolitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -384,7 +448,7 @@ public static VolumeFlow MicrolitersPerHour(this T value) #endif => VolumeFlow.FromMicrolitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MicrolitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -392,7 +456,7 @@ public static VolumeFlow MicrolitersPerMinute(this T value) #endif => VolumeFlow.FromMicrolitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MicrolitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -400,7 +464,7 @@ public static VolumeFlow MicrolitersPerSecond(this T value) #endif => VolumeFlow.FromMicrolitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MillilitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -408,7 +472,7 @@ public static VolumeFlow MillilitersPerDay(this T value) #endif => VolumeFlow.FromMillilitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MillilitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -416,7 +480,7 @@ public static VolumeFlow MillilitersPerHour(this T value) #endif => VolumeFlow.FromMillilitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MillilitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -424,7 +488,7 @@ public static VolumeFlow MillilitersPerMinute(this T value) #endif => VolumeFlow.FromMillilitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MillilitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -432,7 +496,7 @@ public static VolumeFlow MillilitersPerSecond(this T value) #endif => VolumeFlow.FromMillilitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow MillionUsGallonsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -440,7 +504,7 @@ public static VolumeFlow MillionUsGallonsPerDay(this T value) #endif => VolumeFlow.FromMillionUsGallonsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow NanolitersPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -448,7 +512,7 @@ public static VolumeFlow NanolitersPerDay(this T value) #endif => VolumeFlow.FromNanolitersPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow NanolitersPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -456,7 +520,7 @@ public static VolumeFlow NanolitersPerHour(this T value) #endif => VolumeFlow.FromNanolitersPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow NanolitersPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -464,7 +528,7 @@ public static VolumeFlow NanolitersPerMinute(this T value) #endif => VolumeFlow.FromNanolitersPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow NanolitersPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -472,7 +536,7 @@ public static VolumeFlow NanolitersPerSecond(this T value) #endif => VolumeFlow.FromNanolitersPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow OilBarrelsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -480,7 +544,7 @@ public static VolumeFlow OilBarrelsPerDay(this T value) #endif => VolumeFlow.FromOilBarrelsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow OilBarrelsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -488,7 +552,7 @@ public static VolumeFlow OilBarrelsPerHour(this T value) #endif => VolumeFlow.FromOilBarrelsPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow OilBarrelsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -496,7 +560,7 @@ public static VolumeFlow OilBarrelsPerMinute(this T value) #endif => VolumeFlow.FromOilBarrelsPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow OilBarrelsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -504,7 +568,7 @@ public static VolumeFlow OilBarrelsPerSecond(this T value) #endif => VolumeFlow.FromOilBarrelsPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UkGallonsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -512,7 +576,7 @@ public static VolumeFlow UkGallonsPerDay(this T value) #endif => VolumeFlow.FromUkGallonsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UkGallonsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -520,7 +584,7 @@ public static VolumeFlow UkGallonsPerHour(this T value) #endif => VolumeFlow.FromUkGallonsPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UkGallonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -528,7 +592,7 @@ public static VolumeFlow UkGallonsPerMinute(this T value) #endif => VolumeFlow.FromUkGallonsPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UkGallonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -536,7 +600,7 @@ public static VolumeFlow UkGallonsPerSecond(this T value) #endif => VolumeFlow.FromUkGallonsPerSecond(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UsGallonsPerDay(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -544,7 +608,7 @@ public static VolumeFlow UsGallonsPerDay(this T value) #endif => VolumeFlow.FromUsGallonsPerDay(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UsGallonsPerHour(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -552,7 +616,7 @@ public static VolumeFlow UsGallonsPerHour(this T value) #endif => VolumeFlow.FromUsGallonsPerHour(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UsGallonsPerMinute(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -560,7 +624,7 @@ public static VolumeFlow UsGallonsPerMinute(this T value) #endif => VolumeFlow.FromUsGallonsPerMinute(Convert.ToDouble(value)); - /// + /// public static VolumeFlow UsGallonsPerSecond(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowPerAreaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowPerAreaExtensions.g.cs index a51f32978a..cf1683c949 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowPerAreaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowPerAreaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolumeFlowPerArea /// public static class NumberToVolumeFlowPerAreaExtensions { - /// + /// public static VolumeFlowPerArea CubicFeetPerMinutePerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static VolumeFlowPerArea CubicFeetPerMinutePerSquareFoot(this T value) #endif => VolumeFlowPerArea.FromCubicFeetPerMinutePerSquareFoot(Convert.ToDouble(value)); - /// + /// public static VolumeFlowPerArea CubicMetersPerSecondPerSquareMeter(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs index c464b0668a..ee32761053 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolumePerLength /// public static class NumberToVolumePerLengthExtensions { - /// + /// public static VolumePerLength CubicMetersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static VolumePerLength CubicMetersPerMeter(this T value) #endif => VolumePerLength.FromCubicMetersPerMeter(Convert.ToDouble(value)); - /// + /// public static VolumePerLength CubicYardsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static VolumePerLength CubicYardsPerFoot(this T value) #endif => VolumePerLength.FromCubicYardsPerFoot(Convert.ToDouble(value)); - /// + /// public static VolumePerLength CubicYardsPerUsSurveyFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static VolumePerLength CubicYardsPerUsSurveyFoot(this T value) #endif => VolumePerLength.FromCubicYardsPerUsSurveyFoot(Convert.ToDouble(value)); - /// + /// public static VolumePerLength ImperialGallonsPerMile(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static VolumePerLength ImperialGallonsPerMile(this T value) #endif => VolumePerLength.FromImperialGallonsPerMile(Convert.ToDouble(value)); - /// + /// public static VolumePerLength LitersPerKilometer(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static VolumePerLength LitersPerKilometer(this T value) #endif => VolumePerLength.FromLitersPerKilometer(Convert.ToDouble(value)); - /// + /// public static VolumePerLength LitersPerMeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static VolumePerLength LitersPerMeter(this T value) #endif => VolumePerLength.FromLitersPerMeter(Convert.ToDouble(value)); - /// + /// public static VolumePerLength LitersPerMillimeter(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static VolumePerLength LitersPerMillimeter(this T value) #endif => VolumePerLength.FromLitersPerMillimeter(Convert.ToDouble(value)); - /// + /// public static VolumePerLength OilBarrelsPerFoot(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static VolumePerLength OilBarrelsPerFoot(this T value) #endif => VolumePerLength.FromOilBarrelsPerFoot(Convert.ToDouble(value)); - /// + /// public static VolumePerLength UsGallonsPerMile(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumetricHeatCapacityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumetricHeatCapacityExtensions.g.cs index 14f3017903..096580b0d2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumetricHeatCapacityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumetricHeatCapacityExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToVolumetricHeatCapacity /// public static class NumberToVolumetricHeatCapacityExtensions { - /// + /// public static VolumetricHeatCapacity BtusPerCubicFootDegreeFahrenheit(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static VolumetricHeatCapacity BtusPerCubicFootDegreeFahrenheit(this T #endif => VolumetricHeatCapacity.FromBtusPerCubicFootDegreeFahrenheit(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity CaloriesPerCubicCentimeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static VolumetricHeatCapacity CaloriesPerCubicCentimeterDegreeCelsius( #endif => VolumetricHeatCapacity.FromCaloriesPerCubicCentimeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity JoulesPerCubicMeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static VolumetricHeatCapacity JoulesPerCubicMeterDegreeCelsius(this T #endif => VolumetricHeatCapacity.FromJoulesPerCubicMeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity JoulesPerCubicMeterKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static VolumetricHeatCapacity JoulesPerCubicMeterKelvin(this T value) #endif => VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity KilocaloriesPerCubicCentimeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static VolumetricHeatCapacity KilocaloriesPerCubicCentimeterDegreeCelsius #endif => VolumetricHeatCapacity.FromKilocaloriesPerCubicCentimeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity KilojoulesPerCubicMeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -80,7 +80,7 @@ public static VolumetricHeatCapacity KilojoulesPerCubicMeterDegreeCelsius(thi #endif => VolumetricHeatCapacity.FromKilojoulesPerCubicMeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity KilojoulesPerCubicMeterKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -88,7 +88,7 @@ public static VolumetricHeatCapacity KilojoulesPerCubicMeterKelvin(this T val #endif => VolumetricHeatCapacity.FromKilojoulesPerCubicMeterKelvin(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity MegajoulesPerCubicMeterDegreeCelsius(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -96,7 +96,7 @@ public static VolumetricHeatCapacity MegajoulesPerCubicMeterDegreeCelsius(thi #endif => VolumetricHeatCapacity.FromMegajoulesPerCubicMeterDegreeCelsius(Convert.ToDouble(value)); - /// + /// public static VolumetricHeatCapacity MegajoulesPerCubicMeterKelvin(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs index 7979daed07..4269caa699 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs @@ -32,7 +32,7 @@ namespace UnitsNet.NumberExtensions.NumberToWarpingMomentOfInertia /// public static class NumberToWarpingMomentOfInertiaExtensions { - /// + /// public static WarpingMomentOfInertia CentimetersToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -40,7 +40,7 @@ public static WarpingMomentOfInertia CentimetersToTheSixth(this T value) #endif => WarpingMomentOfInertia.FromCentimetersToTheSixth(Convert.ToDouble(value)); - /// + /// public static WarpingMomentOfInertia DecimetersToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -48,7 +48,7 @@ public static WarpingMomentOfInertia DecimetersToTheSixth(this T value) #endif => WarpingMomentOfInertia.FromDecimetersToTheSixth(Convert.ToDouble(value)); - /// + /// public static WarpingMomentOfInertia FeetToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -56,7 +56,7 @@ public static WarpingMomentOfInertia FeetToTheSixth(this T value) #endif => WarpingMomentOfInertia.FromFeetToTheSixth(Convert.ToDouble(value)); - /// + /// public static WarpingMomentOfInertia InchesToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -64,7 +64,7 @@ public static WarpingMomentOfInertia InchesToTheSixth(this T value) #endif => WarpingMomentOfInertia.FromInchesToTheSixth(Convert.ToDouble(value)); - /// + /// public static WarpingMomentOfInertia MetersToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER @@ -72,7 +72,7 @@ public static WarpingMomentOfInertia MetersToTheSixth(this T value) #endif => WarpingMomentOfInertia.FromMetersToTheSixth(Convert.ToDouble(value)); - /// + /// public static WarpingMomentOfInertia MillimetersToTheSixth(this T value) where T : notnull #if NET7_0_OR_GREATER diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index ba02d95392..7511cb0810 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 6.0.0-pre002 + 6.0.0-pre006 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). @@ -12,7 +12,7 @@ logo-32.png https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png https://github.com/angularsen/UnitsNet - MIT + MIT-0 false UnitsNet Extensions NumberToExtensions NumberToUnitsExtensions NumberExtensions NumberToUnits convert conversion parse @@ -22,7 +22,7 @@ latest enable UnitsNet - netstandard2.0;net7.0 + netstandard2.0;net8.0 diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index 6bf0289d9d..17e328ca10 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -14,9 +14,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index 1eafb78ba5..e51fddc1de 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -33,7 +33,7 @@ public class AbbreviatedUnitsConverter : JsonConverter private readonly UnitParser _unitParser; /// - /// Construct a converter using the default list of quantities (case insensitive) and unit abbreviation provider + /// Construct a converter using the default list of quantities (case-insensitive) and unit abbreviation provider /// public AbbreviatedUnitsConverter() : this(StringComparer.OrdinalIgnoreCase) @@ -77,19 +77,55 @@ public override void WriteJson(JsonWriter writer, IQuantity? quantity, JsonSeria writer.WriteStartObject(); - // write the 'Value' using the actual type + WriteValueProperty(writer, quantity); + WriteUnitProperty(writer, unit); + WriteTypeProperty(writer, quantityType); + + writer.WriteEndObject(); + } + + /// + /// Writes the 'Value' property using the actual type. + /// + /// The JsonWriter to write to. + /// The quantity to write. + /// + /// This method can be overridden to customize the payload type or format. For example, you can use a decimal or + /// Fraction instead of a double. + /// + protected virtual void WriteValueProperty(JsonWriter writer, IQuantity quantity) + { writer.WritePropertyName(ValueProperty); - writer.WriteValue((double)quantity.Value); + // writer.WriteValue((double)quantity.Value); + writer.WriteRawValue(quantity.Value.ToString("R")); + } - // write the 'Unit' abbreviation + /// + /// Writes the 'Unit' property. + /// + /// The JsonWriter to write to. + /// The unit to write. + /// + /// This method can be overridden to customize the payload type or format. + /// + protected virtual void WriteUnitProperty(JsonWriter writer, string unit) + { writer.WritePropertyName(UnitProperty); writer.WriteValue(unit); + } - // write the quantity 'Type' + /// + /// Writes the 'Type' property. + /// + /// The JsonWriter to write to. + /// The quantity type to write. + /// + /// This method can be overridden to customize the payload type or format. + /// + protected virtual void WriteTypeProperty(JsonWriter writer, string quantityType) + { writer.WritePropertyName(TypeProperty); writer.WriteValue(quantityType); - - writer.WriteEndObject(); } /// @@ -164,31 +200,31 @@ protected string GetQuantityType(IQuantity quantity) unit = GetUnitOrDefault(unitAbbreviation, quantityInfo); } - double value; + QuantityValue value; if (valueToken is null) { value = default; } else { - value = double.Parse(valueToken, CultureInfo.InvariantCulture); + value = QuantityValue.Parse(valueToken, CultureInfo.InvariantCulture); } return Quantity.From(value, unit); } /// - /// Attempt to find an a unique (non-ambiguous) unit matching the provided abbreviation. - /// - /// An exhaustive search using all quantities is very likely to fail with an - /// , so make sure you're using the minimum set of supported quantities. - /// + /// Attempts to find a unique (non-ambiguous) unit matching the provided abbreviation. /// - /// The unit abbreviation - /// The quantity type where the resulting unit was found - /// The unit associated with the given - /// - /// + /// + /// An exhaustive search using all quantities is very likely to fail with an + /// , so make sure you're using the minimum set of supported quantities. + /// + /// The unit abbreviation. + /// The quantity type where the resulting unit was found. + /// The unit associated with the given . + /// Thrown when the abbreviation is ambiguous. + /// Thrown when the unit is not found. protected virtual Enum FindUnit(string unitAbbreviation, out QuantityInfo quantityInfo) { if (unitAbbreviation is null) // we could assume string.Empty instead @@ -198,9 +234,9 @@ protected virtual Enum FindUnit(string unitAbbreviation, out QuantityInfo quanti Enum? unit = null; QuantityInfo? tempQuantityInfo = default; - foreach (var targetQuantity in _quantities.Values) + foreach (QuantityInfo targetQuantity in _quantities.Values) { - if (!TryParse(unitAbbreviation, targetQuantity, out var unitMatched)) + if (!TryParse(unitAbbreviation, targetQuantity, out Enum? unitMatched)) { continue; } @@ -311,7 +347,7 @@ protected bool TryGetQuantity(string quantityName, [NotNullWhen(true)] out Quant /// Quantity not found exception is thrown if no match found protected QuantityInfo GetQuantityInfo(string quantityName) { - if (!TryGetQuantity(quantityName, out var quantityInfo)) + if (!TryGetQuantity(quantityName, out QuantityInfo? quantityInfo)) { throw new UnitsNetException($"Failed to find the quantity type: {quantityName}.") { Data = { ["type"] = quantityName } }; } diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index dd9fb58820..8c924ab00e 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -2,7 +2,7 @@ UnitsNet.Serialization.JsonNet - 6.0.0-pre002 + 6.0.0-pre006 Andreas Gullberg Larsen Units.NET Serialization with Json.NET A helper library for serializing and deserializing types in Units.NET using Json.NET. @@ -12,7 +12,7 @@ logo-32.png https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png https://github.com/angularsen/UnitsNet - MIT + MIT-0 false unit units measurement json Json.NET Newtonsoft serialize deserialize serialization deserialization Upgrade JSON.NET to 12.0.3. Support arrays. @@ -48,9 +48,9 @@ - - - + + + diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 6e9d2940bd..cfe44fbc7e 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Concurrent; -using System.Globalization; using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -21,7 +20,7 @@ public abstract class UnitsNetBaseJsonConverter : JsonConverter /// /// Register custom types so that the converter can instantiate these quantities. - /// Instead of calling , the will be used to instantiate the object. + /// Instead of calling , the will be used to instantiate the object. /// It is therefore assumed that the constructor of is specified with new T(double value, typeof() unit). /// Registering the same multiple times, it will overwrite the one registered. /// @@ -92,10 +91,10 @@ protected IQuantity ConvertValueUnit(ValueUnit valueUnit) if (registeredQuantity is not null) { - return (IQuantity)Activator.CreateInstance(registeredQuantity, valueUnit.Value, unit); + return (IQuantity)Activator.CreateInstance(registeredQuantity, (QuantityValue)valueUnit.Value, unit); } - return Quantity.From(valueUnit.Value, unit); + return Quantity.From(QuantityValue.FromDoubleRounded(valueUnit.Value), unit); } private (Type? Quantity, Type? Unit) GetRegisteredType(string unit) diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs index d052adfeec..c481cf1385 100644 --- a/UnitsNet.Tests/AssertEx.cs +++ b/UnitsNet.Tests/AssertEx.cs @@ -8,22 +8,40 @@ namespace UnitsNet.Tests /// public static class AssertEx { - public static void EqualTolerance(double expected, double actual, double tolerance, ComparisonType comparisonType = ComparisonType.Relative) + public static void EqualTolerance(QuantityValue expected, QuantityValue actual, QuantityValue tolerance, ComparisonType comparisonType = ComparisonType.Relative) { if (comparisonType == ComparisonType.Relative) { - bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); + var areEqual = QuantityValueComparison.EqualsRelative(expected, actual, tolerance); + + var difference = QuantityValue.Abs(expected - actual).ToDouble(); + var relativeDifference = difference / expected.ToDouble(); - double difference = Math.Abs(expected - actual); - double relativeDifference = difference / expected; - - Assert.True( areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}" ); + Assert.True( areEqual, $"Values are not equal within relative tolerance: {tolerance.ToDouble():P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}" ); } else if (comparisonType == ComparisonType.Absolute) { - bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); + var areEqual = QuantityValueComparison.EqualsAbsolute(expected, actual, tolerance); Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); } } + + // public static void EqualTolerance(double expected, double actual, double tolerance, ComparisonType comparisonType = ComparisonType.Relative) + // { + // if (comparisonType == ComparisonType.Relative) + // { + // bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); + // + // double difference = Math.Abs(expected - actual); + // double relativeDifference = difference / expected; + // + // Assert.True( areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}" ); + // } + // else if (comparisonType == ComparisonType.Absolute) + // { + // bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); + // Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); + // } + // } } } diff --git a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs index 01bd81d2a1..7a7a8cfd5a 100644 --- a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs @@ -51,7 +51,7 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub // Amplitude ratio increases linearly by 20 dBV with power-of-10 increases of voltage. ElectricPotential v = ElectricPotential.FromVolts(voltage); - double actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; + QuantityValue actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; Assert.Equal(expected, actual); } @@ -65,8 +65,8 @@ public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRati { // Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio. AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio); - - double actual = ar.ToElectricPotential().Volts; + // TODO check these + QuantityValue actual = ar.ToElectricPotential().Volts; Assert.Equal(expected, actual); } @@ -80,8 +80,11 @@ public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRati public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expected) { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); + + // TODO check these + // double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts.ToDouble(), 2); + QuantityValue actual = QuantityValue.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); + Assert.Equal(expected, actual); } @@ -93,8 +96,11 @@ public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expect public void AmplitudeRatioToPowerRatio_75OhmImpedance(double dBmV, double expected) { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); + + // TODO check these + // double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts.ToDouble(), 2); + QuantityValue actual = QuantityValue.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); + Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 322b519d74..1a1d4c4bba 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -45,6 +45,13 @@ public void AreaDividedByLengthEqualsLength() Assert.Equal(length, Length.FromMeters(10)); } + [Fact] + public void AreaDividedByVolumeEqualsReciprocalLength() + { + ReciprocalLength reciprocalLength = Area.FromSquareMeters(50) / Volume.FromCubicMeters(5); + Assert.Equal(reciprocalLength, ReciprocalLength.FromInverseMeters(10)); + } + [Fact] public void AreaTimesMassFluxEqualsMassFlow() { @@ -64,13 +71,13 @@ public void AreaTimesDensityEqualsLinearDensity() [InlineData(0.5, 0.19634954084936208)] [InlineData(1, 0.7853981633974483)] [InlineData(2, 3.141592653589793)] - public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, double expected) + public void AreaFromCircleDiameterCalculatedCorrectly(double diameterMeters, double expected) { Length diameter = Length.FromMeters(diameterMeters); - double actual = Area.FromCircleDiameter(diameter).SquareMeters; + QuantityValue actual = Area.FromCircleDiameter(diameter).SquareMeters; - Assert.Equal(expected, actual); + AssertEx.EqualTolerance(expected, actual, SquareMetersTolerance); } [Theory] @@ -78,13 +85,13 @@ public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, doub [InlineData(0.5, 0.7853981633974483)] [InlineData(1, 3.141592653589793)] [InlineData(2, 12.566370614359173)] - public void AreaFromCicleRadiusCalculatedCorrectly(double radiusMeters, double expected) + public void AreaFromCircleRadiusCalculatedCorrectly(double radiusMeters, double expected) { Length radius = Length.FromMeters(radiusMeters); - double actual = Area.FromCircleRadius(radius).SquareMeters; + QuantityValue actual = Area.FromCircleRadius(radius).SquareMeters; - Assert.Equal(expected, actual); + AssertEx.EqualTolerance(expected, actual, SquareMetersTolerance); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs index 9fd00bf3e2..7674706f1c 100644 --- a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs +++ b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs @@ -33,7 +33,7 @@ public void DoubleDividedByBrakeSpecificFuelConsumptionEqualsSpecificEnergy() [Fact] public void BrakeSpecificFuelConsumptionTimesSpecificEnergyEqualsEnergy() { - double value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); + QuantityValue value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); Assert.Equal(200.0, value); } } diff --git a/UnitsNet.Tests/CustomCode/EnergyDensityTests.cs b/UnitsNet.Tests/CustomCode/EnergyDensityTests.cs index 35e28b4a47..3912e7f5c9 100644 --- a/UnitsNet.Tests/CustomCode/EnergyDensityTests.cs +++ b/UnitsNet.Tests/CustomCode/EnergyDensityTests.cs @@ -58,7 +58,7 @@ public void CombustionEnergy() Energy energy = EnergyDensity.CombustionEnergy(EnergyDensity.FromKilowattHoursPerCubicMeter(9.88), Volume.FromCubicMeters(1), Ratio.FromDecimalFractions(0.9543)); - Assert.Equal(9.428484, energy.KilowattHours, 5); + Assert.Equal(9.428484, energy.KilowattHours); } } } diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs index d37951856f..dfa115d06d 100644 --- a/UnitsNet.Tests/CustomCode/ForceTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceTests.cs @@ -108,9 +108,8 @@ public void ForceDividedByForceChangeRateEqualsDuration() [Fact] public void KilogramForceDividedByNewtonEqualsStandardGravity() { - const double standardGravity = 9.80665; - double duration = Force.FromKilogramsForce(1) / Force.FromNewtons(1); - Assert.Equal(standardGravity, duration); + QuantityValue duration = Force.FromKilogramsForce(1) / Force.FromNewtons(1); + Assert.Equal(9.80665, duration); } } } diff --git a/UnitsNet.Tests/CustomCode/IrradiationTests.cs b/UnitsNet.Tests/CustomCode/IrradiationTests.cs index 91bb9b6e9a..3f25e2186f 100644 --- a/UnitsNet.Tests/CustomCode/IrradiationTests.cs +++ b/UnitsNet.Tests/CustomCode/IrradiationTests.cs @@ -41,5 +41,9 @@ public class IrradiationTests : IrradiationTestsBase protected override double WattHoursPerSquareMeterInOneJoulePerSquareMeter => 2.777777777777778e-4; protected override double KilowattHoursPerSquareMeterInOneJoulePerSquareMeter => 2.777777777777778e-7; + + protected override double BtusPerSquareFootInOneJoulePerSquareMeter => 8.805509170334624e-5; + + protected override double KilobtusPerSquareFootInOneJoulePerSquareMeter => 8.805509170334624e-8; } } diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs index 4f888a23c2..2947aa4961 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.cs @@ -134,6 +134,20 @@ public void LengthDividedBySpeedEqualsDuration() Assert.Equal(Duration.FromSeconds(10), duration); } + [Fact] + public void LengthDividedByAreaEqualsReciprocalLength() + { + ReciprocalLength reciprocalLength = Length.FromMeters(20) / Area.FromSquareMeters(2); + Assert.Equal(ReciprocalLength.FromInverseMeters(10), reciprocalLength); + } + + [Fact] + public void LengthDividedByVolumeEqualsReciprocalArea() + { + ReciprocalArea reciprocalArea = Length.FromMeters(20) / Volume.FromCubicMeters(2); + Assert.Equal(ReciprocalArea.FromInverseSquareMeters(10), reciprocalArea); + } + [Fact] public void LengthTimesSpeedEqualsKinematicViscosity() { @@ -176,7 +190,7 @@ public void NegativeLengthToStonePoundsReturnsCorrectValues() negativeLength = Length.FromInches(-25.0); feetInches = negativeLength.FeetInches; - Assert.Equal(-2.0, feetInches.Feet); + Assert.Equal(-2, feetInches.Feet); Assert.Equal(-1.0, feetInches.Inches); } diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs index 9bb2f3f302..c7dff2cd12 100644 --- a/UnitsNet.Tests/CustomCode/ParseTests.cs +++ b/UnitsNet.Tests/CustomCode/ParseTests.cs @@ -28,7 +28,7 @@ public class ParseTests public void ParseLengthToMetersUsEnglish(string s, double expected) { CultureInfo usEnglish = CultureInfo.GetCultureInfo("en-US"); - double actual = Length.Parse(s, usEnglish).Meters; + QuantityValue actual = Length.Parse(s, usEnglish).Meters; Assert.Equal(expected, actual); } @@ -39,10 +39,10 @@ public void ParseLengthToMetersUsEnglish(string s, double expected) [InlineData("1 kg", typeof(FormatException))] // Wrong measurement type. [InlineData("1ft monkey 1in", typeof(FormatException))] // Invalid separator between two valid measurements. [InlineData("1ft 1invalid", typeof(FormatException))] // Valid - public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, Type expectedExceptionType) + public void ParseLength_InvalidString_USEnglish_ThrowsException(string? s, Type expectedExceptionType) { var usEnglish = CultureInfo.GetCultureInfo("en-US"); - Assert.Throws(expectedExceptionType, () => Length.Parse(s, usEnglish)); + Assert.Throws(expectedExceptionType, () => Length.Parse(s!, usEnglish)); } /// Error parsing string. @@ -58,7 +58,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expe numberFormat.NumberDecimalSeparator = "."; numberFormat.CurrencyDecimalSeparator = "."; - double actual = Length.Parse(s, numberFormat).Meters; + QuantityValue actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } @@ -89,7 +89,7 @@ public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expect numberFormat.NumberDecimalSeparator = ","; numberFormat.CurrencyDecimalSeparator = ","; - double actual = Length.Parse(s, numberFormat).Meters; + QuantityValue actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } @@ -125,10 +125,10 @@ public void ParseLengthUnitUsEnglish(string s, LengthUnit expected) [Theory] [InlineData("kg", typeof(UnitNotFoundException))] [InlineData(null, typeof(ArgumentNullException))] - public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, Type expectedExceptionType) + public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string? s, Type expectedExceptionType) { var usEnglish = CultureInfo.GetCultureInfo("en-US"); - Assert.Throws(expectedExceptionType, () => Length.ParseUnit(s, usEnglish)); + Assert.Throws(expectedExceptionType, () => Length.ParseUnit(s!, usEnglish)); } [Theory] @@ -137,7 +137,7 @@ public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, Ty [InlineData("2 kg", false)] [InlineData(null, false)] [InlineData("foo", false)] - public void TryParseLengthUnitUsEnglish(string s, bool expected) + public void TryParseLengthUnitUsEnglish(string? s, bool expected) { CultureInfo usEnglish = CultureInfo.GetCultureInfo("en-US"); bool actual = Length.TryParse(s, usEnglish, out Length _); diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index 8dab3f359a..46b278cc98 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -41,7 +41,7 @@ public void InvalidPower_ExpectArgumentOutOfRangeException(double power) public void ExpectPowerConvertedCorrectly(double power, double expected) { Power p = Power.FromWatts(power); - double actual = PowerRatio.FromPower(p).DecibelWatts; + QuantityValue actual = PowerRatio.FromPower(p).DecibelWatts; Assert.Equal(expected, actual); } @@ -69,7 +69,10 @@ public void PowerRatioToAmplitudeRatio_50OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts.ToDouble(), 2); + // TODO ideally we should be able to match without rounding + // QuantityValue actual = powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts; + Assert.Equal(expected, actual); } @@ -82,7 +85,10 @@ public void PowerRatioToAmplitudeRatio_75OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts.ToDouble(), 2); + // TODO ideally we should be able to match without rounding + // QuantityValue actual = powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts; + Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseTests.cs b/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseTests.cs new file mode 100644 index 0000000000..717fc0410a --- /dev/null +++ b/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseTests.cs @@ -0,0 +1,19 @@ +// 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; + +namespace UnitsNet.Tests.CustomCode +{ + public class RadiationEquivalentDoseTests : RadiationEquivalentDoseTestsBase + { + protected override bool SupportsSIUnitSystem => true; + + protected override double SievertsInOneSievert => 1; + protected override double MillisievertsInOneSievert => 1e+3; + protected override double MicrosievertsInOneSievert => 1e+6; + protected override double NanosievertsInOneSievert => 1e+9; + protected override double MilliroentgensEquivalentManInOneSievert => 1e+5; + protected override double RoentgensEquivalentManInOneSievert => 100; + } +} diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index 27b5c448ea..2da0c248af 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -77,8 +77,8 @@ public void SpecificEnergyTimesMassFlowEqualsPower() [Fact] public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy() { - double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); - Assert.Equal(200d, value); + QuantityValue value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); + Assert.Equal(200, value); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs index e5914c43d5..3e1250dd38 100644 --- a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs @@ -49,7 +49,7 @@ public class VolumeFlowTests : VolumeFlowTestsBase protected override double CubicDecimetersPerMinuteInOneCubicMeterPerSecond => 6e4; - protected override double CubicFeetPerHourInOneCubicMeterPerSecond => 1.271328001973604e+5; + protected override double CubicFeetPerHourInOneCubicMeterPerSecond => 127132.86571572398; protected override double CubicFeetPerMinuteInOneCubicMeterPerSecond => 2.11888E3; @@ -165,6 +165,22 @@ public class VolumeFlowTests : VolumeFlowTestsBase protected override double UsGallonsPerSecondInOneCubicMeterPerSecond => 2.64172052358148E2; + protected override double DecalitersPerDayInOneCubicMeterPerSecond => 8.64E6; + + protected override double DecalitersPerHourInOneCubicMeterPerSecond => 360_000; + + protected override double DecalitersPerMinuteInOneCubicMeterPerSecond => 6_000; + + protected override double DecalitersPerSecondInOneCubicMeterPerSecond => 100; + + protected override double HectolitersPerDayInOneCubicMeterPerSecond => 864_000; + + protected override double HectolitersPerHourInOneCubicMeterPerSecond => 36_000; + + protected override double HectolitersPerMinuteInOneCubicMeterPerSecond => 600; + + protected override double HectolitersPerSecondInOneCubicMeterPerSecond => 10; + [Theory] [InlineData(20, 2, 40)] [InlineData(20, 62, 1240)] diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs index 44d7e4e3e4..cb1d4ceea6 100644 --- a/UnitsNet.Tests/CustomCode/VolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs @@ -17,7 +17,7 @@ public class VolumeTests : VolumeTestsBase protected override double CubicFeetInOneCubicMeter => 35.314666721488590250438010354003; - protected override double CubicInchesInOneCubicMeter => 61023.98242; + protected override double CubicInchesInOneCubicMeter => 61_023.744094732283952756881891717; protected override double CubicKilometersInOneCubicMeter => 1E-9; diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index 233c97b1f1..6e898d46ef 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -8,7 +8,7 @@ namespace UnitsNet.Tests.CustomQuantities /// public readonly struct HowMuch : IQuantity { - public HowMuch(double value, HowMuchUnit unit) + public HowMuch(QuantityValue value, HowMuchUnit unit) { Unit = unit; Value = value; @@ -19,11 +19,11 @@ public HowMuch(double value, HowMuchUnit unit) Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } - public double Value { get; } + public QuantityValue Value { get; } #region IQuantity - private static readonly HowMuch Zero = new HowMuch(0, HowMuchUnit.Some); + private static readonly HowMuch Zero = new(0, HowMuchUnit.Some); public BaseDimensions Dimensions => BaseDimensions.Dimensionless; @@ -40,9 +40,9 @@ public HowMuch(double value, HowMuchUnit unit) Zero, BaseDimensions.Dimensionless); - public double As(Enum unit) => Convert.ToDouble(unit); + public QuantityValue As(Enum unit) => Convert.ToInt32(unit); - public double As(UnitSystem unitSystem) => throw new NotImplementedException(); + public QuantityValue As(UnitSystem unitSystem) => throw new NotImplementedException(); public IQuantity ToUnit(Enum unit) { diff --git a/UnitsNet.Tests/DefaultQuantityValueFormatterTests.cs b/UnitsNet.Tests/DefaultQuantityValueFormatterTests.cs new file mode 100644 index 0000000000..3ec7b99fbd --- /dev/null +++ b/UnitsNet.Tests/DefaultQuantityValueFormatterTests.cs @@ -0,0 +1,404 @@ +// 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; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Numerics; +using Xunit; + +namespace UnitsNet.Tests; + +public class DefaultQuantityValueFormatterTests +{ + private const string AmericanCultureName = "en-US"; + private const string RussianCultureName = "ru-RU"; + private const string NorwegianCultureName = "nb-NO"; + + /// + /// The general ("G") format specifier converts a number to the more compact of either fixed-point or scientific + /// notation, depending on the type of the number and whether a precision specifier is present. The precision specifier + /// defines the maximum number of significant digits that can appear in the result string. If the precision specifier + /// is omitted or zero, the type of the number determines the default precision. + /// + private static readonly string[] GeneralFormats = + ["G", "G0", "G1", "G2", "G3", "G4", "G5", "G6", "g", "g0", "g1", "g2", "g3", "g4", "g5", "g6"]; + + /// + /// The fixed-point ("F") format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" + /// indicates a digit (0-9). The string starts with a minus sign if the number is negative. + /// The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the + /// current NumberFormatInfo.NumberDecimalDigits property supplies the numeric precision. + /// + private static readonly string[] FixedPointFormats = + ["F", "F0", "F1", "F2", "F3", "F4", "F5", "F6", "f", "f0", "f1", "f2", "f3", "f4", "f5", "f6"]; + + /// + /// The numeric ("N") format specifier converts a number to a string of the form "-d,ddd,ddd.ddd…", where "-" indicates + /// a negative number symbol if required, "d" indicates a digit (0-9), "," indicates a group separator, and "." + /// indicates a decimal point symbol. The precision specifier indicates the desired number of digits after the decimal + /// point. If the precision specifier is omitted, the number of decimal places is defined by the current + /// NumberFormatInfo.NumberDecimalDigits property. + /// + private static readonly string[] NumberFormats = + ["N", "N0", "N1", "N2", "N3", "N4", "N5", "N6", "n", "n0", "n1", "n2", "n3", "n4", "n5", "n6"]; + + /// + /// Exponential format specifier (E) + /// The exponential ("E") format specifier converts a number to a string of the form "-d.ddd…E+ddd" or "-d.ddd…e+ddd", + /// where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative. Exactly one + /// digit always precedes the decimal point. + /// The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier + /// is omitted, a default of six digits after the decimal point is used. + /// The case of the format specifier indicates whether to prefix the exponent with an "E" or an "e". The exponent + /// always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet + /// this minimum, if required. + /// + private static readonly string[] ScientificFormats = + ["E", "E0", "E1", "E2", "E3", "E4", "E5", "E6", "e", "e0", "e1", "e2", "e3", "e4", "e5", "e6"]; + + /// + /// The "C" (or currency) format specifier converts a number to a string that represents a currency amount. The + /// precision specifier indicates the desired number of decimal places in the result string. If the precision specifier + /// is omitted, the default precision is defined by the NumberFormatInfo.CurrencyDecimalDigits property. + /// If the value to be formatted has more than the specified or default number of decimal places, the fractional value + /// is rounded in the result string. If the value to the right of the number of specified decimal places is 5 or + /// greater, the last digit in the result string is rounded away from zero. + /// + private static readonly string[] CurrencyFormats = + ["C", "C0", "C1", "C2", "C3", "C4", "C5", "C6", "c", "c0", "c1", "c2", "c3", "c4", "c5", "c6"]; + + /// + /// The percent ("P") format specifier multiplies a number by 100 and converts it to a string that represents a + /// percentage. The precision specifier indicates the desired number of decimal places. If the precision specifier is + /// omitted, the default numeric precision supplied by the current PercentDecimalDigits property is used. + /// + private static readonly string[] PercentageFormats = + ["P", "P0", "P1", "P2", "P3", "P4", "P5", "P6", "p", "p0", "p1", "p2", "p3", "p4", "p5", "p6"]; + + private static readonly IFormatProvider AmericanCulture = CultureInfo.GetCultureInfo(AmericanCultureName); + private static readonly IFormatProvider NorwegianCulture = CultureInfo.GetCultureInfo(NorwegianCultureName); + private static readonly IFormatProvider RussianCulture = CultureInfo.GetCultureInfo(RussianCultureName); + + private static readonly string[] TestCulturesNames = [AmericanCultureName, NorwegianCultureName, RussianCultureName]; + + // we want to access these via the dictionary in order to enable the "selective test debugging" (IFormatProvider not serializable by xUnit) + private static readonly Dictionary FormatProviders = new() + { + { AmericanCultureName, AmericanCulture }, { NorwegianCultureName, NorwegianCulture }, { RussianCultureName, RussianCulture } + }; + + private static readonly decimal[] TerminatingFractions = + [ + 0, 1, -1, 10, -10, 100, -100, 1000, -1000, 10000, -10000, 100000, -100000, + 0.1m, -0.1m, 0.2m, -0.2m, 0.5m, -0.5m, 1.2m, -1.2m, 1.5m, -1.5m, 2.5m, -2.5m, + 0.000015545665434654m, -0.000015545665434654m, + 0.00015545665434654m, -0.00015545665434654m, + 0.0015545665434654m, -0.0015545665434654m, + 0.015545665434654m, -0.015545665434654m, + 0.15545665434654m, -0.15545665434654m, + 1.5545665434654m, -1.5545665434654m, + 15.545665434654m, -15.545665434654m, + 155.45665434654m, -155.45665434654m, + 1554.5665434654m, -1554.5665434654m, + 15545.665434654m, -15545.665434654m, + 155456.65434654m, -155456.65434654m, + 1554566.5434654m, -1554566.5434654m + ]; + + private static IEnumerable SupportedFormatsToTest => GeneralFormats.Concat(FixedPointFormats).Concat(NumberFormats).Concat(ScientificFormats) + .Concat(CurrencyFormats).Concat(PercentageFormats); // these two are currently only supported by converting to double (limited precision) + + /// + /// Tests to ensure `QuantityValue.ToString(...)` matches `double.ToString(...)` for all standard formats. + /// + /// + /// Tests cover general, fixed point, number, scientific, currency, and percentage formats. + /// + public class StandardFormatsCompatibilityTests + { + public static IEnumerable GeneralFormatsToTest => + from stringFormat in GeneralFormats + from valueToTest in TerminatingFractions + from cultureToTest in TestCulturesNames + select new object[] { valueToTest, stringFormat, cultureToTest }; + + public static IEnumerable FixedPointFormatsToTest => + from stringFormat in FixedPointFormats + from valueToTest in TerminatingFractions + from cultureToTest in TestCulturesNames + select new object[] { valueToTest, stringFormat, cultureToTest }; + + public static IEnumerable NumberFormatsToTest => + from stringFormat in NumberFormats + from valueToTest in TerminatingFractions + from cultureToTest in TestCulturesNames + select new object[] { valueToTest, stringFormat, cultureToTest }; + + public static IEnumerable ScientificFormatsToTest => + from stringFormat in ScientificFormats + from valueToTest in TerminatingFractions + from cultureToTest in TestCulturesNames + select new object[] { valueToTest, stringFormat, cultureToTest }; + + // this currency format is currently implemented via the ToDouble().ToString(..) so there isn't any need to test with the cultures + public static IEnumerable CurrencyFormatsToTest => + from stringFormat in CurrencyFormats + from valueToTest in TerminatingFractions + select new object[] { valueToTest, stringFormat }; + + // the percentage format is currently implemented via the ToDouble().ToString(..) so there isn't any need to test with the cultures + public static IEnumerable PercentageFormatsToTest => + from stringFormat in PercentageFormats + from valueToTest in TerminatingFractions + select new object[] { valueToTest, stringFormat }; + + [Theory] + [MemberData(nameof(GeneralFormatsToTest))] + public static void ToStringWithGeneralFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat, string formatProviderName) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + IFormatProvider formatProvider = FormatProviders[formatProviderName]; + // Act + var expected = doubleValue.ToString(stringFormat, formatProvider); + var actual = valueToTest.ToString(stringFormat, formatProvider); + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(FixedPointFormatsToTest))] + public static void ToStringWithFixedPointFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat, string formatProviderName) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + IFormatProvider formatProvider = FormatProviders[formatProviderName]; + // Act + var expected = doubleValue.ToString(stringFormat, formatProvider); + var actual = valueToTest.ToString(stringFormat, formatProvider); + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(NumberFormatsToTest))] + public static void ToStringWithNumberFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat, string formatProviderName) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + IFormatProvider formatProvider = FormatProviders[formatProviderName]; + // Act + var expected = doubleValue.ToString(stringFormat, formatProvider); + var actual = valueToTest.ToString(stringFormat, formatProvider); + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(ScientificFormatsToTest))] + public static void ToStringWithScientificFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat, string formatProviderName) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + IFormatProvider formatProvider = FormatProviders[formatProviderName]; + // Act + var expected = doubleValue.ToString(stringFormat, formatProvider); + var actual = valueToTest.ToString(stringFormat, formatProvider); + // Assert + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(CurrencyFormatsToTest))] + public static void ToStringWithCurrencyFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + // Act + var expected = doubleValue.ToString(stringFormat); + var actual = valueToTest.ToString(stringFormat); + // Assert + Assert.Equal(expected, actual); + } + + + [Theory] + [MemberData(nameof(PercentageFormatsToTest))] + public static void ToStringWithPercentageFormats_ShouldEqual_DoubleToString(QuantityValue valueToTest, string stringFormat) + { + // Arrange + var doubleValue = valueToTest.ToDouble(); + // Act + var expected = doubleValue.ToString(stringFormat); + var actual = valueToTest.ToString(stringFormat); + // Assert + Assert.Equal(expected, actual); + } + } + + /// + /// Contains unit tests for the ToString method of the QuantityValue struct with high precision values. + /// + /// + /// These tests ensure that the ToString method correctly formats high precision values (such as "G36") in various + /// formats (fixed point, number, scientific, and general). + /// + public class ToStringWithHighPrecisionTests + { + [Fact] + public static void ToStringWithFixedPointFormats_Support_HighPrecision() + { + // Arrange + var a = new BigInteger(123456789987654321); + BigInteger b = new BigInteger(123456789987654321) * BigInteger.Pow(10, 18); + BigInteger largeValue = a + b; // should represent the value 123456789987654321123456789987654321 + var valueToTest = new QuantityValue(largeValue, BigInteger.Pow(10, 18)); // place the decimal point in the middle + + // Assert + Assert.Equal("123456789987654321.12345678998765432", valueToTest.ToString("F17")); + Assert.Equal("123456789987654321.123456789987654321", valueToTest.ToString("F18")); + Assert.Equal("123456789987654321.1234567899876543210", valueToTest.ToString("F19")); + } + + [Fact] + public static void ToStringWithNumberFormats_Support_HighPrecision() + { + // Arrange + var a = new BigInteger(123456789987654321); + BigInteger b = new BigInteger(123456789987654321) * BigInteger.Pow(10, 18); + BigInteger largeValue = a + b; // should represent the value 123456789987654321123456789987654321 + var valueToTest = new QuantityValue(largeValue, BigInteger.Pow(10, 18)); // place the decimal point in the middle + + // Assert + Assert.Equal("123 456 789 987 654 321.12345678998765432", valueToTest.ToString("N17")); + Assert.Equal("123 456 789 987 654 321.123456789987654321", valueToTest.ToString("N18")); + Assert.Equal("123 456 789 987 654 321.1234567899876543210", valueToTest.ToString("N19")); + } + + [Fact] + public static void ToStringWithScientificFormats_Support_HighPrecision() + { + // Arrange + var a = new BigInteger(123456789987654321); + BigInteger b = new BigInteger(123456789987654321) * BigInteger.Pow(10, 18); + BigInteger largeValue = a + b; // should represent the value 123456789987654321123456789987654321 + var valueToTest = new QuantityValue(largeValue, BigInteger.Pow(10, 18)); // place the decimal point in the middle + + // Assert + Assert.Equal("1.2345678998765432E+017", valueToTest.ToString("E16")); + Assert.Equal("1.23456789987654321E+017", valueToTest.ToString("E17")); + Assert.Equal("1.234567899876543211E+017", valueToTest.ToString("E18")); + Assert.Equal("1.2345678998765432112345678998765432E+017", valueToTest.ToString("E34")); + Assert.Equal("1.23456789987654321123456789987654321E+017", valueToTest.ToString("E35")); + Assert.Equal("1.234567899876543211234567899876543210E+017", valueToTest.ToString("E36")); + } + + [Fact] + public static void ToStringWithGeneralFormats_Support_HighPrecision() + { + // Arrange + var a = new BigInteger(123456789987654321); + BigInteger b = new BigInteger(123456789987654321) * BigInteger.Pow(10, 18); + BigInteger largeValue = a + b; // should represent the value 123456789987654321123456789987654321 + var valueToTest = new QuantityValue(largeValue, BigInteger.Pow(10, 18)); // place the decimal point in the middle + + // Assert + Assert.Equal("1.2345678998765432E+17", valueToTest.ToString("G17")); + Assert.Equal("123456789987654321", valueToTest.ToString("G18")); + Assert.Equal("123456789987654321.1", valueToTest.ToString("G19")); + Assert.Equal("123456789987654321.12345678998765432", valueToTest.ToString("G35")); + Assert.Equal("123456789987654321.123456789987654321", valueToTest.ToString("G36")); + Assert.Equal("123456789987654321.123456789987654321", valueToTest.ToString("G37")); + } + } + + /// + /// Tests for the (custom) 'Sx' format (Significant Digits After Radix) + /// + public class SignificantDigitsAfterRadixFormatTests + { + // Due to rounding, the values will result in the same string representation regardless of the number of significant digits (up to a certain point) + [Theory] + [InlineData(0.819999999999, "s2", "0.82")] + [InlineData(0.819999999999, "s4", "0.82")] + [InlineData(0.00299999999, "s2", "0.003")] + [InlineData(0.00299999999, "s4", "0.003")] + [InlineData(0.0003000001, "s2", "3e-04")] + [InlineData(0.0003000001, "s4", "3e-04")] + public void RoundingErrorsWithSignificantDigitsAfterRadixFormatting(double value, + string significantDigitsAfterRadixFormatString, string expected) + { + // Arrange + var quantityValue = QuantityValue.FromDoubleRounded(value); + // Act + var actual = quantityValue.ToString(significantDigitsAfterRadixFormatString, AmericanCulture); + // Assert + Assert.Equal(expected, actual); + } + + // Any value in the interval (-inf ≤ x < 1e-03] is formatted in scientific notation + [Theory] + [InlineData(double.MinValue, "-1.8e+308")] + [InlineData(1.23e-120, "1.23e-120")] + [InlineData(0.0000111, "1.11e-05")] + [InlineData(1.99e-4, "1.99e-04")] + public void ScientificNotationLowerInterval(double value, string expected) + { + // Arrange + var quantityValue = QuantityValue.FromDoubleRounded(value); + // Act + var actual = quantityValue.ToString("s", AmericanCulture); + // Assert + Assert.Equal(expected, actual); + } + + // Any value in the interval [1e-03 ≤ x < 1e+03] is formatted in fixed point notation. + [Theory] + [InlineData(1e-3, "0.001")] + [InlineData(1.1, "1.1")] + [InlineData(999.99, "999.99")] + public void FixedPointNotationIntervalFormatting(double value, string expected) + { + // Arrange + var quantityValue = QuantityValue.FromDoubleRounded(value); + // Act + var actual = quantityValue.ToString("s", AmericanCulture); + // Assert + Assert.Equal(expected, actual); + } + + // Any value in the interval [1e+03 ≤ x < 1e+06] is formatted in fixed point notation with digit grouping. + [Theory] + [InlineData(1000, "1,000")] + [InlineData(11000, "11,000")] + [InlineData(111000, "111,000")] + [InlineData(999999.99, "999,999.99")] + public void FixedPointNotationWithDigitGroupingIntervalFormatting(double value, string expected) + { + // Arrange + var quantityValue = QuantityValue.FromDoubleRounded(value); + // Act + var actual = quantityValue.ToString("s", AmericanCulture); + // Assert + Assert.Equal(expected, actual); + } + + // Any value in the interval [1e+06 ≤ x ≤ +inf) is formatted in scientific notation. + [Theory] + [InlineData(1e6, "1e+06")] + [InlineData(11100000, "1.11e+07")] + [InlineData(double.MaxValue, "1.8e+308")] + public void ScientificNotationUpperIntervalFormatting(double value, string expected) + { + // Arrange + var quantityValue = QuantityValue.FromDoubleRounded(value); + // Act + var actual = quantityValue.ToString("s", AmericanCulture); + // Assert + Assert.Equal(expected, actual); + } + } +} diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index cc15ec1af4..20dbd98739 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -13,11 +13,11 @@ internal class DummyIQuantity : IQuantity public Enum Unit => throw new NotImplementedException(); - public double Value => throw new NotImplementedException(); + public QuantityValue Value => throw new NotImplementedException(); - public double As(Enum unit ) => throw new NotImplementedException(); + public QuantityValue As(Enum unit ) => throw new NotImplementedException(); - public double As(UnitSystem unitSystem ) => throw new NotImplementedException(); + public QuantityValue As(UnitSystem unitSystem ) => throw new NotImplementedException(); public bool Equals(IQuantity? other, double tolerance, ComparisonType comparisonType) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index adfc1e4d48..7dc41682e2 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -118,6 +118,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, PowerRatioUnit.DecibelWatt, Quantity.From(3, PowerRatioUnit.DecibelWatt)); Assertion(3, PressureUnit.Torr, Quantity.From(3, PressureUnit.Torr)); Assertion(3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, Quantity.From(3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond)); + Assertion(3, RadiationEquivalentDoseUnit.Sievert, Quantity.From(3, RadiationEquivalentDoseUnit.Sievert)); Assertion(3, RadiationExposureUnit.Roentgen, Quantity.From(3, RadiationExposureUnit.Roentgen)); Assertion(3, RadioactivityUnit.Terarutherford, Quantity.From(3, RadioactivityUnit.Terarutherford)); Assertion(3, RatioUnit.Percent, Quantity.From(3, RatioUnit.Percent)); @@ -248,6 +249,7 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(PowerRatio.Info, PowerRatio.Zero); Assertion(Pressure.Info, Pressure.Zero); Assertion(PressureChangeRate.Info, PressureChangeRate.Zero); + Assertion(RadiationEquivalentDose.Info, RadiationEquivalentDose.Zero); Assertion(RadiationExposure.Info, RadiationExposure.Zero); Assertion(Radioactivity.Info, Radioactivity.Zero); Assertion(Ratio.Info, Ratio.Zero); @@ -378,6 +380,7 @@ public void Dimensions_IsSameAsStaticBaseDimensions() Assertion(PowerRatio.BaseDimensions, PowerRatio.Zero); Assertion(Pressure.BaseDimensions, Pressure.Zero); Assertion(PressureChangeRate.BaseDimensions, PressureChangeRate.Zero); + Assertion(RadiationEquivalentDose.BaseDimensions, RadiationEquivalentDose.Zero); Assertion(RadiationExposure.BaseDimensions, RadiationExposure.Zero); Assertion(Radioactivity.BaseDimensions, Radioactivity.Zero); Assertion(Ratio.BaseDimensions, Ratio.Zero); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs index 5a3a67b1db..6431c8db4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs @@ -126,7 +126,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AbsorbedDoseOfIonizingRadiationUnit.Gray, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new AbsorbedDoseOfIonizingRadiation(double.PositiveInfinity, AbsorbedDoseOfIonizingRadiationUnit.Gray)); @@ -136,7 +136,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new AbsorbedDoseOfIonizingRadiation(double.NaN, AbsorbedDoseOfIonizingRadiationUnit.Gray)); @@ -270,7 +270,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGrays_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => AbsorbedDoseOfIonizingRadiation.FromGrays(double.PositiveInfinity)); @@ -280,7 +280,7 @@ public void FromGrays_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGrays_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => AbsorbedDoseOfIonizingRadiation.FromGrays(double.NaN)); @@ -1103,8 +1103,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AbsorbedDoseOfIonizingRadiationUnit.Gray, 1, AbsorbedDoseOfIonizingRadiationUnit.Gray, true)] // Same value and unit. [InlineData(1, AbsorbedDoseOfIonizingRadiationUnit.Gray, 2, AbsorbedDoseOfIonizingRadiationUnit.Gray, false)] // Different value. - [InlineData(2, AbsorbedDoseOfIonizingRadiationUnit.Gray, 1, AbsorbedDoseOfIonizingRadiationUnit.Centigray, false)] // Different value and unit. - [InlineData(1, AbsorbedDoseOfIonizingRadiationUnit.Gray, 1, AbsorbedDoseOfIonizingRadiationUnit.Centigray, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AbsorbedDoseOfIonizingRadiationUnit unitA, double valueB, AbsorbedDoseOfIonizingRadiationUnit unitB, bool expectEqual) { var a = new AbsorbedDoseOfIonizingRadiation(valueA, unitA); @@ -1433,7 +1431,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AbsorbedDoseOfIonizingRadiation.FromGrays(1.0); - Assert.Equal(new {AbsorbedDoseOfIonizingRadiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(AbsorbedDoseOfIonizingRadiation.Info.Name, quantity.Grays); + #else + var expected = new {AbsorbedDoseOfIonizingRadiation.Info.Name, valueInBaseUnit = quantity.Grays}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 6d511f82df..02f757b128 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AccelerationUnit.MeterPerSecondSquared, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Acceleration(double.PositiveInfinity, AccelerationUnit.MeterPerSecondSquared)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Acceleration(double.NaN, AccelerationUnit.MeterPerSecondSquared)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecondSquared_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Acceleration.FromMetersPerSecondSquared(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromMetersPerSecondSquared_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecondSquared_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Acceleration.FromMetersPerSecondSquared(double.NaN)); @@ -1117,8 +1117,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AccelerationUnit.MeterPerSecondSquared, 1, AccelerationUnit.MeterPerSecondSquared, true)] // Same value and unit. [InlineData(1, AccelerationUnit.MeterPerSecondSquared, 2, AccelerationUnit.MeterPerSecondSquared, false)] // Different value. - [InlineData(2, AccelerationUnit.MeterPerSecondSquared, 1, AccelerationUnit.CentimeterPerSecondSquared, false)] // Different value and unit. - [InlineData(1, AccelerationUnit.MeterPerSecondSquared, 1, AccelerationUnit.CentimeterPerSecondSquared, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AccelerationUnit unitA, double valueB, AccelerationUnit unitB, bool expectEqual) { var a = new Acceleration(valueA, unitA); @@ -1443,7 +1441,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(new {Acceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Acceleration.Info.Name, quantity.MetersPerSecondSquared); + #else + var expected = new {Acceleration.Info.Name, valueInBaseUnit = quantity.MetersPerSecondSquared}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index b6ad678739..f24f6a80da 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -130,7 +130,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmountOfSubstanceUnit.Mole, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new AmountOfSubstance(double.PositiveInfinity, AmountOfSubstanceUnit.Mole)); @@ -140,7 +140,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new AmountOfSubstance(double.NaN, AmountOfSubstanceUnit.Mole)); @@ -279,7 +279,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMoles_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => AmountOfSubstance.FromMoles(double.PositiveInfinity)); @@ -289,7 +289,7 @@ public void FromMoles_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMoles_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => AmountOfSubstance.FromMoles(double.NaN)); @@ -864,8 +864,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AmountOfSubstanceUnit.Mole, 1, AmountOfSubstanceUnit.Mole, true)] // Same value and unit. [InlineData(1, AmountOfSubstanceUnit.Mole, 2, AmountOfSubstanceUnit.Mole, false)] // Different value. - [InlineData(2, AmountOfSubstanceUnit.Mole, 1, AmountOfSubstanceUnit.Centimole, false)] // Different value and unit. - [InlineData(1, AmountOfSubstanceUnit.Mole, 1, AmountOfSubstanceUnit.Centimole, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AmountOfSubstanceUnit unitA, double valueB, AmountOfSubstanceUnit unitB, bool expectEqual) { var a = new AmountOfSubstance(valueA, unitA); @@ -1196,7 +1194,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(new {AmountOfSubstance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(AmountOfSubstance.Info.Name, quantity.Moles); + #else + var expected = new {AmountOfSubstance.Info.Name, valueInBaseUnit = quantity.Moles}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 8d526e5e33..f8fb6e7691 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmplitudeRatioUnit.DecibelVolt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new AmplitudeRatio(double.PositiveInfinity, AmplitudeRatioUnit.DecibelVolt)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new AmplitudeRatio(double.NaN, AmplitudeRatioUnit.DecibelVolt)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibelVolts_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => AmplitudeRatio.FromDecibelVolts(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromDecibelVolts_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibelVolts_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => AmplitudeRatio.FromDecibelVolts(double.NaN)); @@ -435,8 +435,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AmplitudeRatioUnit.DecibelVolt, 1, AmplitudeRatioUnit.DecibelVolt, true)] // Same value and unit. [InlineData(1, AmplitudeRatioUnit.DecibelVolt, 2, AmplitudeRatioUnit.DecibelVolt, false)] // Different value. - [InlineData(2, AmplitudeRatioUnit.DecibelVolt, 1, AmplitudeRatioUnit.DecibelMicrovolt, false)] // Different value and unit. - [InlineData(1, AmplitudeRatioUnit.DecibelVolt, 1, AmplitudeRatioUnit.DecibelMicrovolt, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AmplitudeRatioUnit unitA, double valueB, AmplitudeRatioUnit unitB, bool expectEqual) { var a = new AmplitudeRatio(valueA, unitA); @@ -741,7 +739,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(new {AmplitudeRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(AmplitudeRatio.Info.Name, quantity.DecibelVolts); + #else + var expected = new {AmplitudeRatio.Info.Name, valueInBaseUnit = quantity.DecibelVolts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 53570ce564..8398d2dd63 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -126,7 +126,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AngleUnit.Degree, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Angle(double.PositiveInfinity, AngleUnit.Degree)); @@ -136,7 +136,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Angle(double.NaN, AngleUnit.Degree)); @@ -270,7 +270,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDegrees_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Angle.FromDegrees(double.PositiveInfinity)); @@ -280,7 +280,7 @@ public void FromDegrees_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDegrees_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Angle.FromDegrees(double.NaN)); @@ -1379,8 +1379,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AngleUnit.Degree, 1, AngleUnit.Degree, true)] // Same value and unit. [InlineData(1, AngleUnit.Degree, 2, AngleUnit.Degree, false)] // Different value. - [InlineData(2, AngleUnit.Degree, 1, AngleUnit.Arcminute, false)] // Different value and unit. - [InlineData(1, AngleUnit.Degree, 1, AngleUnit.Arcminute, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AngleUnit unitA, double valueB, AngleUnit unitB, bool expectEqual) { var a = new Angle(valueA, unitA); @@ -1709,7 +1707,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(new {Angle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Angle.Info.Name, quantity.Degrees); + #else + var expected = new {Angle.Info.Name, valueInBaseUnit = quantity.Degrees}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 4a7469909b..9f7210691d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentEnergyUnit.VoltampereHour, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ApparentEnergy(double.PositiveInfinity, ApparentEnergyUnit.VoltampereHour)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ApparentEnergy(double.NaN, ApparentEnergyUnit.VoltampereHour)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltampereHours_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ApparentEnergy.FromVoltampereHours(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromVoltampereHours_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltampereHours_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ApparentEnergy.FromVoltampereHours(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ApparentEnergyUnit.VoltampereHour, 1, ApparentEnergyUnit.VoltampereHour, true)] // Same value and unit. [InlineData(1, ApparentEnergyUnit.VoltampereHour, 2, ApparentEnergyUnit.VoltampereHour, false)] // Different value. - [InlineData(2, ApparentEnergyUnit.VoltampereHour, 1, ApparentEnergyUnit.KilovoltampereHour, false)] // Different value and unit. - [InlineData(1, ApparentEnergyUnit.VoltampereHour, 1, ApparentEnergyUnit.KilovoltampereHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ApparentEnergyUnit unitA, double valueB, ApparentEnergyUnit unitB, bool expectEqual) { var a = new ApparentEnergy(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(new {ApparentEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ApparentEnergy.Info.Name, quantity.VoltampereHours); + #else + var expected = new {ApparentEnergy.Info.Name, valueInBaseUnit = quantity.VoltampereHours}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index bf80b99a6c..d5bac7f821 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentPowerUnit.Voltampere, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ApparentPower(double.PositiveInfinity, ApparentPowerUnit.Voltampere)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ApparentPower(double.NaN, ApparentPowerUnit.Voltampere)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltamperes_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ApparentPower.FromVoltamperes(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromVoltamperes_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltamperes_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ApparentPower.FromVoltamperes(double.NaN)); @@ -479,8 +479,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ApparentPowerUnit.Voltampere, 1, ApparentPowerUnit.Voltampere, true)] // Same value and unit. [InlineData(1, ApparentPowerUnit.Voltampere, 2, ApparentPowerUnit.Voltampere, false)] // Different value. - [InlineData(2, ApparentPowerUnit.Voltampere, 1, ApparentPowerUnit.Gigavoltampere, false)] // Different value and unit. - [InlineData(1, ApparentPowerUnit.Voltampere, 1, ApparentPowerUnit.Gigavoltampere, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ApparentPowerUnit unitA, double valueB, ApparentPowerUnit unitB, bool expectEqual) { var a = new ApparentPower(valueA, unitA); @@ -789,7 +787,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(new {ApparentPower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ApparentPower.Info.Name, quantity.Voltamperes); + #else + var expected = new {ApparentPower.Info.Name, valueInBaseUnit = quantity.Voltamperes}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 3a7fcb6528..e293d4730e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new AreaDensity(double.PositiveInfinity, AreaDensityUnit.KilogramPerSquareMeter)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new AreaDensity(double.NaN, AreaDensityUnit.KilogramPerSquareMeter)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => AreaDensity.FromKilogramsPerSquareMeter(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromKilogramsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExc Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => AreaDensity.FromKilogramsPerSquareMeter(double.NaN)); @@ -420,8 +420,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AreaDensityUnit.KilogramPerSquareMeter, 1, AreaDensityUnit.KilogramPerSquareMeter, true)] // Same value and unit. [InlineData(1, AreaDensityUnit.KilogramPerSquareMeter, 2, AreaDensityUnit.KilogramPerSquareMeter, false)] // Different value. - [InlineData(2, AreaDensityUnit.KilogramPerSquareMeter, 1, AreaDensityUnit.GramPerSquareMeter, false)] // Different value and unit. - [InlineData(1, AreaDensityUnit.KilogramPerSquareMeter, 1, AreaDensityUnit.GramPerSquareMeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AreaDensityUnit unitA, double valueB, AreaDensityUnit unitB, bool expectEqual) { var a = new AreaDensity(valueA, unitA); @@ -724,7 +722,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(new {AreaDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(AreaDensity.Info.Name, quantity.KilogramsPerSquareMeter); + #else + var expected = new {AreaDensity.Info.Name, valueInBaseUnit = quantity.KilogramsPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index d0e98f1051..ab9711ec9a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new AreaMomentOfInertia(double.PositiveInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new AreaMomentOfInertia(double.NaN, AreaMomentOfInertiaUnit.MeterToTheFourth)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersToTheFourth_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => AreaMomentOfInertia.FromMetersToTheFourth(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromMetersToTheFourth_WithInfinityValue_DoNotThrowsArgumentException Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersToTheFourth_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NaN)); @@ -645,8 +645,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AreaMomentOfInertiaUnit.MeterToTheFourth, 1, AreaMomentOfInertiaUnit.MeterToTheFourth, true)] // Same value and unit. [InlineData(1, AreaMomentOfInertiaUnit.MeterToTheFourth, 2, AreaMomentOfInertiaUnit.MeterToTheFourth, false)] // Different value. - [InlineData(2, AreaMomentOfInertiaUnit.MeterToTheFourth, 1, AreaMomentOfInertiaUnit.CentimeterToTheFourth, false)] // Different value and unit. - [InlineData(1, AreaMomentOfInertiaUnit.MeterToTheFourth, 1, AreaMomentOfInertiaUnit.CentimeterToTheFourth, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AreaMomentOfInertiaUnit unitA, double valueB, AreaMomentOfInertiaUnit unitB, bool expectEqual) { var a = new AreaMomentOfInertia(valueA, unitA); @@ -955,7 +953,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(new {AreaMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(AreaMomentOfInertia.Info.Name, quantity.MetersToTheFourth); + #else + var expected = new {AreaMomentOfInertia.Info.Name, valueInBaseUnit = quantity.MetersToTheFourth}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 5c47527b56..ab4a6669bd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaUnit.SquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Area(double.PositiveInfinity, AreaUnit.SquareMeter)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Area(double.NaN, AreaUnit.SquareMeter)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Area.FromSquareMeters(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Area.FromSquareMeters(double.NaN)); @@ -1407,8 +1407,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, AreaUnit.SquareMeter, 1, AreaUnit.SquareMeter, true)] // Same value and unit. [InlineData(1, AreaUnit.SquareMeter, 2, AreaUnit.SquareMeter, false)] // Different value. - [InlineData(2, AreaUnit.SquareMeter, 1, AreaUnit.Acre, false)] // Different value and unit. - [InlineData(1, AreaUnit.SquareMeter, 1, AreaUnit.Acre, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, AreaUnit unitA, double valueB, AreaUnit unitB, bool expectEqual) { var a = new Area(valueA, unitA); @@ -1733,7 +1731,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(new {Area.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Area.Info.Name, quantity.SquareMeters); + #else + var expected = new {Area.Info.Name, valueInBaseUnit = quantity.SquareMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index c375ba78b6..ce07d42108 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -166,7 +166,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BitRateUnit.BitPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new BitRate(double.PositiveInfinity, BitRateUnit.BitPerSecond)); @@ -176,7 +176,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new BitRate(double.NaN, BitRateUnit.BitPerSecond)); @@ -360,7 +360,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBitsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => BitRate.FromBitsPerSecond(double.PositiveInfinity)); @@ -370,7 +370,7 @@ public void FromBitsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBitsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => BitRate.FromBitsPerSecond(double.NaN)); @@ -1513,8 +1513,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, BitRateUnit.BitPerSecond, 1, BitRateUnit.BitPerSecond, true)] // Same value and unit. [InlineData(1, BitRateUnit.BitPerSecond, 2, BitRateUnit.BitPerSecond, false)] // Different value. - [InlineData(2, BitRateUnit.BitPerSecond, 1, BitRateUnit.BytePerSecond, false)] // Different value and unit. - [InlineData(1, BitRateUnit.BitPerSecond, 1, BitRateUnit.BytePerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, BitRateUnit unitA, double valueB, BitRateUnit unitB, bool expectEqual) { var a = new BitRate(valueA, unitA); @@ -1863,7 +1861,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(new {BitRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(BitRate.Info.Name, quantity.BitsPerSecond); + #else + var expected = new {BitRate.Info.Name, valueInBaseUnit = quantity.BitsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 43cf8ecc6f..a80e6f8761 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new BrakeSpecificFuelConsumption(double.PositiveInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new BrakeSpecificFuelConsumption(double.NaN, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerJoule_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromKilogramsPerJoule_WithInfinityValue_DoNotThrowsArgumentException Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerJoule_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, 1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, true)] // Same value and unit. [InlineData(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, 2, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, false)] // Different value. - [InlineData(2, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, 1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, false)] // Different value and unit. - [InlineData(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, 1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, BrakeSpecificFuelConsumptionUnit unitA, double valueB, BrakeSpecificFuelConsumptionUnit unitB, bool expectEqual) { var a = new BrakeSpecificFuelConsumption(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(new {BrakeSpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(BrakeSpecificFuelConsumption.Info.Name, quantity.KilogramsPerJoule); + #else + var expected = new {BrakeSpecificFuelConsumption.Info.Name, valueInBaseUnit = quantity.KilogramsPerJoule}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index a29bdaa0fc..32b83da7d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -90,7 +90,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CapacitanceUnit.Farad, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Capacitance(double.PositiveInfinity, CapacitanceUnit.Farad)); @@ -100,7 +100,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Capacitance(double.NaN, CapacitanceUnit.Farad)); @@ -189,7 +189,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromFarads_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Capacitance.FromFarads(double.PositiveInfinity)); @@ -199,7 +199,7 @@ public void FromFarads_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromFarads_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Capacitance.FromFarads(double.NaN)); @@ -514,8 +514,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, CapacitanceUnit.Farad, 1, CapacitanceUnit.Farad, true)] // Same value and unit. [InlineData(1, CapacitanceUnit.Farad, 2, CapacitanceUnit.Farad, false)] // Different value. - [InlineData(2, CapacitanceUnit.Farad, 1, CapacitanceUnit.Kilofarad, false)] // Different value and unit. - [InlineData(1, CapacitanceUnit.Farad, 1, CapacitanceUnit.Kilofarad, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, CapacitanceUnit unitA, double valueB, CapacitanceUnit unitB, bool expectEqual) { var a = new Capacitance(valueA, unitA); @@ -826,7 +824,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(new {Capacitance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Capacitance.Info.Name, quantity.Farads); + #else + var expected = new {Capacitance.Info.Name, valueInBaseUnit = quantity.Farads}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index b3dc60110f..ca824226ad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CoefficientOfThermalExpansionUnit.PerKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new CoefficientOfThermalExpansion(double.PositiveInfinity, CoefficientOfThermalExpansionUnit.PerKelvin)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new CoefficientOfThermalExpansion(double.NaN, CoefficientOfThermalExpansionUnit.PerKelvin)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPerKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => CoefficientOfThermalExpansion.FromPerKelvin(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromPerKelvin_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPerKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => CoefficientOfThermalExpansion.FromPerKelvin(double.NaN)); @@ -501,8 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, CoefficientOfThermalExpansionUnit.PerKelvin, 1, CoefficientOfThermalExpansionUnit.PerKelvin, true)] // Same value and unit. [InlineData(1, CoefficientOfThermalExpansionUnit.PerKelvin, 2, CoefficientOfThermalExpansionUnit.PerKelvin, false)] // Different value. - [InlineData(2, CoefficientOfThermalExpansionUnit.PerKelvin, 1, CoefficientOfThermalExpansionUnit.PerDegreeCelsius, false)] // Different value and unit. - [InlineData(1, CoefficientOfThermalExpansionUnit.PerKelvin, 1, CoefficientOfThermalExpansionUnit.PerDegreeCelsius, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, CoefficientOfThermalExpansionUnit unitA, double valueB, CoefficientOfThermalExpansionUnit unitB, bool expectEqual) { var a = new CoefficientOfThermalExpansion(valueA, unitA); @@ -811,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = CoefficientOfThermalExpansion.FromPerKelvin(1.0); - Assert.Equal(new {CoefficientOfThermalExpansion.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(CoefficientOfThermalExpansion.Info.Name, quantity.PerKelvin); + #else + var expected = new {CoefficientOfThermalExpansion.Info.Name, valueInBaseUnit = quantity.PerKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index aad597d478..db7ab68f25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -90,7 +90,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CompressibilityUnit.InversePascal, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Compressibility(double.PositiveInfinity, CompressibilityUnit.InversePascal)); @@ -100,7 +100,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Compressibility(double.NaN, CompressibilityUnit.InversePascal)); @@ -189,7 +189,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInversePascals_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Compressibility.FromInversePascals(double.PositiveInfinity)); @@ -199,7 +199,7 @@ public void FromInversePascals_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInversePascals_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Compressibility.FromInversePascals(double.NaN)); @@ -704,8 +704,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, CompressibilityUnit.InversePascal, 1, CompressibilityUnit.InversePascal, true)] // Same value and unit. [InlineData(1, CompressibilityUnit.InversePascal, 2, CompressibilityUnit.InversePascal, false)] // Different value. - [InlineData(2, CompressibilityUnit.InversePascal, 1, CompressibilityUnit.InverseAtmosphere, false)] // Different value and unit. - [InlineData(1, CompressibilityUnit.InversePascal, 1, CompressibilityUnit.InverseAtmosphere, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, CompressibilityUnit unitA, double valueB, CompressibilityUnit unitB, bool expectEqual) { var a = new Compressibility(valueA, unitA); @@ -1016,7 +1014,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal(new {Compressibility.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Compressibility.Info.Name, quantity.InversePascals); + #else + var expected = new {Compressibility.Info.Name, valueInBaseUnit = quantity.InversePascals}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index e7e3a06fa4..af18ccc3cd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -286,7 +286,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DensityUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Density(double.PositiveInfinity, DensityUnit.KilogramPerCubicMeter)); @@ -296,7 +296,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Density(double.NaN, DensityUnit.KilogramPerCubicMeter)); @@ -630,7 +630,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Density.FromKilogramsPerCubicMeter(double.PositiveInfinity)); @@ -640,7 +640,7 @@ public void FromKilogramsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Density.FromKilogramsPerCubicMeter(double.NaN)); @@ -2347,8 +2347,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, DensityUnit.KilogramPerCubicMeter, 1, DensityUnit.KilogramPerCubicMeter, true)] // Same value and unit. [InlineData(1, DensityUnit.KilogramPerCubicMeter, 2, DensityUnit.KilogramPerCubicMeter, false)] // Different value. - [InlineData(2, DensityUnit.KilogramPerCubicMeter, 1, DensityUnit.CentigramPerDeciliter, false)] // Different value and unit. - [InlineData(1, DensityUnit.KilogramPerCubicMeter, 1, DensityUnit.CentigramPerDeciliter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, DensityUnit unitA, double valueB, DensityUnit unitB, bool expectEqual) { var a = new Density(valueA, unitA); @@ -2757,7 +2755,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {Density.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Density.Info.Name, quantity.KilogramsPerCubicMeter); + #else + var expected = new {Density.Info.Name, valueInBaseUnit = quantity.KilogramsPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index b6b8eb6e17..b0dc1692e6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -106,7 +106,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DurationUnit.Second, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Duration(double.PositiveInfinity, DurationUnit.Second)); @@ -116,7 +116,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Duration(double.NaN, DurationUnit.Second)); @@ -225,7 +225,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSeconds_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Duration.FromSeconds(double.PositiveInfinity)); @@ -235,7 +235,7 @@ public void FromSeconds_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSeconds_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Duration.FromSeconds(double.NaN)); @@ -1852,8 +1852,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, DurationUnit.Second, 1, DurationUnit.Second, true)] // Same value and unit. [InlineData(1, DurationUnit.Second, 2, DurationUnit.Second, false)] // Different value. - [InlineData(2, DurationUnit.Second, 1, DurationUnit.Day, false)] // Different value and unit. - [InlineData(1, DurationUnit.Second, 1, DurationUnit.Day, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, DurationUnit unitA, double valueB, DurationUnit unitB, bool expectEqual) { var a = new Duration(valueA, unitA); @@ -2172,7 +2170,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(new {Duration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Duration.Info.Name, quantity.Seconds); + #else + var expected = new {Duration.Info.Name, valueInBaseUnit = quantity.Seconds}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 04783059d7..ac160599b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -102,7 +102,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new DynamicViscosity(double.PositiveInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); @@ -112,7 +112,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new DynamicViscosity(double.NaN, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); @@ -216,7 +216,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonSecondsPerMeterSquared_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.PositiveInfinity)); @@ -226,7 +226,7 @@ public void FromNewtonSecondsPerMeterSquared_WithInfinityValue_DoNotThrowsArgume Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonSecondsPerMeterSquared_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NaN)); @@ -713,8 +713,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared, 1, DynamicViscosityUnit.NewtonSecondPerMeterSquared, true)] // Same value and unit. [InlineData(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared, 2, DynamicViscosityUnit.NewtonSecondPerMeterSquared, false)] // Different value. - [InlineData(2, DynamicViscosityUnit.NewtonSecondPerMeterSquared, 1, DynamicViscosityUnit.Centipoise, false)] // Different value and unit. - [InlineData(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared, 1, DynamicViscosityUnit.Centipoise, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, DynamicViscosityUnit unitA, double valueB, DynamicViscosityUnit unitB, bool expectEqual) { var a = new DynamicViscosity(valueA, unitA); @@ -1031,7 +1029,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(new {DynamicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(DynamicViscosity.Info.Name, quantity.NewtonSecondsPerMeterSquared); + #else + var expected = new {DynamicViscosity.Info.Name, valueInBaseUnit = quantity.NewtonSecondsPerMeterSquared}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index d8116b6226..99671117ce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricAdmittanceUnit.Siemens, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricAdmittance(double.PositiveInfinity, ElectricAdmittanceUnit.Siemens)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricAdmittance(double.NaN, ElectricAdmittanceUnit.Siemens)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemens_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricAdmittance.FromSiemens(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromSiemens_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemens_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricAdmittance.FromSiemens(double.NaN)); @@ -431,8 +431,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricAdmittanceUnit.Siemens, 1, ElectricAdmittanceUnit.Siemens, true)] // Same value and unit. [InlineData(1, ElectricAdmittanceUnit.Siemens, 2, ElectricAdmittanceUnit.Siemens, false)] // Different value. - [InlineData(2, ElectricAdmittanceUnit.Siemens, 1, ElectricAdmittanceUnit.Microsiemens, false)] // Different value and unit. - [InlineData(1, ElectricAdmittanceUnit.Siemens, 1, ElectricAdmittanceUnit.Microsiemens, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricAdmittanceUnit unitA, double valueB, ElectricAdmittanceUnit unitB, bool expectEqual) { var a = new ElectricAdmittance(valueA, unitA); @@ -737,7 +735,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(new {ElectricAdmittance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricAdmittance.Info.Name, quantity.Siemens); + #else + var expected = new {ElectricAdmittance.Info.Name, valueInBaseUnit = quantity.Siemens}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index dbfcedc08f..2160b8dffc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricChargeDensity(double.PositiveInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricChargeDensity(double.NaN, ElectricChargeDensityUnit.CoulombPerCubicMeter)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromCoulombsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExcep Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricChargeDensityUnit.CoulombPerCubicMeter, 1, ElectricChargeDensityUnit.CoulombPerCubicMeter, true)] // Same value and unit. [InlineData(1, ElectricChargeDensityUnit.CoulombPerCubicMeter, 2, ElectricChargeDensityUnit.CoulombPerCubicMeter, false)] // Different value. - [InlineData(2, ElectricChargeDensityUnit.CoulombPerCubicMeter, 1, ElectricChargeDensityUnit.CoulombPerCubicMeter, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricChargeDensityUnit unitA, double valueB, ElectricChargeDensityUnit unitB, bool expectEqual) { var a = new ElectricChargeDensity(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(new {ElectricChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricChargeDensity.Info.Name, quantity.CoulombsPerCubicMeter); + #else + var expected = new {ElectricChargeDensity.Info.Name, valueInBaseUnit = quantity.CoulombsPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index bfd453e100..be984410e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -106,7 +106,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeUnit.Coulomb, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricCharge(double.PositiveInfinity, ElectricChargeUnit.Coulomb)); @@ -116,7 +116,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricCharge(double.NaN, ElectricChargeUnit.Coulomb)); @@ -225,7 +225,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombs_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricCharge.FromCoulombs(double.PositiveInfinity)); @@ -235,7 +235,7 @@ public void FromCoulombs_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombs_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricCharge.FromCoulombs(double.NaN)); @@ -706,8 +706,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricChargeUnit.Coulomb, 1, ElectricChargeUnit.Coulomb, true)] // Same value and unit. [InlineData(1, ElectricChargeUnit.Coulomb, 2, ElectricChargeUnit.Coulomb, false)] // Different value. - [InlineData(2, ElectricChargeUnit.Coulomb, 1, ElectricChargeUnit.AmpereHour, false)] // Different value and unit. - [InlineData(1, ElectricChargeUnit.Coulomb, 1, ElectricChargeUnit.AmpereHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricChargeUnit unitA, double valueB, ElectricChargeUnit unitB, bool expectEqual) { var a = new ElectricCharge(valueA, unitA); @@ -1026,7 +1024,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(new {ElectricCharge.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricCharge.Info.Name, quantity.Coulombs); + #else + var expected = new {ElectricCharge.Info.Name, valueInBaseUnit = quantity.Coulombs}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index ab6dbeb4a1..6fd926d23d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductanceUnit.Siemens, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricConductance(double.PositiveInfinity, ElectricConductanceUnit.Siemens)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricConductance(double.NaN, ElectricConductanceUnit.Siemens)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemens_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricConductance.FromSiemens(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromSiemens_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemens_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricConductance.FromSiemens(double.NaN)); @@ -466,8 +466,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricConductanceUnit.Siemens, 1, ElectricConductanceUnit.Siemens, true)] // Same value and unit. [InlineData(1, ElectricConductanceUnit.Siemens, 2, ElectricConductanceUnit.Siemens, false)] // Different value. - [InlineData(2, ElectricConductanceUnit.Siemens, 1, ElectricConductanceUnit.Kilosiemens, false)] // Different value and unit. - [InlineData(1, ElectricConductanceUnit.Siemens, 1, ElectricConductanceUnit.Kilosiemens, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricConductanceUnit unitA, double valueB, ElectricConductanceUnit unitB, bool expectEqual) { var a = new ElectricConductance(valueA, unitA); @@ -774,7 +772,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(new {ElectricConductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricConductance.Info.Name, quantity.Siemens); + #else + var expected = new {ElectricConductance.Info.Name, valueInBaseUnit = quantity.Siemens}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index db74c22833..9e4717a626 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricConductivity(double.PositiveInfinity, ElectricConductivityUnit.SiemensPerMeter)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricConductivity(double.NaN, ElectricConductivityUnit.SiemensPerMeter)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemensPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricConductivity.FromSiemensPerMeter(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromSiemensPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSiemensPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricConductivity.FromSiemensPerMeter(double.NaN)); @@ -501,8 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricConductivityUnit.SiemensPerMeter, 1, ElectricConductivityUnit.SiemensPerMeter, true)] // Same value and unit. [InlineData(1, ElectricConductivityUnit.SiemensPerMeter, 2, ElectricConductivityUnit.SiemensPerMeter, false)] // Different value. - [InlineData(2, ElectricConductivityUnit.SiemensPerMeter, 1, ElectricConductivityUnit.MicrosiemensPerCentimeter, false)] // Different value and unit. - [InlineData(1, ElectricConductivityUnit.SiemensPerMeter, 1, ElectricConductivityUnit.MicrosiemensPerCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricConductivityUnit unitA, double valueB, ElectricConductivityUnit unitB, bool expectEqual) { var a = new ElectricConductivity(valueA, unitA); @@ -811,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(new {ElectricConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricConductivity.Info.Name, quantity.SiemensPerMeter); + #else + var expected = new {ElectricConductivity.Info.Name, valueInBaseUnit = quantity.SiemensPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 36a051e746..f87059e936 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricCurrentDensity(double.PositiveInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricCurrentDensity(double.NaN, ElectricCurrentDensityUnit.AmperePerSquareMeter)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromAmperesPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExcep Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricCurrentDensityUnit.AmperePerSquareMeter, 1, ElectricCurrentDensityUnit.AmperePerSquareMeter, true)] // Same value and unit. [InlineData(1, ElectricCurrentDensityUnit.AmperePerSquareMeter, 2, ElectricCurrentDensityUnit.AmperePerSquareMeter, false)] // Different value. - [InlineData(2, ElectricCurrentDensityUnit.AmperePerSquareMeter, 1, ElectricCurrentDensityUnit.AmperePerSquareFoot, false)] // Different value and unit. - [InlineData(1, ElectricCurrentDensityUnit.AmperePerSquareMeter, 1, ElectricCurrentDensityUnit.AmperePerSquareFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricCurrentDensityUnit unitA, double valueB, ElectricCurrentDensityUnit unitB, bool expectEqual) { var a = new ElectricCurrentDensity(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(new {ElectricCurrentDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricCurrentDensity.Info.Name, quantity.AmperesPerSquareMeter); + #else + var expected = new {ElectricCurrentDensity.Info.Name, valueInBaseUnit = quantity.AmperesPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 7850e56594..5328894118 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -90,7 +90,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricCurrentGradient(double.PositiveInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); @@ -100,7 +100,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricCurrentGradient(double.NaN, ElectricCurrentGradientUnit.AmperePerSecond)); @@ -189,7 +189,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity)); @@ -199,7 +199,7 @@ public void FromAmperesPerSecond_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NaN)); @@ -536,8 +536,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricCurrentGradientUnit.AmperePerSecond, 1, ElectricCurrentGradientUnit.AmperePerSecond, true)] // Same value and unit. [InlineData(1, ElectricCurrentGradientUnit.AmperePerSecond, 2, ElectricCurrentGradientUnit.AmperePerSecond, false)] // Different value. - [InlineData(2, ElectricCurrentGradientUnit.AmperePerSecond, 1, ElectricCurrentGradientUnit.AmperePerMicrosecond, false)] // Different value and unit. - [InlineData(1, ElectricCurrentGradientUnit.AmperePerSecond, 1, ElectricCurrentGradientUnit.AmperePerMicrosecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricCurrentGradientUnit unitA, double valueB, ElectricCurrentGradientUnit unitB, bool expectEqual) { var a = new ElectricCurrentGradient(valueA, unitA); @@ -848,7 +846,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(new {ElectricCurrentGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricCurrentGradient.Info.Name, quantity.AmperesPerSecond); + #else + var expected = new {ElectricCurrentGradient.Info.Name, valueInBaseUnit = quantity.AmperesPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index fb478daebd..490bfb34ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentUnit.Ampere, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricCurrent(double.PositiveInfinity, ElectricCurrentUnit.Ampere)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricCurrent(double.NaN, ElectricCurrentUnit.Ampere)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperes_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricCurrent.FromAmperes(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromAmperes_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperes_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricCurrent.FromAmperes(double.NaN)); @@ -584,8 +584,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricCurrentUnit.Ampere, 1, ElectricCurrentUnit.Ampere, true)] // Same value and unit. [InlineData(1, ElectricCurrentUnit.Ampere, 2, ElectricCurrentUnit.Ampere, false)] // Different value. - [InlineData(2, ElectricCurrentUnit.Ampere, 1, ElectricCurrentUnit.Centiampere, false)] // Different value and unit. - [InlineData(1, ElectricCurrentUnit.Ampere, 1, ElectricCurrentUnit.Centiampere, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricCurrentUnit unitA, double valueB, ElectricCurrentUnit unitB, bool expectEqual) { var a = new ElectricCurrent(valueA, unitA); @@ -900,7 +898,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(new {ElectricCurrent.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricCurrent.Info.Name, quantity.Amperes); + #else + var expected = new {ElectricCurrent.Info.Name, valueInBaseUnit = quantity.Amperes}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index c0ed5996c6..77496e32a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricFieldUnit.VoltPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricField(double.PositiveInfinity, ElectricFieldUnit.VoltPerMeter)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricField(double.NaN, ElectricFieldUnit.VoltPerMeter)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricField.FromVoltsPerMeter(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromVoltsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricField.FromVoltsPerMeter(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricFieldUnit.VoltPerMeter, 1, ElectricFieldUnit.VoltPerMeter, true)] // Same value and unit. [InlineData(1, ElectricFieldUnit.VoltPerMeter, 2, ElectricFieldUnit.VoltPerMeter, false)] // Different value. - [InlineData(2, ElectricFieldUnit.VoltPerMeter, 1, ElectricFieldUnit.VoltPerMeter, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricFieldUnit unitA, double valueB, ElectricFieldUnit unitB, bool expectEqual) { var a = new ElectricField(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(new {ElectricField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricField.Info.Name, quantity.VoltsPerMeter); + #else + var expected = new {ElectricField.Info.Name, valueInBaseUnit = quantity.VoltsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 5277d5929e..d6a12f5a58 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricInductanceUnit.Henry, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricInductance(double.PositiveInfinity, ElectricInductanceUnit.Henry)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricInductance(double.NaN, ElectricInductanceUnit.Henry)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHenries_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricInductance.FromHenries(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromHenries_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHenries_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricInductance.FromHenries(double.NaN)); @@ -466,8 +466,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricInductanceUnit.Henry, 1, ElectricInductanceUnit.Henry, true)] // Same value and unit. [InlineData(1, ElectricInductanceUnit.Henry, 2, ElectricInductanceUnit.Henry, false)] // Different value. - [InlineData(2, ElectricInductanceUnit.Henry, 1, ElectricInductanceUnit.Microhenry, false)] // Different value and unit. - [InlineData(1, ElectricInductanceUnit.Henry, 1, ElectricInductanceUnit.Microhenry, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricInductanceUnit unitA, double valueB, ElectricInductanceUnit unitB, bool expectEqual) { var a = new ElectricInductance(valueA, unitA); @@ -774,7 +772,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(new {ElectricInductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricInductance.Info.Name, quantity.Henries); + #else + var expected = new {ElectricInductance.Info.Name, valueInBaseUnit = quantity.Henries}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index c8afc29b25..6da149e367 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialAcUnit.VoltAc, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricPotentialAc(double.PositiveInfinity, ElectricPotentialAcUnit.VoltAc)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricPotentialAc(double.NaN, ElectricPotentialAcUnit.VoltAc)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsAc_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricPotentialAc.FromVoltsAc(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromVoltsAc_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsAc_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricPotentialAc.FromVoltsAc(double.NaN)); @@ -444,8 +444,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricPotentialAcUnit.VoltAc, 1, ElectricPotentialAcUnit.VoltAc, true)] // Same value and unit. [InlineData(1, ElectricPotentialAcUnit.VoltAc, 2, ElectricPotentialAcUnit.VoltAc, false)] // Different value. - [InlineData(2, ElectricPotentialAcUnit.VoltAc, 1, ElectricPotentialAcUnit.KilovoltAc, false)] // Different value and unit. - [InlineData(1, ElectricPotentialAcUnit.VoltAc, 1, ElectricPotentialAcUnit.KilovoltAc, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricPotentialAcUnit unitA, double valueB, ElectricPotentialAcUnit unitB, bool expectEqual) { var a = new ElectricPotentialAc(valueA, unitA); @@ -752,7 +750,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(new {ElectricPotentialAc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricPotentialAc.Info.Name, quantity.VoltsAc); + #else + var expected = new {ElectricPotentialAc.Info.Name, valueInBaseUnit = quantity.VoltsAc}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 3f496d9d3d..a1be0d8437 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -142,7 +142,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricPotentialChangeRate(double.PositiveInfinity, ElectricPotentialChangeRateUnit.VoltPerSecond)); @@ -152,7 +152,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricPotentialChangeRate(double.NaN, ElectricPotentialChangeRateUnit.VoltPerSecond)); @@ -306,7 +306,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricPotentialChangeRate.FromVoltsPerSecond(double.PositiveInfinity)); @@ -316,7 +316,7 @@ public void FromVoltsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricPotentialChangeRate.FromVoltsPerSecond(double.NaN)); @@ -903,8 +903,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricPotentialChangeRateUnit.VoltPerSecond, 1, ElectricPotentialChangeRateUnit.VoltPerSecond, true)] // Same value and unit. [InlineData(1, ElectricPotentialChangeRateUnit.VoltPerSecond, 2, ElectricPotentialChangeRateUnit.VoltPerSecond, false)] // Different value. - [InlineData(2, ElectricPotentialChangeRateUnit.VoltPerSecond, 1, ElectricPotentialChangeRateUnit.KilovoltPerHour, false)] // Different value and unit. - [InlineData(1, ElectricPotentialChangeRateUnit.VoltPerSecond, 1, ElectricPotentialChangeRateUnit.KilovoltPerHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricPotentialChangeRateUnit unitA, double valueB, ElectricPotentialChangeRateUnit unitB, bool expectEqual) { var a = new ElectricPotentialChangeRate(valueA, unitA); @@ -1241,7 +1239,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialChangeRate.FromVoltsPerSecond(1.0); - Assert.Equal(new {ElectricPotentialChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricPotentialChangeRate.Info.Name, quantity.VoltsPerSecond); + #else + var expected = new {ElectricPotentialChangeRate.Info.Name, valueInBaseUnit = quantity.VoltsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index ce6513981b..de38a76f5e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialDcUnit.VoltDc, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricPotentialDc(double.PositiveInfinity, ElectricPotentialDcUnit.VoltDc)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricPotentialDc(double.NaN, ElectricPotentialDcUnit.VoltDc)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsDc_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricPotentialDc.FromVoltsDc(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromVoltsDc_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltsDc_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricPotentialDc.FromVoltsDc(double.NaN)); @@ -444,8 +444,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricPotentialDcUnit.VoltDc, 1, ElectricPotentialDcUnit.VoltDc, true)] // Same value and unit. [InlineData(1, ElectricPotentialDcUnit.VoltDc, 2, ElectricPotentialDcUnit.VoltDc, false)] // Different value. - [InlineData(2, ElectricPotentialDcUnit.VoltDc, 1, ElectricPotentialDcUnit.KilovoltDc, false)] // Different value and unit. - [InlineData(1, ElectricPotentialDcUnit.VoltDc, 1, ElectricPotentialDcUnit.KilovoltDc, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricPotentialDcUnit unitA, double valueB, ElectricPotentialDcUnit unitB, bool expectEqual) { var a = new ElectricPotentialDc(valueA, unitA); @@ -752,7 +750,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(new {ElectricPotentialDc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricPotentialDc.Info.Name, quantity.VoltsDc); + #else + var expected = new {ElectricPotentialDc.Info.Name, valueInBaseUnit = quantity.VoltsDc}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 7dc092cc39..82d1180ff1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialUnit.Volt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricPotential(double.PositiveInfinity, ElectricPotentialUnit.Volt)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricPotential(double.NaN, ElectricPotentialUnit.Volt)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVolts_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricPotential.FromVolts(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromVolts_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVolts_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricPotential.FromVolts(double.NaN)); @@ -601,8 +601,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricPotentialUnit.Volt, 1, ElectricPotentialUnit.Volt, true)] // Same value and unit. [InlineData(1, ElectricPotentialUnit.Volt, 2, ElectricPotentialUnit.Volt, false)] // Different value. - [InlineData(2, ElectricPotentialUnit.Volt, 1, ElectricPotentialUnit.Kilovolt, false)] // Different value and unit. - [InlineData(1, ElectricPotentialUnit.Volt, 1, ElectricPotentialUnit.Kilovolt, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricPotentialUnit unitA, double valueB, ElectricPotentialUnit unitB, bool expectEqual) { var a = new ElectricPotential(valueA, unitA); @@ -911,7 +909,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(new {ElectricPotential.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricPotential.Info.Name, quantity.Volts); + #else + var expected = new {ElectricPotential.Info.Name, valueInBaseUnit = quantity.Volts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index c11e686600..12d0b9196f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -90,7 +90,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistanceUnit.Ohm, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricResistance(double.PositiveInfinity, ElectricResistanceUnit.Ohm)); @@ -100,7 +100,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricResistance(double.NaN, ElectricResistanceUnit.Ohm)); @@ -189,7 +189,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromOhms_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricResistance.FromOhms(double.PositiveInfinity)); @@ -199,7 +199,7 @@ public void FromOhms_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromOhms_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricResistance.FromOhms(double.NaN)); @@ -514,8 +514,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricResistanceUnit.Ohm, 1, ElectricResistanceUnit.Ohm, true)] // Same value and unit. [InlineData(1, ElectricResistanceUnit.Ohm, 2, ElectricResistanceUnit.Ohm, false)] // Different value. - [InlineData(2, ElectricResistanceUnit.Ohm, 1, ElectricResistanceUnit.Gigaohm, false)] // Different value and unit. - [InlineData(1, ElectricResistanceUnit.Ohm, 1, ElectricResistanceUnit.Gigaohm, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricResistanceUnit unitA, double valueB, ElectricResistanceUnit unitB, bool expectEqual) { var a = new ElectricResistance(valueA, unitA); @@ -826,7 +824,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(new {ElectricResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricResistance.Info.Name, quantity.Ohms); + #else + var expected = new {ElectricResistance.Info.Name, valueInBaseUnit = quantity.Ohms}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index f6b8d3931d..1bbf49a57a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistivityUnit.OhmMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricResistivity(double.PositiveInfinity, ElectricResistivityUnit.OhmMeter)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricResistivity(double.NaN, ElectricResistivityUnit.OhmMeter)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromOhmMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricResistivity.FromOhmMeters(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromOhmMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromOhmMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricResistivity.FromOhmMeters(double.NaN)); @@ -737,8 +737,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricResistivityUnit.OhmMeter, 1, ElectricResistivityUnit.OhmMeter, true)] // Same value and unit. [InlineData(1, ElectricResistivityUnit.OhmMeter, 2, ElectricResistivityUnit.OhmMeter, false)] // Different value. - [InlineData(2, ElectricResistivityUnit.OhmMeter, 1, ElectricResistivityUnit.KiloohmCentimeter, false)] // Different value and unit. - [InlineData(1, ElectricResistivityUnit.OhmMeter, 1, ElectricResistivityUnit.KiloohmCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricResistivityUnit unitA, double valueB, ElectricResistivityUnit unitB, bool expectEqual) { var a = new ElectricResistivity(valueA, unitA); @@ -1063,7 +1061,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(new {ElectricResistivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricResistivity.Info.Name, quantity.OhmMeters); + #else + var expected = new {ElectricResistivity.Info.Name, valueInBaseUnit = quantity.OhmMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 4fe2ba0dc5..402d08a151 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ElectricSurfaceChargeDensity(double.PositiveInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ElectricSurfaceChargeDensity(double.NaN, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromCoulombsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, 1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, true)] // Same value and unit. [InlineData(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, 2, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, false)] // Different value. - [InlineData(2, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, 1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, false)] // Different value and unit. - [InlineData(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, 1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ElectricSurfaceChargeDensityUnit unitA, double valueB, ElectricSurfaceChargeDensityUnit unitB, bool expectEqual) { var a = new ElectricSurfaceChargeDensity(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(new {ElectricSurfaceChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ElectricSurfaceChargeDensity.Info.Name, quantity.CoulombsPerSquareMeter); + #else + var expected = new {ElectricSurfaceChargeDensity.Info.Name, valueInBaseUnit = quantity.CoulombsPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs index 8cd2c3b07c..d43ae0633d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyDensityTestsBase.g.cs @@ -110,7 +110,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EnergyDensityUnit.JoulePerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new EnergyDensity(double.PositiveInfinity, EnergyDensityUnit.JoulePerCubicMeter)); @@ -120,7 +120,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new EnergyDensity(double.NaN, EnergyDensityUnit.JoulePerCubicMeter)); @@ -234,7 +234,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => EnergyDensity.FromJoulesPerCubicMeter(double.PositiveInfinity)); @@ -244,7 +244,7 @@ public void FromJoulesPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => EnergyDensity.FromJoulesPerCubicMeter(double.NaN)); @@ -711,8 +711,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, EnergyDensityUnit.JoulePerCubicMeter, 1, EnergyDensityUnit.JoulePerCubicMeter, true)] // Same value and unit. [InlineData(1, EnergyDensityUnit.JoulePerCubicMeter, 2, EnergyDensityUnit.JoulePerCubicMeter, false)] // Different value. - [InlineData(2, EnergyDensityUnit.JoulePerCubicMeter, 1, EnergyDensityUnit.GigajoulePerCubicMeter, false)] // Different value and unit. - [InlineData(1, EnergyDensityUnit.JoulePerCubicMeter, 1, EnergyDensityUnit.GigajoulePerCubicMeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, EnergyDensityUnit unitA, double valueB, EnergyDensityUnit unitB, bool expectEqual) { var a = new EnergyDensity(valueA, unitA); @@ -1033,7 +1031,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = EnergyDensity.FromJoulesPerCubicMeter(1.0); - Assert.Equal(new {EnergyDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(EnergyDensity.Info.Name, quantity.JoulesPerCubicMeter); + #else + var expected = new {EnergyDensity.Info.Name, valueInBaseUnit = quantity.JoulesPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 7595d23197..e5f566189c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -222,7 +222,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EnergyUnit.Joule, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Energy(double.PositiveInfinity, EnergyUnit.Joule)); @@ -232,7 +232,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Energy(double.NaN, EnergyUnit.Joule)); @@ -486,7 +486,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoules_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Energy.FromJoules(double.PositiveInfinity)); @@ -496,7 +496,7 @@ public void FromJoules_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoules_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Energy.FromJoules(double.NaN)); @@ -2173,8 +2173,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, EnergyUnit.Joule, 1, EnergyUnit.Joule, true)] // Same value and unit. [InlineData(1, EnergyUnit.Joule, 2, EnergyUnit.Joule, false)] // Different value. - [InlineData(2, EnergyUnit.Joule, 1, EnergyUnit.BritishThermalUnit, false)] // Different value and unit. - [InlineData(1, EnergyUnit.Joule, 1, EnergyUnit.BritishThermalUnit, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, EnergyUnit unitA, double valueB, EnergyUnit unitB, bool expectEqual) { var a = new Energy(valueA, unitA); @@ -2551,7 +2549,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Energy.FromJoules(1.0); - Assert.Equal(new {Energy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Energy.Info.Name, quantity.Joules); + #else + var expected = new {Energy.Info.Name, valueInBaseUnit = quantity.Joules}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 716f46113e..321bf94ebf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -90,7 +90,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EntropyUnit.JoulePerKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Entropy(double.PositiveInfinity, EntropyUnit.JoulePerKelvin)); @@ -100,7 +100,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Entropy(double.NaN, EntropyUnit.JoulePerKelvin)); @@ -189,7 +189,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Entropy.FromJoulesPerKelvin(double.PositiveInfinity)); @@ -199,7 +199,7 @@ public void FromJoulesPerKelvin_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Entropy.FromJoulesPerKelvin(double.NaN)); @@ -536,8 +536,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, EntropyUnit.JoulePerKelvin, 1, EntropyUnit.JoulePerKelvin, true)] // Same value and unit. [InlineData(1, EntropyUnit.JoulePerKelvin, 2, EntropyUnit.JoulePerKelvin, false)] // Different value. - [InlineData(2, EntropyUnit.JoulePerKelvin, 1, EntropyUnit.CaloriePerKelvin, false)] // Different value and unit. - [InlineData(1, EntropyUnit.JoulePerKelvin, 1, EntropyUnit.CaloriePerKelvin, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, EntropyUnit unitA, double valueB, EntropyUnit unitB, bool expectEqual) { var a = new Entropy(valueA, unitA); @@ -848,7 +846,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(new {Entropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Entropy.Info.Name, quantity.JoulesPerKelvin); + #else + var expected = new {Entropy.Info.Name, valueInBaseUnit = quantity.JoulesPerKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 9fb05c1c41..8800ef9321 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -122,7 +122,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceChangeRateUnit.NewtonPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ForceChangeRate(double.PositiveInfinity, ForceChangeRateUnit.NewtonPerSecond)); @@ -132,7 +132,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ForceChangeRate(double.NaN, ForceChangeRateUnit.NewtonPerSecond)); @@ -261,7 +261,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ForceChangeRate.FromNewtonsPerSecond(double.PositiveInfinity)); @@ -271,7 +271,7 @@ public void FromNewtonsPerSecond_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ForceChangeRate.FromNewtonsPerSecond(double.NaN)); @@ -912,8 +912,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ForceChangeRateUnit.NewtonPerSecond, 1, ForceChangeRateUnit.NewtonPerSecond, true)] // Same value and unit. [InlineData(1, ForceChangeRateUnit.NewtonPerSecond, 2, ForceChangeRateUnit.NewtonPerSecond, false)] // Different value. - [InlineData(2, ForceChangeRateUnit.NewtonPerSecond, 1, ForceChangeRateUnit.CentinewtonPerSecond, false)] // Different value and unit. - [InlineData(1, ForceChangeRateUnit.NewtonPerSecond, 1, ForceChangeRateUnit.CentinewtonPerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ForceChangeRateUnit unitA, double valueB, ForceChangeRateUnit unitB, bool expectEqual) { var a = new ForceChangeRate(valueA, unitA); @@ -1240,7 +1238,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(new {ForceChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ForceChangeRate.Info.Name, quantity.NewtonsPerSecond); + #else + var expected = new {ForceChangeRate.Info.Name, valueInBaseUnit = quantity.NewtonsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 647e0eb1fc..2aaef7e741 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -214,7 +214,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ForcePerLength(double.PositiveInfinity, ForcePerLengthUnit.NewtonPerMeter)); @@ -224,7 +224,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ForcePerLength(double.NaN, ForcePerLengthUnit.NewtonPerMeter)); @@ -468,7 +468,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ForcePerLength.FromNewtonsPerMeter(double.PositiveInfinity)); @@ -478,7 +478,7 @@ public void FromNewtonsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ForcePerLength.FromNewtonsPerMeter(double.NaN)); @@ -1795,8 +1795,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ForcePerLengthUnit.NewtonPerMeter, 1, ForcePerLengthUnit.NewtonPerMeter, true)] // Same value and unit. [InlineData(1, ForcePerLengthUnit.NewtonPerMeter, 2, ForcePerLengthUnit.NewtonPerMeter, false)] // Different value. - [InlineData(2, ForcePerLengthUnit.NewtonPerMeter, 1, ForcePerLengthUnit.CentinewtonPerCentimeter, false)] // Different value and unit. - [InlineData(1, ForcePerLengthUnit.NewtonPerMeter, 1, ForcePerLengthUnit.CentinewtonPerCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ForcePerLengthUnit unitA, double valueB, ForcePerLengthUnit unitB, bool expectEqual) { var a = new ForcePerLength(valueA, unitA); @@ -2169,7 +2167,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(new {ForcePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ForcePerLength.Info.Name, quantity.NewtonsPerMeter); + #else + var expected = new {ForcePerLength.Info.Name, valueInBaseUnit = quantity.NewtonsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 972e275bfb..3db5fdb3b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -122,7 +122,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceUnit.Newton, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Force(double.PositiveInfinity, ForceUnit.Newton)); @@ -132,7 +132,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Force(double.NaN, ForceUnit.Newton)); @@ -261,7 +261,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtons_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Force.FromNewtons(double.PositiveInfinity)); @@ -271,7 +271,7 @@ public void FromNewtons_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtons_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Force.FromNewtons(double.NaN)); @@ -1230,8 +1230,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ForceUnit.Newton, 1, ForceUnit.Newton, true)] // Same value and unit. [InlineData(1, ForceUnit.Newton, 2, ForceUnit.Newton, false)] // Different value. - [InlineData(2, ForceUnit.Newton, 1, ForceUnit.Decanewton, false)] // Different value and unit. - [InlineData(1, ForceUnit.Newton, 1, ForceUnit.Decanewton, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ForceUnit unitA, double valueB, ForceUnit unitB, bool expectEqual) { var a = new Force(valueA, unitA); @@ -1558,7 +1556,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Force.FromNewtons(1.0); - Assert.Equal(new {Force.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Force.Info.Name, quantity.Newtons); + #else + var expected = new {Force.Info.Name, valueInBaseUnit = quantity.Newtons}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 232ea244c9..0bf93a090f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -114,7 +114,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FrequencyUnit.Hertz, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Frequency(double.PositiveInfinity, FrequencyUnit.Hertz)); @@ -124,7 +124,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Frequency(double.NaN, FrequencyUnit.Hertz)); @@ -243,7 +243,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHertz_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Frequency.FromHertz(double.PositiveInfinity)); @@ -253,7 +253,7 @@ public void FromHertz_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHertz_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Frequency.FromHertz(double.NaN)); @@ -918,8 +918,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, FrequencyUnit.Hertz, 1, FrequencyUnit.Hertz, true)] // Same value and unit. [InlineData(1, FrequencyUnit.Hertz, 2, FrequencyUnit.Hertz, false)] // Different value. - [InlineData(2, FrequencyUnit.Hertz, 1, FrequencyUnit.BeatPerMinute, false)] // Different value and unit. - [InlineData(1, FrequencyUnit.Hertz, 1, FrequencyUnit.BeatPerMinute, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, FrequencyUnit unitA, double valueB, FrequencyUnit unitB, bool expectEqual) { var a = new Frequency(valueA, unitA); @@ -1242,7 +1240,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(new {Frequency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Frequency.Info.Name, quantity.Hertz); + #else + var expected = new {Frequency.Info.Name, valueInBaseUnit = quantity.Hertz}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 6f5a23ad6e..2760dab409 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FuelEfficiencyUnit.LiterPer100Kilometers, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new FuelEfficiency(double.PositiveInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new FuelEfficiency(double.NaN, FuelEfficiencyUnit.LiterPer100Kilometers)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLitersPer100Kilometers_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => FuelEfficiency.FromLitersPer100Kilometers(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromLitersPer100Kilometers_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLitersPer100Kilometers_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => FuelEfficiency.FromLitersPer100Kilometers(double.NaN)); @@ -431,8 +431,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, FuelEfficiencyUnit.LiterPer100Kilometers, 1, FuelEfficiencyUnit.LiterPer100Kilometers, true)] // Same value and unit. [InlineData(1, FuelEfficiencyUnit.LiterPer100Kilometers, 2, FuelEfficiencyUnit.LiterPer100Kilometers, false)] // Different value. - [InlineData(2, FuelEfficiencyUnit.LiterPer100Kilometers, 1, FuelEfficiencyUnit.KilometerPerLiter, false)] // Different value and unit. - [InlineData(1, FuelEfficiencyUnit.LiterPer100Kilometers, 1, FuelEfficiencyUnit.KilometerPerLiter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, FuelEfficiencyUnit unitA, double valueB, FuelEfficiencyUnit unitB, bool expectEqual) { var a = new FuelEfficiency(valueA, unitA); @@ -737,7 +735,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(new {FuelEfficiency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(FuelEfficiency.Info.Name, quantity.LitersPer100Kilometers); + #else + var expected = new {FuelEfficiency.Info.Name, valueInBaseUnit = quantity.LitersPer100Kilometers}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index c4c41efbf5..5b02c267ed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -134,7 +134,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatFluxUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new HeatFlux(double.PositiveInfinity, HeatFluxUnit.WattPerSquareMeter)); @@ -144,7 +144,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new HeatFlux(double.NaN, HeatFluxUnit.WattPerSquareMeter)); @@ -288,7 +288,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => HeatFlux.FromWattsPerSquareMeter(double.PositiveInfinity)); @@ -298,7 +298,7 @@ public void FromWattsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => HeatFlux.FromWattsPerSquareMeter(double.NaN)); @@ -945,8 +945,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, HeatFluxUnit.WattPerSquareMeter, 1, HeatFluxUnit.WattPerSquareMeter, true)] // Same value and unit. [InlineData(1, HeatFluxUnit.WattPerSquareMeter, 2, HeatFluxUnit.WattPerSquareMeter, false)] // Different value. - [InlineData(2, HeatFluxUnit.WattPerSquareMeter, 1, HeatFluxUnit.BtuPerHourSquareFoot, false)] // Different value and unit. - [InlineData(1, HeatFluxUnit.WattPerSquareMeter, 1, HeatFluxUnit.BtuPerHourSquareFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, HeatFluxUnit unitA, double valueB, HeatFluxUnit unitB, bool expectEqual) { var a = new HeatFlux(valueA, unitA); @@ -1279,7 +1277,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {HeatFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(HeatFlux.Info.Name, quantity.WattsPerSquareMeter); + #else + var expected = new {HeatFlux.Info.Name, valueInBaseUnit = quantity.WattsPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 18f60db9ae..2d5715a6fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new HeatTransferCoefficient(double.PositiveInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new HeatTransferCoefficient(double.NaN, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeterKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromWattsPerSquareMeterKelvin_WithInfinityValue_DoNotThrowsArgumentE Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeterKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NaN)); @@ -682,8 +682,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, 1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, true)] // Same value and unit. [InlineData(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, 2, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, false)] // Different value. - [InlineData(2, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, 1, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, false)] // Different value and unit. - [InlineData(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, 1, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, HeatTransferCoefficientUnit unitA, double valueB, HeatTransferCoefficientUnit unitB, bool expectEqual) { var a = new HeatTransferCoefficient(valueA, unitA); @@ -990,7 +988,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(new {HeatTransferCoefficient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(HeatTransferCoefficient.Info.Name, quantity.WattsPerSquareMeterKelvin); + #else + var expected = new {HeatTransferCoefficient.Info.Name, valueInBaseUnit = quantity.WattsPerSquareMeterKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 138a4da00d..5a65ec4aaa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IlluminanceUnit.Lux, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Illuminance(double.PositiveInfinity, IlluminanceUnit.Lux)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Illuminance(double.NaN, IlluminanceUnit.Lux)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLux_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Illuminance.FromLux(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromLux_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLux_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Illuminance.FromLux(double.NaN)); @@ -409,8 +409,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, IlluminanceUnit.Lux, 1, IlluminanceUnit.Lux, true)] // Same value and unit. [InlineData(1, IlluminanceUnit.Lux, 2, IlluminanceUnit.Lux, false)] // Different value. - [InlineData(2, IlluminanceUnit.Lux, 1, IlluminanceUnit.Kilolux, false)] // Different value and unit. - [InlineData(1, IlluminanceUnit.Lux, 1, IlluminanceUnit.Kilolux, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, IlluminanceUnit unitA, double valueB, IlluminanceUnit unitB, bool expectEqual) { var a = new Illuminance(valueA, unitA); @@ -715,7 +713,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(new {Illuminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Illuminance.Info.Name, quantity.Lux); + #else + var expected = new {Illuminance.Info.Name, valueInBaseUnit = quantity.Lux}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs index e01d2b3df0..fb886696f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ImpulseTestsBase.g.cs @@ -114,7 +114,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ImpulseUnit.NewtonSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Impulse(double.PositiveInfinity, ImpulseUnit.NewtonSecond)); @@ -124,7 +124,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Impulse(double.NaN, ImpulseUnit.NewtonSecond)); @@ -243,7 +243,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonSeconds_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Impulse.FromNewtonSeconds(double.PositiveInfinity)); @@ -253,7 +253,7 @@ public void FromNewtonSeconds_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonSeconds_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Impulse.FromNewtonSeconds(double.NaN)); @@ -724,8 +724,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ImpulseUnit.NewtonSecond, 1, ImpulseUnit.NewtonSecond, true)] // Same value and unit. [InlineData(1, ImpulseUnit.NewtonSecond, 2, ImpulseUnit.NewtonSecond, false)] // Different value. - [InlineData(2, ImpulseUnit.NewtonSecond, 1, ImpulseUnit.CentinewtonSecond, false)] // Different value and unit. - [InlineData(1, ImpulseUnit.NewtonSecond, 1, ImpulseUnit.CentinewtonSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ImpulseUnit unitA, double valueB, ImpulseUnit unitB, bool expectEqual) { var a = new Impulse(valueA, unitA); @@ -1048,7 +1046,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Impulse.FromNewtonSeconds(1.0); - Assert.Equal(new {Impulse.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Impulse.Info.Name, quantity.NewtonSeconds); + #else + var expected = new {Impulse.Info.Name, valueInBaseUnit = quantity.NewtonSeconds}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index dc482d26f1..4a4d69e90c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -166,7 +166,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(InformationUnit.Bit, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Information(double.PositiveInfinity, InformationUnit.Bit)); @@ -176,7 +176,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Information(double.NaN, InformationUnit.Bit)); @@ -360,7 +360,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBits_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Information.FromBits(double.PositiveInfinity)); @@ -370,7 +370,7 @@ public void FromBits_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBits_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Information.FromBits(double.NaN)); @@ -915,8 +915,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, InformationUnit.Bit, 1, InformationUnit.Bit, true)] // Same value and unit. [InlineData(1, InformationUnit.Bit, 2, InformationUnit.Bit, false)] // Different value. - [InlineData(2, InformationUnit.Bit, 1, InformationUnit.Byte, false)] // Different value and unit. - [InlineData(1, InformationUnit.Bit, 1, InformationUnit.Byte, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, InformationUnit unitA, double valueB, InformationUnit unitB, bool expectEqual) { var a = new Information(valueA, unitA); @@ -1265,7 +1263,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Information.FromBits(1.0); - Assert.Equal(new {Information.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Information.Info.Name, quantity.Bits); + #else + var expected = new {Information.Info.Name, valueInBaseUnit = quantity.Bits}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 8e586edca8..85225505ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradianceUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Irradiance(double.PositiveInfinity, IrradianceUnit.WattPerSquareMeter)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Irradiance(double.NaN, IrradianceUnit.WattPerSquareMeter)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Irradiance.FromWattsPerSquareMeter(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromWattsPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Irradiance.FromWattsPerSquareMeter(double.NaN)); @@ -737,8 +737,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, IrradianceUnit.WattPerSquareMeter, 1, IrradianceUnit.WattPerSquareMeter, true)] // Same value and unit. [InlineData(1, IrradianceUnit.WattPerSquareMeter, 2, IrradianceUnit.WattPerSquareMeter, false)] // Different value. - [InlineData(2, IrradianceUnit.WattPerSquareMeter, 1, IrradianceUnit.KilowattPerSquareCentimeter, false)] // Different value and unit. - [InlineData(1, IrradianceUnit.WattPerSquareMeter, 1, IrradianceUnit.KilowattPerSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, IrradianceUnit unitA, double valueB, IrradianceUnit unitB, bool expectEqual) { var a = new Irradiance(valueA, unitA); @@ -1063,7 +1061,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {Irradiance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Irradiance.Info.Name, quantity.WattsPerSquareMeter); + #else + var expected = new {Irradiance.Info.Name, valueInBaseUnit = quantity.WattsPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 30024603b2..efd9e932e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -38,18 +38,22 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class IrradiationTestsBase : QuantityTestsBase { + protected abstract double BtusPerSquareFootInOneJoulePerSquareMeter { get; } protected abstract double JoulesPerSquareCentimeterInOneJoulePerSquareMeter { get; } protected abstract double JoulesPerSquareMeterInOneJoulePerSquareMeter { get; } protected abstract double JoulesPerSquareMillimeterInOneJoulePerSquareMeter { get; } + protected abstract double KilobtusPerSquareFootInOneJoulePerSquareMeter { get; } protected abstract double KilojoulesPerSquareMeterInOneJoulePerSquareMeter { get; } protected abstract double KilowattHoursPerSquareMeterInOneJoulePerSquareMeter { get; } protected abstract double MillijoulesPerSquareCentimeterInOneJoulePerSquareMeter { get; } protected abstract double WattHoursPerSquareMeterInOneJoulePerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BtusPerSquareFootTolerance { get { return 1e-5; } } protected virtual double JoulesPerSquareCentimeterTolerance { get { return 1e-5; } } protected virtual double JoulesPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double JoulesPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilobtusPerSquareFootTolerance { get { return 1e-5; } } protected virtual double KilojoulesPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double MillijoulesPerSquareCentimeterTolerance { get { return 1e-5; } } @@ -60,9 +64,11 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase { return unit switch { + IrradiationUnit.BtuPerSquareFoot => (BtusPerSquareFootInOneJoulePerSquareMeter, BtusPerSquareFootTolerance), IrradiationUnit.JoulePerSquareCentimeter => (JoulesPerSquareCentimeterInOneJoulePerSquareMeter, JoulesPerSquareCentimeterTolerance), IrradiationUnit.JoulePerSquareMeter => (JoulesPerSquareMeterInOneJoulePerSquareMeter, JoulesPerSquareMeterTolerance), IrradiationUnit.JoulePerSquareMillimeter => (JoulesPerSquareMillimeterInOneJoulePerSquareMeter, JoulesPerSquareMillimeterTolerance), + IrradiationUnit.KilobtuPerSquareFoot => (KilobtusPerSquareFootInOneJoulePerSquareMeter, KilobtusPerSquareFootTolerance), IrradiationUnit.KilojoulePerSquareMeter => (KilojoulesPerSquareMeterInOneJoulePerSquareMeter, KilojoulesPerSquareMeterTolerance), IrradiationUnit.KilowattHourPerSquareMeter => (KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, KilowattHoursPerSquareMeterTolerance), IrradiationUnit.MillijoulePerSquareCentimeter => (MillijoulesPerSquareCentimeterInOneJoulePerSquareMeter, MillijoulesPerSquareCentimeterTolerance), @@ -73,9 +79,11 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase public static IEnumerable UnitTypes = new List { + new object[] { IrradiationUnit.BtuPerSquareFoot }, new object[] { IrradiationUnit.JoulePerSquareCentimeter }, new object[] { IrradiationUnit.JoulePerSquareMeter }, new object[] { IrradiationUnit.JoulePerSquareMillimeter }, + new object[] { IrradiationUnit.KilobtuPerSquareFoot }, new object[] { IrradiationUnit.KilojoulePerSquareMeter }, new object[] { IrradiationUnit.KilowattHourPerSquareMeter }, new object[] { IrradiationUnit.MillijoulePerSquareCentimeter }, @@ -90,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Irradiation(double.PositiveInfinity, IrradiationUnit.JoulePerSquareMeter)); @@ -100,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Irradiation(double.NaN, IrradiationUnit.JoulePerSquareMeter)); @@ -147,9 +155,11 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() public void JoulePerSquareMeterToIrradiationUnits() { Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + AssertEx.EqualTolerance(BtusPerSquareFootInOneJoulePerSquareMeter, joulepersquaremeter.BtusPerSquareFoot, BtusPerSquareFootTolerance); AssertEx.EqualTolerance(JoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMillimeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareMillimeter, JoulesPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(KilobtusPerSquareFootInOneJoulePerSquareMeter, joulepersquaremeter.KilobtusPerSquareFoot, KilobtusPerSquareFootTolerance); AssertEx.EqualTolerance(KilojoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.KilojoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance); AssertEx.EqualTolerance(MillijoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.MillijoulesPerSquareCentimeter, MillijoulesPerSquareCentimeterTolerance); @@ -159,37 +169,45 @@ public void JoulePerSquareMeterToIrradiationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Irradiation.From(1, IrradiationUnit.JoulePerSquareCentimeter); - AssertEx.EqualTolerance(1, quantity00.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); - Assert.Equal(IrradiationUnit.JoulePerSquareCentimeter, quantity00.Unit); + var quantity00 = Irradiation.From(1, IrradiationUnit.BtuPerSquareFoot); + AssertEx.EqualTolerance(1, quantity00.BtusPerSquareFoot, BtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.BtuPerSquareFoot, quantity00.Unit); + + var quantity01 = Irradiation.From(1, IrradiationUnit.JoulePerSquareCentimeter); + AssertEx.EqualTolerance(1, quantity01.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); + Assert.Equal(IrradiationUnit.JoulePerSquareCentimeter, quantity01.Unit); - var quantity01 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMeter); - AssertEx.EqualTolerance(1, quantity01.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); - Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity01.Unit); + var quantity02 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMeter); + AssertEx.EqualTolerance(1, quantity02.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); + Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity02.Unit); - var quantity02 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMillimeter); - AssertEx.EqualTolerance(1, quantity02.JoulesPerSquareMillimeter, JoulesPerSquareMillimeterTolerance); - Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, quantity02.Unit); + var quantity03 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMillimeter); + AssertEx.EqualTolerance(1, quantity03.JoulesPerSquareMillimeter, JoulesPerSquareMillimeterTolerance); + Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, quantity03.Unit); - var quantity03 = Irradiation.From(1, IrradiationUnit.KilojoulePerSquareMeter); - AssertEx.EqualTolerance(1, quantity03.KilojoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); - Assert.Equal(IrradiationUnit.KilojoulePerSquareMeter, quantity03.Unit); + var quantity04 = Irradiation.From(1, IrradiationUnit.KilobtuPerSquareFoot); + AssertEx.EqualTolerance(1, quantity04.KilobtusPerSquareFoot, KilobtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.KilobtuPerSquareFoot, quantity04.Unit); - var quantity04 = Irradiation.From(1, IrradiationUnit.KilowattHourPerSquareMeter); - AssertEx.EqualTolerance(1, quantity04.KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance); - Assert.Equal(IrradiationUnit.KilowattHourPerSquareMeter, quantity04.Unit); + var quantity05 = Irradiation.From(1, IrradiationUnit.KilojoulePerSquareMeter); + AssertEx.EqualTolerance(1, quantity05.KilojoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); + Assert.Equal(IrradiationUnit.KilojoulePerSquareMeter, quantity05.Unit); - var quantity05 = Irradiation.From(1, IrradiationUnit.MillijoulePerSquareCentimeter); - AssertEx.EqualTolerance(1, quantity05.MillijoulesPerSquareCentimeter, MillijoulesPerSquareCentimeterTolerance); - Assert.Equal(IrradiationUnit.MillijoulePerSquareCentimeter, quantity05.Unit); + var quantity06 = Irradiation.From(1, IrradiationUnit.KilowattHourPerSquareMeter); + AssertEx.EqualTolerance(1, quantity06.KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance); + Assert.Equal(IrradiationUnit.KilowattHourPerSquareMeter, quantity06.Unit); - var quantity06 = Irradiation.From(1, IrradiationUnit.WattHourPerSquareMeter); - AssertEx.EqualTolerance(1, quantity06.WattHoursPerSquareMeter, WattHoursPerSquareMeterTolerance); - Assert.Equal(IrradiationUnit.WattHourPerSquareMeter, quantity06.Unit); + var quantity07 = Irradiation.From(1, IrradiationUnit.MillijoulePerSquareCentimeter); + AssertEx.EqualTolerance(1, quantity07.MillijoulesPerSquareCentimeter, MillijoulesPerSquareCentimeterTolerance); + Assert.Equal(IrradiationUnit.MillijoulePerSquareCentimeter, quantity07.Unit); + + var quantity08 = Irradiation.From(1, IrradiationUnit.WattHourPerSquareMeter); + AssertEx.EqualTolerance(1, quantity08.WattHoursPerSquareMeter, WattHoursPerSquareMeterTolerance); + Assert.Equal(IrradiationUnit.WattHourPerSquareMeter, quantity08.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Irradiation.FromJoulesPerSquareMeter(double.PositiveInfinity)); @@ -199,7 +217,7 @@ public void FromJoulesPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Irradiation.FromJoulesPerSquareMeter(double.NaN)); @@ -211,9 +229,11 @@ public void FromJoulesPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() public void As() { var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + AssertEx.EqualTolerance(BtusPerSquareFootInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.BtuPerSquareFoot), BtusPerSquareFootTolerance); AssertEx.EqualTolerance(JoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareCentimeter), JoulesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareMeter), JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMillimeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareMillimeter), JoulesPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(KilobtusPerSquareFootInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.KilobtuPerSquareFoot), KilobtusPerSquareFootTolerance); AssertEx.EqualTolerance(KilojoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.KilojoulePerSquareMeter), KilojoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(KilowattHoursPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.KilowattHourPerSquareMeter), KilowattHoursPerSquareMeterTolerance); AssertEx.EqualTolerance(MillijoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.MillijoulePerSquareCentimeter), MillijoulesPerSquareCentimeterTolerance); @@ -240,6 +260,13 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void Parse() { + try + { + var parsed = Irradiation.Parse("1 Btu/ft²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.BtusPerSquareFoot, BtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.BtuPerSquareFoot, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = Irradiation.Parse("1 J/cm²", CultureInfo.GetCultureInfo("en-US")); @@ -261,6 +288,13 @@ public void Parse() Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = Irradiation.Parse("1 kBtu/ft²", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.KilobtusPerSquareFoot, KilobtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.KilobtuPerSquareFoot, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = Irradiation.Parse("1 kJ/m²", CultureInfo.GetCultureInfo("en-US")); @@ -294,6 +328,12 @@ public void Parse() [Fact] public void TryParse() { + { + Assert.True(Irradiation.TryParse("1 Btu/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.BtusPerSquareFoot, BtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.BtuPerSquareFoot, parsed.Unit); + } + { Assert.True(Irradiation.TryParse("1 J/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); @@ -312,6 +352,12 @@ public void TryParse() Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, parsed.Unit); } + { + Assert.True(Irradiation.TryParse("1 kBtu/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.KilobtusPerSquareFoot, KilobtusPerSquareFootTolerance); + Assert.Equal(IrradiationUnit.KilobtuPerSquareFoot, parsed.Unit); + } + { Assert.True(Irradiation.TryParse("1 kJ/m²", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.KilojoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); @@ -341,6 +387,12 @@ public void TryParse() [Fact] public void ParseUnit() { + try + { + var parsedUnit = Irradiation.ParseUnit("Btu/ft²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(IrradiationUnit.BtuPerSquareFoot, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = Irradiation.ParseUnit("J/cm²", CultureInfo.GetCultureInfo("en-US")); @@ -359,6 +411,12 @@ public void ParseUnit() Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = Irradiation.ParseUnit("kBtu/ft²", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(IrradiationUnit.KilobtuPerSquareFoot, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = Irradiation.ParseUnit("kJ/m²", CultureInfo.GetCultureInfo("en-US")); @@ -388,6 +446,11 @@ public void ParseUnit() [Fact] public void TryParseUnit() { + { + Assert.True(Irradiation.TryParseUnit("Btu/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(IrradiationUnit.BtuPerSquareFoot, parsedUnit); + } + { Assert.True(Irradiation.TryParseUnit("J/cm²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(IrradiationUnit.JoulePerSquareCentimeter, parsedUnit); @@ -403,6 +466,11 @@ public void TryParseUnit() Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, parsedUnit); } + { + Assert.True(Irradiation.TryParseUnit("kBtu/ft²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(IrradiationUnit.KilobtuPerSquareFoot, parsedUnit); + } + { Assert.True(Irradiation.TryParseUnit("kJ/m²", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(IrradiationUnit.KilojoulePerSquareMeter, parsedUnit); @@ -471,9 +539,11 @@ public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(Irra public void ConversionRoundTrip() { Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + AssertEx.EqualTolerance(1, Irradiation.FromBtusPerSquareFoot(joulepersquaremeter.BtusPerSquareFoot).JoulesPerSquareMeter, BtusPerSquareFootTolerance); AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareCentimeter(joulepersquaremeter.JoulesPerSquareCentimeter).JoulesPerSquareMeter, JoulesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMeter(joulepersquaremeter.JoulesPerSquareMeter).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMillimeter(joulepersquaremeter.JoulesPerSquareMillimeter).JoulesPerSquareMeter, JoulesPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromKilobtusPerSquareFoot(joulepersquaremeter.KilobtusPerSquareFoot).JoulesPerSquareMeter, KilobtusPerSquareFootTolerance); AssertEx.EqualTolerance(1, Irradiation.FromKilojoulesPerSquareMeter(joulepersquaremeter.KilojoulesPerSquareMeter).JoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Irradiation.FromKilowattHoursPerSquareMeter(joulepersquaremeter.KilowattHoursPerSquareMeter).JoulesPerSquareMeter, KilowattHoursPerSquareMeterTolerance); AssertEx.EqualTolerance(1, Irradiation.FromMillijoulesPerSquareCentimeter(joulepersquaremeter.MillijoulesPerSquareCentimeter).JoulesPerSquareMeter, MillijoulesPerSquareCentimeterTolerance); @@ -536,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, IrradiationUnit.JoulePerSquareMeter, 1, IrradiationUnit.JoulePerSquareMeter, true)] // Same value and unit. [InlineData(1, IrradiationUnit.JoulePerSquareMeter, 2, IrradiationUnit.JoulePerSquareMeter, false)] // Different value. - [InlineData(2, IrradiationUnit.JoulePerSquareMeter, 1, IrradiationUnit.JoulePerSquareCentimeter, false)] // Different value and unit. - [InlineData(1, IrradiationUnit.JoulePerSquareMeter, 1, IrradiationUnit.JoulePerSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, IrradiationUnit unitA, double valueB, IrradiationUnit unitB, bool expectEqual) { var a = new Irradiation(valueA, unitA); @@ -625,9 +693,11 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() var prevCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { + Assert.Equal("1 Btu/ft²", new Irradiation(1, IrradiationUnit.BtuPerSquareFoot).ToString()); Assert.Equal("1 J/cm²", new Irradiation(1, IrradiationUnit.JoulePerSquareCentimeter).ToString()); Assert.Equal("1 J/m²", new Irradiation(1, IrradiationUnit.JoulePerSquareMeter).ToString()); Assert.Equal("1 J/mm²", new Irradiation(1, IrradiationUnit.JoulePerSquareMillimeter).ToString()); + Assert.Equal("1 kBtu/ft²", new Irradiation(1, IrradiationUnit.KilobtuPerSquareFoot).ToString()); Assert.Equal("1 kJ/m²", new Irradiation(1, IrradiationUnit.KilojoulePerSquareMeter).ToString()); Assert.Equal("1 kWh/m²", new Irradiation(1, IrradiationUnit.KilowattHourPerSquareMeter).ToString()); Assert.Equal("1 mJ/cm²", new Irradiation(1, IrradiationUnit.MillijoulePerSquareCentimeter).ToString()); @@ -645,9 +715,11 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture // Chose this culture, because we don't currently have any abbreviations mapped for that culture and we expect the en-US to be used as fallback. var swedishCulture = CultureInfo.GetCultureInfo("sv-SE"); + Assert.Equal("1 Btu/ft²", new Irradiation(1, IrradiationUnit.BtuPerSquareFoot).ToString(swedishCulture)); Assert.Equal("1 J/cm²", new Irradiation(1, IrradiationUnit.JoulePerSquareCentimeter).ToString(swedishCulture)); Assert.Equal("1 J/m²", new Irradiation(1, IrradiationUnit.JoulePerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 J/mm²", new Irradiation(1, IrradiationUnit.JoulePerSquareMillimeter).ToString(swedishCulture)); + Assert.Equal("1 kBtu/ft²", new Irradiation(1, IrradiationUnit.KilobtuPerSquareFoot).ToString(swedishCulture)); Assert.Equal("1 kJ/m²", new Irradiation(1, IrradiationUnit.KilojoulePerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 kWh/m²", new Irradiation(1, IrradiationUnit.KilowattHourPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 mJ/cm²", new Irradiation(1, IrradiationUnit.MillijoulePerSquareCentimeter).ToString(swedishCulture)); @@ -848,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(new {Irradiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Irradiation.Info.Name, quantity.JoulesPerSquareMeter); + #else + var expected = new {Irradiation.Info.Name, valueInBaseUnit = quantity.JoulesPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index eb0754c789..6cef4eb453 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -106,7 +106,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(JerkUnit.MeterPerSecondCubed, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Jerk(double.PositiveInfinity, JerkUnit.MeterPerSecondCubed)); @@ -116,7 +116,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Jerk(double.NaN, JerkUnit.MeterPerSecondCubed)); @@ -225,7 +225,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecondCubed_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Jerk.FromMetersPerSecondCubed(double.PositiveInfinity)); @@ -235,7 +235,7 @@ public void FromMetersPerSecondCubed_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecondCubed_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Jerk.FromMetersPerSecondCubed(double.NaN)); @@ -940,8 +940,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, JerkUnit.MeterPerSecondCubed, 1, JerkUnit.MeterPerSecondCubed, true)] // Same value and unit. [InlineData(1, JerkUnit.MeterPerSecondCubed, 2, JerkUnit.MeterPerSecondCubed, false)] // Different value. - [InlineData(2, JerkUnit.MeterPerSecondCubed, 1, JerkUnit.CentimeterPerSecondCubed, false)] // Different value and unit. - [InlineData(1, JerkUnit.MeterPerSecondCubed, 1, JerkUnit.CentimeterPerSecondCubed, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, JerkUnit unitA, double valueB, JerkUnit unitB, bool expectEqual) { var a = new Jerk(valueA, unitA); @@ -1260,7 +1258,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal(new {Jerk.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Jerk.Info.Name, quantity.MetersPerSecondCubed); + #else + var expected = new {Jerk.Info.Name, valueInBaseUnit = quantity.MetersPerSecondCubed}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 94b9ea9dfe..9e6b2ce572 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new KinematicViscosity(double.PositiveInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new KinematicViscosity(double.NaN, KinematicViscosityUnit.SquareMeterPerSecond)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => KinematicViscosity.FromSquareMetersPerSecond(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromSquareMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentExcep Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMetersPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => KinematicViscosity.FromSquareMetersPerSecond(double.NaN)); @@ -798,8 +798,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, KinematicViscosityUnit.SquareMeterPerSecond, 1, KinematicViscosityUnit.SquareMeterPerSecond, true)] // Same value and unit. [InlineData(1, KinematicViscosityUnit.SquareMeterPerSecond, 2, KinematicViscosityUnit.SquareMeterPerSecond, false)] // Different value. - [InlineData(2, KinematicViscosityUnit.SquareMeterPerSecond, 1, KinematicViscosityUnit.Centistokes, false)] // Different value and unit. - [InlineData(1, KinematicViscosityUnit.SquareMeterPerSecond, 1, KinematicViscosityUnit.Centistokes, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, KinematicViscosityUnit unitA, double valueB, KinematicViscosityUnit unitB, bool expectEqual) { var a = new KinematicViscosity(valueA, unitA); @@ -1114,7 +1112,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(new {KinematicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(KinematicViscosity.Info.Name, quantity.SquareMetersPerSecond); + #else + var expected = new {KinematicViscosity.Info.Name, valueInBaseUnit = quantity.SquareMetersPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs index 4ed4d28b79..b6bee0f2af 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LeakRateTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LeakRateUnit.PascalCubicMeterPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new LeakRate(double.PositiveInfinity, LeakRateUnit.PascalCubicMeterPerSecond)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new LeakRate(double.NaN, LeakRateUnit.PascalCubicMeterPerSecond)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascalCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => LeakRate.FromPascalCubicMetersPerSecond(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromPascalCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgument Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascalCubicMetersPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => LeakRate.FromPascalCubicMetersPerSecond(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LeakRateUnit.PascalCubicMeterPerSecond, 1, LeakRateUnit.PascalCubicMeterPerSecond, true)] // Same value and unit. [InlineData(1, LeakRateUnit.PascalCubicMeterPerSecond, 2, LeakRateUnit.PascalCubicMeterPerSecond, false)] // Different value. - [InlineData(2, LeakRateUnit.PascalCubicMeterPerSecond, 1, LeakRateUnit.MillibarLiterPerSecond, false)] // Different value and unit. - [InlineData(1, LeakRateUnit.PascalCubicMeterPerSecond, 1, LeakRateUnit.MillibarLiterPerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LeakRateUnit unitA, double valueB, LeakRateUnit unitB, bool expectEqual) { var a = new LeakRate(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LeakRate.FromPascalCubicMetersPerSecond(1.0); - Assert.Equal(new {LeakRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(LeakRate.Info.Name, quantity.PascalCubicMetersPerSecond); + #else + var expected = new {LeakRate.Info.Name, valueInBaseUnit = quantity.PascalCubicMetersPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 606906809e..88c8bbf877 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -230,7 +230,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LengthUnit.Meter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Length(double.PositiveInfinity, LengthUnit.Meter)); @@ -240,7 +240,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Length(double.NaN, LengthUnit.Meter)); @@ -504,7 +504,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Length.FromMeters(double.PositiveInfinity)); @@ -514,7 +514,7 @@ public void FromMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Length.FromMeters(double.NaN)); @@ -2835,8 +2835,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LengthUnit.Meter, 1, LengthUnit.Meter, true)] // Same value and unit. [InlineData(1, LengthUnit.Meter, 2, LengthUnit.Meter, false)] // Different value. - [InlineData(2, LengthUnit.Meter, 1, LengthUnit.Angstrom, false)] // Different value and unit. - [InlineData(1, LengthUnit.Meter, 1, LengthUnit.Angstrom, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LengthUnit unitA, double valueB, LengthUnit unitB, bool expectEqual) { var a = new Length(valueA, unitA); @@ -3217,7 +3215,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Length.FromMeters(1.0); - Assert.Equal(new {Length.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Length.Info.Name, quantity.Meters); + #else + var expected = new {Length.Info.Name, valueInBaseUnit = quantity.Meters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index e66e811785..cc683d7b80 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LevelUnit.Decibel, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Level(double.PositiveInfinity, LevelUnit.Decibel)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Level(double.NaN, LevelUnit.Decibel)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibels_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Level.FromDecibels(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromDecibels_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibels_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Level.FromDecibels(double.NaN)); @@ -365,8 +365,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LevelUnit.Decibel, 1, LevelUnit.Decibel, true)] // Same value and unit. [InlineData(1, LevelUnit.Decibel, 2, LevelUnit.Decibel, false)] // Different value. - [InlineData(2, LevelUnit.Decibel, 1, LevelUnit.Neper, false)] // Different value and unit. - [InlineData(1, LevelUnit.Decibel, 1, LevelUnit.Neper, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LevelUnit unitA, double valueB, LevelUnit unitB, bool expectEqual) { var a = new Level(valueA, unitA); @@ -667,7 +665,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Level.FromDecibels(1.0); - Assert.Equal(new {Level.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Level.Info.Name, quantity.Decibels); + #else + var expected = new {Level.Info.Name, valueInBaseUnit = quantity.Decibels}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index ee4d74de2e..eddf277ef8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearDensityUnit.KilogramPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new LinearDensity(double.PositiveInfinity, LinearDensityUnit.KilogramPerMeter)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new LinearDensity(double.NaN, LinearDensityUnit.KilogramPerMeter)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => LinearDensity.FromKilogramsPerMeter(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromKilogramsPerMeter_WithInfinityValue_DoNotThrowsArgumentException Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => LinearDensity.FromKilogramsPerMeter(double.NaN)); @@ -781,8 +781,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LinearDensityUnit.KilogramPerMeter, 1, LinearDensityUnit.KilogramPerMeter, true)] // Same value and unit. [InlineData(1, LinearDensityUnit.KilogramPerMeter, 2, LinearDensityUnit.KilogramPerMeter, false)] // Different value. - [InlineData(2, LinearDensityUnit.KilogramPerMeter, 1, LinearDensityUnit.GramPerCentimeter, false)] // Different value and unit. - [InlineData(1, LinearDensityUnit.KilogramPerMeter, 1, LinearDensityUnit.GramPerCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LinearDensityUnit unitA, double valueB, LinearDensityUnit unitB, bool expectEqual) { var a = new LinearDensity(valueA, unitA); @@ -1107,7 +1105,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(new {LinearDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(LinearDensity.Info.Name, quantity.KilogramsPerMeter); + #else + var expected = new {LinearDensity.Info.Name, valueInBaseUnit = quantity.KilogramsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 285ea7d869..2f45dee524 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -162,7 +162,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearPowerDensityUnit.WattPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new LinearPowerDensity(double.PositiveInfinity, LinearPowerDensityUnit.WattPerMeter)); @@ -172,7 +172,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new LinearPowerDensity(double.NaN, LinearPowerDensityUnit.WattPerMeter)); @@ -351,7 +351,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => LinearPowerDensity.FromWattsPerMeter(double.PositiveInfinity)); @@ -361,7 +361,7 @@ public void FromWattsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => LinearPowerDensity.FromWattsPerMeter(double.NaN)); @@ -1056,8 +1056,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LinearPowerDensityUnit.WattPerMeter, 1, LinearPowerDensityUnit.WattPerMeter, true)] // Same value and unit. [InlineData(1, LinearPowerDensityUnit.WattPerMeter, 2, LinearPowerDensityUnit.WattPerMeter, false)] // Different value. - [InlineData(2, LinearPowerDensityUnit.WattPerMeter, 1, LinearPowerDensityUnit.GigawattPerCentimeter, false)] // Different value and unit. - [InlineData(1, LinearPowerDensityUnit.WattPerMeter, 1, LinearPowerDensityUnit.GigawattPerCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LinearPowerDensityUnit unitA, double valueB, LinearPowerDensityUnit unitB, bool expectEqual) { var a = new LinearPowerDensity(valueA, unitA); @@ -1404,7 +1402,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(new {LinearPowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(LinearPowerDensity.Info.Name, quantity.WattsPerMeter); + #else + var expected = new {LinearPowerDensity.Info.Name, valueInBaseUnit = quantity.WattsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs index f2012f80ec..64feb07a17 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminanceTestsBase.g.cs @@ -102,7 +102,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminanceUnit.CandelaPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Luminance(double.PositiveInfinity, LuminanceUnit.CandelaPerSquareMeter)); @@ -112,7 +112,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Luminance(double.NaN, LuminanceUnit.CandelaPerSquareMeter)); @@ -216,7 +216,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCandelasPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Luminance.FromCandelasPerSquareMeter(double.PositiveInfinity)); @@ -226,7 +226,7 @@ public void FromCandelasPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCandelasPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Luminance.FromCandelasPerSquareMeter(double.NaN)); @@ -641,8 +641,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LuminanceUnit.CandelaPerSquareMeter, 1, LuminanceUnit.CandelaPerSquareMeter, true)] // Same value and unit. [InlineData(1, LuminanceUnit.CandelaPerSquareMeter, 2, LuminanceUnit.CandelaPerSquareMeter, false)] // Different value. - [InlineData(2, LuminanceUnit.CandelaPerSquareMeter, 1, LuminanceUnit.CandelaPerSquareFoot, false)] // Different value and unit. - [InlineData(1, LuminanceUnit.CandelaPerSquareMeter, 1, LuminanceUnit.CandelaPerSquareFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LuminanceUnit unitA, double valueB, LuminanceUnit unitB, bool expectEqual) { var a = new Luminance(valueA, unitA); @@ -959,7 +957,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Luminance.FromCandelasPerSquareMeter(1.0); - Assert.Equal(new {Luminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Luminance.Info.Name, quantity.CandelasPerSquareMeter); + #else + var expected = new {Luminance.Info.Name, valueInBaseUnit = quantity.CandelasPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 01acc81210..6374e28e99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -118,7 +118,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminosityUnit.Watt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Luminosity(double.PositiveInfinity, LuminosityUnit.Watt)); @@ -128,7 +128,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Luminosity(double.NaN, LuminosityUnit.Watt)); @@ -252,7 +252,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWatts_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Luminosity.FromWatts(double.PositiveInfinity)); @@ -262,7 +262,7 @@ public void FromWatts_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWatts_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Luminosity.FromWatts(double.NaN)); @@ -737,8 +737,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LuminosityUnit.Watt, 1, LuminosityUnit.Watt, true)] // Same value and unit. [InlineData(1, LuminosityUnit.Watt, 2, LuminosityUnit.Watt, false)] // Different value. - [InlineData(2, LuminosityUnit.Watt, 1, LuminosityUnit.Decawatt, false)] // Different value and unit. - [InlineData(1, LuminosityUnit.Watt, 1, LuminosityUnit.Decawatt, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LuminosityUnit unitA, double valueB, LuminosityUnit unitB, bool expectEqual) { var a = new Luminosity(valueA, unitA); @@ -1063,7 +1061,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(new {Luminosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Luminosity.Info.Name, quantity.Watts); + #else + var expected = new {Luminosity.Info.Name, valueInBaseUnit = quantity.Watts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index c9847200e8..87214dec10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousFluxUnit.Lumen, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new LuminousFlux(double.PositiveInfinity, LuminousFluxUnit.Lumen)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new LuminousFlux(double.NaN, LuminousFluxUnit.Lumen)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLumens_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => LuminousFlux.FromLumens(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromLumens_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromLumens_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => LuminousFlux.FromLumens(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LuminousFluxUnit.Lumen, 1, LuminousFluxUnit.Lumen, true)] // Same value and unit. [InlineData(1, LuminousFluxUnit.Lumen, 2, LuminousFluxUnit.Lumen, false)] // Different value. - [InlineData(2, LuminousFluxUnit.Lumen, 1, LuminousFluxUnit.Lumen, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LuminousFluxUnit unitA, double valueB, LuminousFluxUnit unitB, bool expectEqual) { var a = new LuminousFlux(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(new {LuminousFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(LuminousFlux.Info.Name, quantity.Lumens); + #else + var expected = new {LuminousFlux.Info.Name, valueInBaseUnit = quantity.Lumens}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index b2411776e3..a8e4e893d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousIntensityUnit.Candela, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new LuminousIntensity(double.PositiveInfinity, LuminousIntensityUnit.Candela)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new LuminousIntensity(double.NaN, LuminousIntensityUnit.Candela)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCandela_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => LuminousIntensity.FromCandela(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromCandela_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCandela_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => LuminousIntensity.FromCandela(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, LuminousIntensityUnit.Candela, 1, LuminousIntensityUnit.Candela, true)] // Same value and unit. [InlineData(1, LuminousIntensityUnit.Candela, 2, LuminousIntensityUnit.Candela, false)] // Different value. - [InlineData(2, LuminousIntensityUnit.Candela, 1, LuminousIntensityUnit.Candela, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, LuminousIntensityUnit unitA, double valueB, LuminousIntensityUnit unitB, bool expectEqual) { var a = new LuminousIntensity(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(new {LuminousIntensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(LuminousIntensity.Info.Name, quantity.Candela); + #else + var expected = new {LuminousIntensity.Info.Name, valueInBaseUnit = quantity.Candela}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 8b2c6dbe4a..3c2755b175 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFieldUnit.Tesla, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MagneticField(double.PositiveInfinity, MagneticFieldUnit.Tesla)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MagneticField(double.NaN, MagneticFieldUnit.Tesla)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromTeslas_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MagneticField.FromTeslas(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromTeslas_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromTeslas_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MagneticField.FromTeslas(double.NaN)); @@ -501,8 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MagneticFieldUnit.Tesla, 1, MagneticFieldUnit.Tesla, true)] // Same value and unit. [InlineData(1, MagneticFieldUnit.Tesla, 2, MagneticFieldUnit.Tesla, false)] // Different value. - [InlineData(2, MagneticFieldUnit.Tesla, 1, MagneticFieldUnit.Gauss, false)] // Different value and unit. - [InlineData(1, MagneticFieldUnit.Tesla, 1, MagneticFieldUnit.Gauss, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MagneticFieldUnit unitA, double valueB, MagneticFieldUnit unitB, bool expectEqual) { var a = new MagneticField(valueA, unitA); @@ -811,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(new {MagneticField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MagneticField.Info.Name, quantity.Teslas); + #else + var expected = new {MagneticField.Info.Name, valueInBaseUnit = quantity.Teslas}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 7fb6fe4167..5a34d5626c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFluxUnit.Weber, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MagneticFlux(double.PositiveInfinity, MagneticFluxUnit.Weber)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MagneticFlux(double.NaN, MagneticFluxUnit.Weber)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWebers_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MagneticFlux.FromWebers(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromWebers_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWebers_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MagneticFlux.FromWebers(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MagneticFluxUnit.Weber, 1, MagneticFluxUnit.Weber, true)] // Same value and unit. [InlineData(1, MagneticFluxUnit.Weber, 2, MagneticFluxUnit.Weber, false)] // Different value. - [InlineData(2, MagneticFluxUnit.Weber, 1, MagneticFluxUnit.Weber, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MagneticFluxUnit unitA, double valueB, MagneticFluxUnit unitB, bool expectEqual) { var a = new MagneticFlux(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(new {MagneticFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MagneticFlux.Info.Name, quantity.Webers); + #else + var expected = new {MagneticFlux.Info.Name, valueInBaseUnit = quantity.Webers}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 899ef4b52f..18cf7ecf3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagnetizationUnit.AmperePerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Magnetization(double.PositiveInfinity, MagnetizationUnit.AmperePerMeter)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Magnetization(double.NaN, MagnetizationUnit.AmperePerMeter)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Magnetization.FromAmperesPerMeter(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromAmperesPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmperesPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Magnetization.FromAmperesPerMeter(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MagnetizationUnit.AmperePerMeter, 1, MagnetizationUnit.AmperePerMeter, true)] // Same value and unit. [InlineData(1, MagnetizationUnit.AmperePerMeter, 2, MagnetizationUnit.AmperePerMeter, false)] // Different value. - [InlineData(2, MagnetizationUnit.AmperePerMeter, 1, MagnetizationUnit.AmperePerMeter, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MagnetizationUnit unitA, double valueB, MagnetizationUnit unitB, bool expectEqual) { var a = new Magnetization(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(new {Magnetization.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Magnetization.Info.Name, quantity.AmperesPerMeter); + #else + var expected = new {Magnetization.Info.Name, valueInBaseUnit = quantity.AmperesPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index f36a2637fc..7c18e62329 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -258,7 +258,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MassConcentration(double.PositiveInfinity, MassConcentrationUnit.KilogramPerCubicMeter)); @@ -268,7 +268,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MassConcentration(double.NaN, MassConcentrationUnit.KilogramPerCubicMeter)); @@ -567,7 +567,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MassConcentration.FromKilogramsPerCubicMeter(double.PositiveInfinity)); @@ -577,7 +577,7 @@ public void FromKilogramsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MassConcentration.FromKilogramsPerCubicMeter(double.NaN)); @@ -2102,8 +2102,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassConcentrationUnit.KilogramPerCubicMeter, 1, MassConcentrationUnit.KilogramPerCubicMeter, true)] // Same value and unit. [InlineData(1, MassConcentrationUnit.KilogramPerCubicMeter, 2, MassConcentrationUnit.KilogramPerCubicMeter, false)] // Different value. - [InlineData(2, MassConcentrationUnit.KilogramPerCubicMeter, 1, MassConcentrationUnit.CentigramPerDeciliter, false)] // Different value and unit. - [InlineData(1, MassConcentrationUnit.KilogramPerCubicMeter, 1, MassConcentrationUnit.CentigramPerDeciliter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassConcentrationUnit unitA, double valueB, MassConcentrationUnit unitB, bool expectEqual) { var a = new MassConcentration(valueA, unitA); @@ -2498,7 +2496,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {MassConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MassConcentration.Info.Name, quantity.KilogramsPerCubicMeter); + #else + var expected = new {MassConcentration.Info.Name, valueInBaseUnit = quantity.KilogramsPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 2670fd3bda..42e2a338ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -194,7 +194,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFlowUnit.GramPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MassFlow(double.PositiveInfinity, MassFlowUnit.GramPerSecond)); @@ -204,7 +204,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MassFlow(double.NaN, MassFlowUnit.GramPerSecond)); @@ -423,7 +423,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGramsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MassFlow.FromGramsPerSecond(double.PositiveInfinity)); @@ -433,7 +433,7 @@ public void FromGramsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGramsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MassFlow.FromGramsPerSecond(double.NaN)); @@ -1688,8 +1688,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassFlowUnit.GramPerSecond, 1, MassFlowUnit.GramPerSecond, true)] // Same value and unit. [InlineData(1, MassFlowUnit.GramPerSecond, 2, MassFlowUnit.GramPerSecond, false)] // Different value. - [InlineData(2, MassFlowUnit.GramPerSecond, 1, MassFlowUnit.CentigramPerDay, false)] // Different value and unit. - [InlineData(1, MassFlowUnit.GramPerSecond, 1, MassFlowUnit.CentigramPerDay, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassFlowUnit unitA, double valueB, MassFlowUnit unitB, bool expectEqual) { var a = new MassFlow(valueA, unitA); @@ -2052,7 +2050,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(new {MassFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MassFlow.Info.Name, quantity.GramsPerSecond); + #else + var expected = new {MassFlow.Info.Name, valueInBaseUnit = quantity.GramsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index a34f26945f..ca30e77869 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -110,7 +110,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MassFlux(double.PositiveInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); @@ -120,7 +120,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MassFlux(double.NaN, MassFluxUnit.KilogramPerSecondPerSquareMeter)); @@ -234,7 +234,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerSecondPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.PositiveInfinity)); @@ -244,7 +244,7 @@ public void FromKilogramsPerSecondPerSquareMeter_WithInfinityValue_DoNotThrowsAr Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerSecondPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NaN)); @@ -711,8 +711,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassFluxUnit.KilogramPerSecondPerSquareMeter, 1, MassFluxUnit.KilogramPerSecondPerSquareMeter, true)] // Same value and unit. [InlineData(1, MassFluxUnit.KilogramPerSecondPerSquareMeter, 2, MassFluxUnit.KilogramPerSecondPerSquareMeter, false)] // Different value. - [InlineData(2, MassFluxUnit.KilogramPerSecondPerSquareMeter, 1, MassFluxUnit.GramPerHourPerSquareCentimeter, false)] // Different value and unit. - [InlineData(1, MassFluxUnit.KilogramPerSecondPerSquareMeter, 1, MassFluxUnit.GramPerHourPerSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassFluxUnit unitA, double valueB, MassFluxUnit unitB, bool expectEqual) { var a = new MassFlux(valueA, unitA); @@ -1033,7 +1031,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(new {MassFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MassFlux.Info.Name, quantity.KilogramsPerSecondPerSquareMeter); + #else + var expected = new {MassFlux.Info.Name, valueInBaseUnit = quantity.KilogramsPerSecondPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 03abfe59ac..9a08669517 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -158,7 +158,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFractionUnit.DecimalFraction, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MassFraction(double.PositiveInfinity, MassFractionUnit.DecimalFraction)); @@ -168,7 +168,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MassFraction(double.NaN, MassFractionUnit.DecimalFraction)); @@ -342,7 +342,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MassFraction.FromDecimalFractions(double.PositiveInfinity)); @@ -352,7 +352,7 @@ public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MassFraction.FromDecimalFractions(double.NaN)); @@ -1155,8 +1155,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassFractionUnit.DecimalFraction, 1, MassFractionUnit.DecimalFraction, true)] // Same value and unit. [InlineData(1, MassFractionUnit.DecimalFraction, 2, MassFractionUnit.DecimalFraction, false)] // Different value. - [InlineData(2, MassFractionUnit.DecimalFraction, 1, MassFractionUnit.CentigramPerGram, false)] // Different value and unit. - [InlineData(1, MassFractionUnit.DecimalFraction, 1, MassFractionUnit.CentigramPerGram, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassFractionUnit unitA, double valueB, MassFractionUnit unitB, bool expectEqual) { var a = new MassFraction(valueA, unitA); @@ -1501,7 +1499,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(new {MassFraction.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MassFraction.Info.Name, quantity.DecimalFractions); + #else + var expected = new {MassFraction.Info.Name, valueInBaseUnit = quantity.DecimalFractions}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 87da68ae89..9a0333810e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -174,7 +174,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MassMomentOfInertia(double.PositiveInfinity, MassMomentOfInertiaUnit.KilogramSquareMeter)); @@ -184,7 +184,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MassMomentOfInertia(double.NaN, MassMomentOfInertiaUnit.KilogramSquareMeter)); @@ -378,7 +378,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MassMomentOfInertia.FromKilogramSquareMeters(double.PositiveInfinity)); @@ -388,7 +388,7 @@ public void FromKilogramSquareMeters_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramSquareMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MassMomentOfInertia.FromKilogramSquareMeters(double.NaN)); @@ -1271,8 +1271,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassMomentOfInertiaUnit.KilogramSquareMeter, 1, MassMomentOfInertiaUnit.KilogramSquareMeter, true)] // Same value and unit. [InlineData(1, MassMomentOfInertiaUnit.KilogramSquareMeter, 2, MassMomentOfInertiaUnit.KilogramSquareMeter, false)] // Different value. - [InlineData(2, MassMomentOfInertiaUnit.KilogramSquareMeter, 1, MassMomentOfInertiaUnit.GramSquareCentimeter, false)] // Different value and unit. - [InlineData(1, MassMomentOfInertiaUnit.KilogramSquareMeter, 1, MassMomentOfInertiaUnit.GramSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassMomentOfInertiaUnit unitA, double valueB, MassMomentOfInertiaUnit unitB, bool expectEqual) { var a = new MassMomentOfInertia(valueA, unitA); @@ -1625,7 +1623,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(new {MassMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MassMomentOfInertia.Info.Name, quantity.KilogramSquareMeters); + #else + var expected = new {MassMomentOfInertia.Info.Name, valueInBaseUnit = quantity.KilogramSquareMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 2759b9b0bd..7fa60e1713 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -170,7 +170,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassUnit.Kilogram, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Mass(double.PositiveInfinity, MassUnit.Kilogram)); @@ -180,7 +180,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Mass(double.NaN, MassUnit.Kilogram)); @@ -369,7 +369,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilograms_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Mass.FromKilograms(double.PositiveInfinity)); @@ -379,7 +379,7 @@ public void FromKilograms_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilograms_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Mass.FromKilograms(double.NaN)); @@ -2344,8 +2344,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MassUnit.Kilogram, 1, MassUnit.Kilogram, true)] // Same value and unit. [InlineData(1, MassUnit.Kilogram, 2, MassUnit.Kilogram, false)] // Different value. - [InlineData(2, MassUnit.Kilogram, 1, MassUnit.Centigram, false)] // Different value and unit. - [InlineData(1, MassUnit.Kilogram, 1, MassUnit.Centigram, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MassUnit unitA, double valueB, MassUnit unitB, bool expectEqual) { var a = new Mass(valueA, unitA); @@ -2696,7 +2694,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(new {Mass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Mass.Info.Name, quantity.Kilograms); + #else + var expected = new {Mass.Info.Name, valueInBaseUnit = quantity.Kilograms}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs index 7ec6b5cd8a..4c49351f71 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolalityTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolalityUnit.MolePerKilogram, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Molality(double.PositiveInfinity, MolalityUnit.MolePerKilogram)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Molality(double.NaN, MolalityUnit.MolePerKilogram)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerKilogram_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Molality.FromMolesPerKilogram(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromMolesPerKilogram_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerKilogram_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Molality.FromMolesPerKilogram(double.NaN)); @@ -361,8 +361,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolalityUnit.MolePerKilogram, 1, MolalityUnit.MolePerKilogram, true)] // Same value and unit. [InlineData(1, MolalityUnit.MolePerKilogram, 2, MolalityUnit.MolePerKilogram, false)] // Different value. - [InlineData(2, MolalityUnit.MolePerKilogram, 1, MolalityUnit.MolePerGram, false)] // Different value and unit. - [InlineData(1, MolalityUnit.MolePerKilogram, 1, MolalityUnit.MolePerGram, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolalityUnit unitA, double valueB, MolalityUnit unitB, bool expectEqual) { var a = new Molality(valueA, unitA); @@ -663,7 +661,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Molality.FromMolesPerKilogram(1.0); - Assert.Equal(new {Molality.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Molality.Info.Name, quantity.MolesPerKilogram); + #else + var expected = new {Molality.Info.Name, valueInBaseUnit = quantity.MolesPerKilogram}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 3f78851b43..c31a9267db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEnergyUnit.JoulePerMole, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MolarEnergy(double.PositiveInfinity, MolarEnergyUnit.JoulePerMole)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MolarEnergy(double.NaN, MolarEnergyUnit.JoulePerMole)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerMole_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MolarEnergy.FromJoulesPerMole(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromJoulesPerMole_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerMole_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MolarEnergy.FromJoulesPerMole(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolarEnergyUnit.JoulePerMole, 1, MolarEnergyUnit.JoulePerMole, true)] // Same value and unit. [InlineData(1, MolarEnergyUnit.JoulePerMole, 2, MolarEnergyUnit.JoulePerMole, false)] // Different value. - [InlineData(2, MolarEnergyUnit.JoulePerMole, 1, MolarEnergyUnit.KilojoulePerMole, false)] // Different value and unit. - [InlineData(1, MolarEnergyUnit.JoulePerMole, 1, MolarEnergyUnit.KilojoulePerMole, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolarEnergyUnit unitA, double valueB, MolarEnergyUnit unitB, bool expectEqual) { var a = new MolarEnergy(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(new {MolarEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MolarEnergy.Info.Name, quantity.JoulesPerMole); + #else + var expected = new {MolarEnergy.Info.Name, valueInBaseUnit = quantity.JoulesPerMole}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 21ee3dccbe..b3fa7edf25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MolarEntropy(double.PositiveInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MolarEntropy(double.NaN, MolarEntropyUnit.JoulePerMoleKelvin)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerMoleKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MolarEntropy.FromJoulesPerMoleKelvin(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromJoulesPerMoleKelvin_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerMoleKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolarEntropyUnit.JoulePerMoleKelvin, 1, MolarEntropyUnit.JoulePerMoleKelvin, true)] // Same value and unit. [InlineData(1, MolarEntropyUnit.JoulePerMoleKelvin, 2, MolarEntropyUnit.JoulePerMoleKelvin, false)] // Different value. - [InlineData(2, MolarEntropyUnit.JoulePerMoleKelvin, 1, MolarEntropyUnit.KilojoulePerMoleKelvin, false)] // Different value and unit. - [InlineData(1, MolarEntropyUnit.JoulePerMoleKelvin, 1, MolarEntropyUnit.KilojoulePerMoleKelvin, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolarEntropyUnit unitA, double valueB, MolarEntropyUnit unitB, bool expectEqual) { var a = new MolarEntropy(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(new {MolarEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MolarEntropy.Info.Name, quantity.JoulesPerMoleKelvin); + #else + var expected = new {MolarEntropy.Info.Name, valueInBaseUnit = quantity.JoulesPerMoleKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs index 3327e56843..be94acedc7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarFlowTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarFlowUnit.MolePerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MolarFlow(double.PositiveInfinity, MolarFlowUnit.MolePerSecond)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MolarFlow(double.NaN, MolarFlowUnit.MolePerSecond)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MolarFlow.FromMolesPerSecond(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromMolesPerSecond_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MolarFlow.FromMolesPerSecond(double.NaN)); @@ -606,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolarFlowUnit.MolePerSecond, 1, MolarFlowUnit.MolePerSecond, true)] // Same value and unit. [InlineData(1, MolarFlowUnit.MolePerSecond, 2, MolarFlowUnit.MolePerSecond, false)] // Different value. - [InlineData(2, MolarFlowUnit.MolePerSecond, 1, MolarFlowUnit.KilomolePerHour, false)] // Different value and unit. - [InlineData(1, MolarFlowUnit.MolePerSecond, 1, MolarFlowUnit.KilomolePerHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolarFlowUnit unitA, double valueB, MolarFlowUnit unitB, bool expectEqual) { var a = new MolarFlow(valueA, unitA); @@ -922,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarFlow.FromMolesPerSecond(1.0); - Assert.Equal(new {MolarFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MolarFlow.Info.Name, quantity.MolesPerSecond); + #else + var expected = new {MolarFlow.Info.Name, valueInBaseUnit = quantity.MolesPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index efe943b6bb..8058863e5d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -114,7 +114,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarMassUnit.KilogramPerMole, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new MolarMass(double.PositiveInfinity, MolarMassUnit.KilogramPerMole)); @@ -124,7 +124,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new MolarMass(double.NaN, MolarMassUnit.KilogramPerMole)); @@ -243,7 +243,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerMole_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => MolarMass.FromKilogramsPerMole(double.PositiveInfinity)); @@ -253,7 +253,7 @@ public void FromKilogramsPerMole_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKilogramsPerMole_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => MolarMass.FromKilogramsPerMole(double.NaN)); @@ -1034,8 +1034,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolarMassUnit.KilogramPerMole, 1, MolarMassUnit.KilogramPerMole, true)] // Same value and unit. [InlineData(1, MolarMassUnit.KilogramPerMole, 2, MolarMassUnit.KilogramPerMole, false)] // Different value. - [InlineData(2, MolarMassUnit.KilogramPerMole, 1, MolarMassUnit.CentigramPerMole, false)] // Different value and unit. - [InlineData(1, MolarMassUnit.KilogramPerMole, 1, MolarMassUnit.CentigramPerMole, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolarMassUnit unitA, double valueB, MolarMassUnit unitB, bool expectEqual) { var a = new MolarMass(valueA, unitA); @@ -1358,7 +1356,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(new {MolarMass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(MolarMass.Info.Name, quantity.KilogramsPerMole); + #else + var expected = new {MolarMass.Info.Name, valueInBaseUnit = quantity.KilogramsPerMole}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index c87aacc006..7a7165f9d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -106,7 +106,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarityUnit.MolePerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Molarity(double.PositiveInfinity, MolarityUnit.MolePerCubicMeter)); @@ -116,7 +116,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Molarity(double.NaN, MolarityUnit.MolePerCubicMeter)); @@ -225,7 +225,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Molarity.FromMolesPerCubicMeter(double.PositiveInfinity)); @@ -235,7 +235,7 @@ public void FromMolesPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExceptio Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMolesPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Molarity.FromMolesPerCubicMeter(double.NaN)); @@ -868,8 +868,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, MolarityUnit.MolePerCubicMeter, 1, MolarityUnit.MolePerCubicMeter, true)] // Same value and unit. [InlineData(1, MolarityUnit.MolePerCubicMeter, 2, MolarityUnit.MolePerCubicMeter, false)] // Different value. - [InlineData(2, MolarityUnit.MolePerCubicMeter, 1, MolarityUnit.CentimolePerLiter, false)] // Different value and unit. - [InlineData(1, MolarityUnit.MolePerCubicMeter, 1, MolarityUnit.CentimolePerLiter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, MolarityUnit unitA, double valueB, MolarityUnit unitB, bool expectEqual) { var a = new Molarity(valueA, unitA); @@ -1188,7 +1186,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(new {Molarity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Molarity.Info.Name, quantity.MolesPerCubicMeter); + #else + var expected = new {Molarity.Info.Name, valueInBaseUnit = quantity.MolesPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index b0889115bc..5d4e3bdc06 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermeabilityUnit.HenryPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Permeability(double.PositiveInfinity, PermeabilityUnit.HenryPerMeter)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Permeability(double.NaN, PermeabilityUnit.HenryPerMeter)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHenriesPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Permeability.FromHenriesPerMeter(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromHenriesPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromHenriesPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Permeability.FromHenriesPerMeter(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PermeabilityUnit.HenryPerMeter, 1, PermeabilityUnit.HenryPerMeter, true)] // Same value and unit. [InlineData(1, PermeabilityUnit.HenryPerMeter, 2, PermeabilityUnit.HenryPerMeter, false)] // Different value. - [InlineData(2, PermeabilityUnit.HenryPerMeter, 1, PermeabilityUnit.HenryPerMeter, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PermeabilityUnit unitA, double valueB, PermeabilityUnit unitB, bool expectEqual) { var a = new Permeability(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(new {Permeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Permeability.Info.Name, quantity.HenriesPerMeter); + #else + var expected = new {Permeability.Info.Name, valueInBaseUnit = quantity.HenriesPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index f56dda0005..3347aba7f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermittivityUnit.FaradPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Permittivity(double.PositiveInfinity, PermittivityUnit.FaradPerMeter)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Permittivity(double.NaN, PermittivityUnit.FaradPerMeter)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromFaradsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Permittivity.FromFaradsPerMeter(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromFaradsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromFaradsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Permittivity.FromFaradsPerMeter(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PermittivityUnit.FaradPerMeter, 1, PermittivityUnit.FaradPerMeter, true)] // Same value and unit. [InlineData(1, PermittivityUnit.FaradPerMeter, 2, PermittivityUnit.FaradPerMeter, false)] // Different value. - [InlineData(2, PermittivityUnit.FaradPerMeter, 1, PermittivityUnit.FaradPerMeter, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PermittivityUnit unitA, double valueB, PermittivityUnit unitB, bool expectEqual) { var a = new Permittivity(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(new {Permittivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Permittivity.Info.Name, quantity.FaradsPerMeter); + #else + var expected = new {Permittivity.Info.Name, valueInBaseUnit = quantity.FaradsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 9cda117a1a..1bd5b2a246 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PorousMediumPermeabilityUnit.SquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new PorousMediumPermeability(double.PositiveInfinity, PorousMediumPermeabilityUnit.SquareMeter)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new PorousMediumPermeability(double.NaN, PorousMediumPermeabilityUnit.SquareMeter)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => PorousMediumPermeability.FromSquareMeters(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => PorousMediumPermeability.FromSquareMeters(double.NaN)); @@ -466,8 +466,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PorousMediumPermeabilityUnit.SquareMeter, 1, PorousMediumPermeabilityUnit.SquareMeter, true)] // Same value and unit. [InlineData(1, PorousMediumPermeabilityUnit.SquareMeter, 2, PorousMediumPermeabilityUnit.SquareMeter, false)] // Different value. - [InlineData(2, PorousMediumPermeabilityUnit.SquareMeter, 1, PorousMediumPermeabilityUnit.Darcy, false)] // Different value and unit. - [InlineData(1, PorousMediumPermeabilityUnit.SquareMeter, 1, PorousMediumPermeabilityUnit.Darcy, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PorousMediumPermeabilityUnit unitA, double valueB, PorousMediumPermeabilityUnit unitB, bool expectEqual) { var a = new PorousMediumPermeability(valueA, unitA); @@ -774,7 +772,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal(new {PorousMediumPermeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(PorousMediumPermeability.Info.Name, quantity.SquareMeters); + #else + var expected = new {PorousMediumPermeability.Info.Name, valueInBaseUnit = quantity.SquareMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 4949a0a39e..1a53c1e0d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -238,7 +238,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerDensityUnit.WattPerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new PowerDensity(double.PositiveInfinity, PowerDensityUnit.WattPerCubicMeter)); @@ -248,7 +248,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new PowerDensity(double.NaN, PowerDensityUnit.WattPerCubicMeter)); @@ -522,7 +522,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => PowerDensity.FromWattsPerCubicMeter(double.PositiveInfinity)); @@ -532,7 +532,7 @@ public void FromWattsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExceptio Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => PowerDensity.FromWattsPerCubicMeter(double.NaN)); @@ -1743,8 +1743,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PowerDensityUnit.WattPerCubicMeter, 1, PowerDensityUnit.WattPerCubicMeter, true)] // Same value and unit. [InlineData(1, PowerDensityUnit.WattPerCubicMeter, 2, PowerDensityUnit.WattPerCubicMeter, false)] // Different value. - [InlineData(2, PowerDensityUnit.WattPerCubicMeter, 1, PowerDensityUnit.DecawattPerCubicFoot, false)] // Different value and unit. - [InlineData(1, PowerDensityUnit.WattPerCubicMeter, 1, PowerDensityUnit.DecawattPerCubicFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PowerDensityUnit unitA, double valueB, PowerDensityUnit unitB, bool expectEqual) { var a = new PowerDensity(valueA, unitA); @@ -2129,7 +2127,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(new {PowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(PowerDensity.Info.Name, quantity.WattsPerCubicMeter); + #else + var expected = new {PowerDensity.Info.Name, valueInBaseUnit = quantity.WattsPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 141fefd908..ed6b41f43a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerRatioUnit.DecibelWatt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new PowerRatio(double.PositiveInfinity, PowerRatioUnit.DecibelWatt)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new PowerRatio(double.NaN, PowerRatioUnit.DecibelWatt)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibelWatts_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromDecibelWatts_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecibelWatts_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => PowerRatio.FromDecibelWatts(double.NaN)); @@ -389,8 +389,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelWatt, true)] // Same value and unit. [InlineData(1, PowerRatioUnit.DecibelWatt, 2, PowerRatioUnit.DecibelWatt, false)] // Different value. - [InlineData(2, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt, false)] // Different value and unit. - [InlineData(1, PowerRatioUnit.DecibelWatt, 1, PowerRatioUnit.DecibelMilliwatt, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PowerRatioUnit unitA, double valueB, PowerRatioUnit unitB, bool expectEqual) { var a = new PowerRatio(valueA, unitA); @@ -691,7 +689,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(new {PowerRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(PowerRatio.Info.Name, quantity.DecibelWatts); + #else + var expected = new {PowerRatio.Info.Name, valueInBaseUnit = quantity.DecibelWatts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index e676cac6c0..48ec19abb1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -166,7 +166,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerUnit.Watt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Power(double.PositiveInfinity, PowerUnit.Watt)); @@ -176,7 +176,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Power(double.NaN, PowerUnit.Watt)); @@ -360,7 +360,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWatts_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Power.FromWatts(double.PositiveInfinity)); @@ -370,7 +370,7 @@ public void FromWatts_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWatts_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Power.FromWatts(double.NaN)); @@ -1207,8 +1207,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PowerUnit.Watt, 1, PowerUnit.Watt, true)] // Same value and unit. [InlineData(1, PowerUnit.Watt, 2, PowerUnit.Watt, false)] // Different value. - [InlineData(2, PowerUnit.Watt, 1, PowerUnit.BoilerHorsepower, false)] // Different value and unit. - [InlineData(1, PowerUnit.Watt, 1, PowerUnit.BoilerHorsepower, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PowerUnit unitA, double valueB, PowerUnit unitB, bool expectEqual) { var a = new Power(valueA, unitA); @@ -1557,7 +1555,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Power.FromWatts(1.0); - Assert.Equal(new {Power.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Power.Info.Name, quantity.Watts); + #else + var expected = new {Power.Info.Name, valueInBaseUnit = quantity.Watts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 8af12eaaf2..adfea2c2fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -134,7 +134,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureChangeRateUnit.PascalPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new PressureChangeRate(double.PositiveInfinity, PressureChangeRateUnit.PascalPerSecond)); @@ -144,7 +144,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new PressureChangeRate(double.NaN, PressureChangeRateUnit.PascalPerSecond)); @@ -288,7 +288,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascalsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => PressureChangeRate.FromPascalsPerSecond(double.PositiveInfinity)); @@ -298,7 +298,7 @@ public void FromPascalsPerSecond_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascalsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => PressureChangeRate.FromPascalsPerSecond(double.NaN)); @@ -1641,8 +1641,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PressureChangeRateUnit.PascalPerSecond, 1, PressureChangeRateUnit.PascalPerSecond, true)] // Same value and unit. [InlineData(1, PressureChangeRateUnit.PascalPerSecond, 2, PressureChangeRateUnit.PascalPerSecond, false)] // Different value. - [InlineData(2, PressureChangeRateUnit.PascalPerSecond, 1, PressureChangeRateUnit.AtmospherePerSecond, false)] // Different value and unit. - [InlineData(1, PressureChangeRateUnit.PascalPerSecond, 1, PressureChangeRateUnit.AtmospherePerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PressureChangeRateUnit unitA, double valueB, PressureChangeRateUnit unitB, bool expectEqual) { var a = new PressureChangeRate(valueA, unitA); @@ -1975,7 +1973,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(new {PressureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(PressureChangeRate.Info.Name, quantity.PascalsPerSecond); + #else + var expected = new {PressureChangeRate.Info.Name, valueInBaseUnit = quantity.PascalsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 1abc7a7fb1..07fd0ed750 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -258,7 +258,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureUnit.Pascal, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Pressure(double.PositiveInfinity, PressureUnit.Pascal)); @@ -268,7 +268,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Pressure(double.NaN, PressureUnit.Pascal)); @@ -567,7 +567,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascals_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Pressure.FromPascals(double.PositiveInfinity)); @@ -577,7 +577,7 @@ public void FromPascals_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPascals_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Pressure.FromPascals(double.NaN)); @@ -3048,8 +3048,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, PressureUnit.Pascal, 1, PressureUnit.Pascal, true)] // Same value and unit. [InlineData(1, PressureUnit.Pascal, 2, PressureUnit.Pascal, false)] // Different value. - [InlineData(2, PressureUnit.Pascal, 1, PressureUnit.Atmosphere, false)] // Different value and unit. - [InlineData(1, PressureUnit.Pascal, 1, PressureUnit.Atmosphere, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PressureUnit unitA, double valueB, PressureUnit unitB, bool expectEqual) { var a = new Pressure(valueA, unitA); @@ -3444,7 +3442,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(new {Pressure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Pressure.Info.Name, quantity.Pascals); + #else + var expected = new {Pressure.Info.Name, valueInBaseUnit = quantity.Pascals}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs new file mode 100644 index 0000000000..5c898de888 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseTestsBase.g.cs @@ -0,0 +1,925 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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.Globalization; +using System.Linq; +using System.Threading; +using UnitsNet.Tests.TestsBase; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of RadiationEquivalentDose. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RadiationEquivalentDoseTestsBase : QuantityTestsBase + { + protected abstract double MicrosievertsInOneSievert { get; } + protected abstract double MilliroentgensEquivalentManInOneSievert { get; } + protected abstract double MillisievertsInOneSievert { get; } + protected abstract double NanosievertsInOneSievert { get; } + protected abstract double RoentgensEquivalentManInOneSievert { get; } + protected abstract double SievertsInOneSievert { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double MicrosievertsTolerance { get { return 1e-5; } } + protected virtual double MilliroentgensEquivalentManTolerance { get { return 1e-5; } } + protected virtual double MillisievertsTolerance { get { return 1e-5; } } + protected virtual double NanosievertsTolerance { get { return 1e-5; } } + protected virtual double RoentgensEquivalentManTolerance { get { return 1e-5; } } + protected virtual double SievertsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RadiationEquivalentDoseUnit unit) + { + return unit switch + { + RadiationEquivalentDoseUnit.Microsievert => (MicrosievertsInOneSievert, MicrosievertsTolerance), + RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan => (MilliroentgensEquivalentManInOneSievert, MilliroentgensEquivalentManTolerance), + RadiationEquivalentDoseUnit.Millisievert => (MillisievertsInOneSievert, MillisievertsTolerance), + RadiationEquivalentDoseUnit.Nanosievert => (NanosievertsInOneSievert, NanosievertsTolerance), + RadiationEquivalentDoseUnit.RoentgenEquivalentMan => (RoentgensEquivalentManInOneSievert, RoentgensEquivalentManTolerance), + RadiationEquivalentDoseUnit.Sievert => (SievertsInOneSievert, SievertsTolerance), + _ => throw new NotSupportedException() + }; + } + + public static IEnumerable UnitTypes = new List + { + new object[] { RadiationEquivalentDoseUnit.Microsievert }, + new object[] { RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan }, + new object[] { RadiationEquivalentDoseUnit.Millisievert }, + new object[] { RadiationEquivalentDoseUnit.Nanosievert }, + new object[] { RadiationEquivalentDoseUnit.RoentgenEquivalentMan }, + new object[] { RadiationEquivalentDoseUnit.Sievert }, + }; + + [Fact] + public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() + { + var quantity = new RadiationEquivalentDose(); + Assert.Equal(0, quantity.Value); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, quantity.Unit); + } + + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] + public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() + { + var exception1 = Record.Exception(() => new RadiationEquivalentDose(double.PositiveInfinity, RadiationEquivalentDoseUnit.Sievert)); + var exception2 = Record.Exception(() => new RadiationEquivalentDose(double.NegativeInfinity, RadiationEquivalentDoseUnit.Sievert)); + + Assert.Null(exception1); + Assert.Null(exception2); + } + + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] + public void Ctor_WithNaNValue_DoNotThrowsArgumentException() + { + var exception = Record.Exception(() => new RadiationEquivalentDose(double.NaN, RadiationEquivalentDoseUnit.Sievert)); + + Assert.Null(exception); + } + + [Fact] + public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() + { + Assert.Throws(() => new RadiationEquivalentDose(value: 1, unitSystem: null)); + } + + [Fact] + public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + Func TestCode = () => new RadiationEquivalentDose(value: 1, unitSystem: UnitSystem.SI); + if (SupportsSIUnitSystem) + { + var quantity = (RadiationEquivalentDose) TestCode(); + Assert.Equal(1, quantity.Value); + } + else + { + Assert.Throws(TestCode); + } + } + + [Fact] + public void RadiationEquivalentDose_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() + { + var quantity = new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Sievert); + + QuantityInfo quantityInfo = quantity.QuantityInfo; + + Assert.Equal(RadiationEquivalentDose.Zero, quantityInfo.Zero); + Assert.Equal("RadiationEquivalentDose", quantityInfo.Name); + + var units = EnumUtils.GetEnumValues().OrderBy(x => x.ToString()).ToArray(); + var unitNames = units.Select(x => x.ToString()); + } + + [Fact] + public void SievertToRadiationEquivalentDoseUnits() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + AssertEx.EqualTolerance(MicrosievertsInOneSievert, sievert.Microsieverts, MicrosievertsTolerance); + AssertEx.EqualTolerance(MilliroentgensEquivalentManInOneSievert, sievert.MilliroentgensEquivalentMan, MilliroentgensEquivalentManTolerance); + AssertEx.EqualTolerance(MillisievertsInOneSievert, sievert.Millisieverts, MillisievertsTolerance); + AssertEx.EqualTolerance(NanosievertsInOneSievert, sievert.Nanosieverts, NanosievertsTolerance); + AssertEx.EqualTolerance(RoentgensEquivalentManInOneSievert, sievert.RoentgensEquivalentMan, RoentgensEquivalentManTolerance); + AssertEx.EqualTolerance(SievertsInOneSievert, sievert.Sieverts, SievertsTolerance); + } + + [Fact] + public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() + { + var quantity00 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.Microsievert); + AssertEx.EqualTolerance(1, quantity00.Microsieverts, MicrosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, quantity00.Unit); + + var quantity01 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan); + AssertEx.EqualTolerance(1, quantity01.MilliroentgensEquivalentMan, MilliroentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, quantity01.Unit); + + var quantity02 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.Millisievert); + AssertEx.EqualTolerance(1, quantity02.Millisieverts, MillisievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, quantity02.Unit); + + var quantity03 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.Nanosievert); + AssertEx.EqualTolerance(1, quantity03.Nanosieverts, NanosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, quantity03.Unit); + + var quantity04 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.RoentgenEquivalentMan); + AssertEx.EqualTolerance(1, quantity04.RoentgensEquivalentMan, RoentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, quantity04.Unit); + + var quantity05 = RadiationEquivalentDose.From(1, RadiationEquivalentDoseUnit.Sievert); + AssertEx.EqualTolerance(1, quantity05.Sieverts, SievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, quantity05.Unit); + + } + + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] + public void FromSieverts_WithInfinityValue_DoNotThrowsArgumentException() + { + var exception1 = Record.Exception(() => RadiationEquivalentDose.FromSieverts(double.PositiveInfinity)); + var exception2 = Record.Exception(() => RadiationEquivalentDose.FromSieverts(double.NegativeInfinity)); + + Assert.Null(exception1); + Assert.Null(exception2); + } + + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] + public void FromSieverts_WithNanValue_DoNotThrowsArgumentException() + { + var exception = Record.Exception(() => RadiationEquivalentDose.FromSieverts(double.NaN)); + + Assert.Null(exception); + } + + [Fact] + public void As() + { + var sievert = RadiationEquivalentDose.FromSieverts(1); + AssertEx.EqualTolerance(MicrosievertsInOneSievert, sievert.As(RadiationEquivalentDoseUnit.Microsievert), MicrosievertsTolerance); + AssertEx.EqualTolerance(MilliroentgensEquivalentManInOneSievert, sievert.As(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan), MilliroentgensEquivalentManTolerance); + AssertEx.EqualTolerance(MillisievertsInOneSievert, sievert.As(RadiationEquivalentDoseUnit.Millisievert), MillisievertsTolerance); + AssertEx.EqualTolerance(NanosievertsInOneSievert, sievert.As(RadiationEquivalentDoseUnit.Nanosievert), NanosievertsTolerance); + AssertEx.EqualTolerance(RoentgensEquivalentManInOneSievert, sievert.As(RadiationEquivalentDoseUnit.RoentgenEquivalentMan), RoentgensEquivalentManTolerance); + AssertEx.EqualTolerance(SievertsInOneSievert, sievert.As(RadiationEquivalentDoseUnit.Sievert), SievertsTolerance); + } + + [Fact] + public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + { + var quantity = new RadiationEquivalentDose(value: 1, unit: RadiationEquivalentDose.BaseUnit); + Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); + + if (SupportsSIUnitSystem) + { + var value = Convert.ToDouble(AsWithSIUnitSystem()); + Assert.Equal(1, value); + } + else + { + Assert.Throws(AsWithSIUnitSystem); + } + } + + [Fact] + public void Parse() + { + try + { + var parsed = RadiationEquivalentDose.Parse("1 µSv", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.Microsieverts, MicrosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 мкЗв", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.Microsieverts, MicrosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 mrem", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MilliroentgensEquivalentMan, MilliroentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 mSv", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.Millisieverts, MillisievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 мЗв", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.Millisieverts, MillisievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 nSv", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.Nanosieverts, NanosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 нЗв", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.Nanosieverts, NanosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 rem", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.RoentgensEquivalentMan, RoentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 Sv", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.Sieverts, SievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDose.Parse("1 Зв", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.Sieverts, SievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParse() + { + { + Assert.True(RadiationEquivalentDose.TryParse("1 µSv", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Microsieverts, MicrosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 мкЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Microsieverts, MicrosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 mrem", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MilliroentgensEquivalentMan, MilliroentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 mSv", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Millisieverts, MillisievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 мЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Millisieverts, MillisievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 nSv", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Nanosieverts, NanosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 нЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Nanosieverts, NanosievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 rem", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.RoentgensEquivalentMan, RoentgensEquivalentManTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 Sv", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Sieverts, SievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDose.TryParse("1 Зв", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.Sieverts, SievertsTolerance); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsed.Unit); + } + + } + + [Fact] + public void ParseUnit() + { + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("µSv", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("мкЗв", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("mrem", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("mSv", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("мЗв", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("nSv", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("нЗв", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("rem", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("Sv", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDose.ParseUnit("Зв", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + } + + [Fact] + public void TryParseUnit() + { + { + Assert.True(RadiationEquivalentDose.TryParseUnit("µSv", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("мкЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Microsievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("mrem", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("mSv", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("мЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Millisievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("nSv", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("нЗв", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Nanosievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("rem", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("Sv", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDose.TryParseUnit("Зв", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseUnit.Sievert, parsedUnit); + } + + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit(RadiationEquivalentDoseUnit unit) + { + var inBaseUnits = RadiationEquivalentDose.From(1.0, RadiationEquivalentDose.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); + + var conversionFactor = GetConversionFactor(unit); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + Assert.Equal(unit, converted.Unit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_WithSameUnits_AreEqual(RadiationEquivalentDoseUnit unit) + { + var quantity = RadiationEquivalentDose.From(3.0, unit); + var toUnitWithSameUnit = quantity.ToUnit(unit); + Assert.Equal(quantity, toUnitWithSameUnit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RadiationEquivalentDoseUnit unit) + { + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RadiationEquivalentDose.Units.First(u => u != RadiationEquivalentDose.BaseUnit); + + var quantity = RadiationEquivalentDose.From(3.0, fromUnit); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Theory] + [MemberData(nameof(UnitTypes))] + public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(RadiationEquivalentDoseUnit unit) + { + var quantity = default(RadiationEquivalentDose); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + } + + [Fact] + public void ConversionRoundTrip() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromMicrosieverts(sievert.Microsieverts).Sieverts, MicrosievertsTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromMilliroentgensEquivalentMan(sievert.MilliroentgensEquivalentMan).Sieverts, MilliroentgensEquivalentManTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromMillisieverts(sievert.Millisieverts).Sieverts, MillisievertsTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromNanosieverts(sievert.Nanosieverts).Sieverts, NanosievertsTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromRoentgensEquivalentMan(sievert.RoentgensEquivalentMan).Sieverts, RoentgensEquivalentManTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDose.FromSieverts(sievert.Sieverts).Sieverts, SievertsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + RadiationEquivalentDose v = RadiationEquivalentDose.FromSieverts(1); + AssertEx.EqualTolerance(-1, -v.Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(2, (RadiationEquivalentDose.FromSieverts(3)-v).Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(2, (v + v).Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(10, (v*10).Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(10, (10*v).Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(2, (RadiationEquivalentDose.FromSieverts(10)/5).Sieverts, SievertsTolerance); + AssertEx.EqualTolerance(2, RadiationEquivalentDose.FromSieverts(10)/RadiationEquivalentDose.FromSieverts(5), SievertsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + RadiationEquivalentDose oneSievert = RadiationEquivalentDose.FromSieverts(1); + RadiationEquivalentDose twoSieverts = RadiationEquivalentDose.FromSieverts(2); + + Assert.True(oneSievert < twoSieverts); + Assert.True(oneSievert <= twoSieverts); + Assert.True(twoSieverts > oneSievert); + Assert.True(twoSieverts >= oneSievert); + + Assert.False(oneSievert > twoSieverts); + Assert.False(oneSievert >= twoSieverts); + Assert.False(twoSieverts < oneSievert); + Assert.False(twoSieverts <= oneSievert); + } + + [Fact] + public void CompareToIsImplemented() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.Equal(0, sievert.CompareTo(sievert)); + Assert.True(sievert.CompareTo(RadiationEquivalentDose.Zero) > 0); + Assert.True(RadiationEquivalentDose.Zero.CompareTo(sievert) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.Throws(() => sievert.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.Throws(() => sievert.CompareTo(null)); + } + + [Theory] + [InlineData(1, RadiationEquivalentDoseUnit.Sievert, 1, RadiationEquivalentDoseUnit.Sievert, true)] // Same value and unit. + [InlineData(1, RadiationEquivalentDoseUnit.Sievert, 2, RadiationEquivalentDoseUnit.Sievert, false)] // Different value. + public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RadiationEquivalentDoseUnit unitA, double valueB, RadiationEquivalentDoseUnit unitB, bool expectEqual) + { + var a = new RadiationEquivalentDose(valueA, unitA); + var b = new RadiationEquivalentDose(valueB, unitB); + + // Operator overloads. + Assert.Equal(expectEqual, a == b); + Assert.Equal(expectEqual, b == a); + Assert.Equal(!expectEqual, a != b); + Assert.Equal(!expectEqual, b != a); + + // IEquatable + Assert.Equal(expectEqual, a.Equals(b)); + Assert.Equal(expectEqual, b.Equals(a)); + + // IEquatable + Assert.Equal(expectEqual, a.Equals((object)b)); + Assert.Equal(expectEqual, b.Equals((object)a)); + } + + [Fact] + public void Equals_Null_ReturnsFalse() + { + var a = RadiationEquivalentDose.Zero; + + Assert.False(a.Equals((object)null)); + + // "The result of the expression is always 'false'..." + #pragma warning disable CS8073 + Assert.False(a == null); + Assert.False(null == a); + Assert.True(a != null); + Assert.True(null != a); + #pragma warning restore CS8073 + } + + [Fact] + public void Equals_RelativeTolerance_IsImplemented() + { + var v = RadiationEquivalentDose.FromSieverts(1); + Assert.True(v.Equals(RadiationEquivalentDose.FromSieverts(1), SievertsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RadiationEquivalentDose.Zero, SievertsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() + { + var v = RadiationEquivalentDose.FromSieverts(1); + Assert.Throws(() => v.Equals(RadiationEquivalentDose.FromSieverts(1), -1, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.False(sievert.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + RadiationEquivalentDose sievert = RadiationEquivalentDose.FromSieverts(1); + Assert.False(sievert.Equals(null)); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RadiationEquivalentDoseUnit)).Cast(); + foreach (var unit in units) + { + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(RadiationEquivalentDose.BaseDimensions is null); + } + + [Fact] + public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() + { + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); + try { + Assert.Equal("1 µSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Microsievert).ToString()); + Assert.Equal("1 mrem", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan).ToString()); + Assert.Equal("1 mSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Millisievert).ToString()); + Assert.Equal("1 nSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Nanosievert).ToString()); + Assert.Equal("1 rem", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.RoentgenEquivalentMan).ToString()); + Assert.Equal("1 Sv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Sievert).ToString()); + } + finally + { + Thread.CurrentThread.CurrentCulture = prevCulture; + } + } + + [Fact] + public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCultureSinceThereAreNoMappings() + { + // Chose this culture, because we don't currently have any abbreviations mapped for that culture and we expect the en-US to be used as fallback. + var swedishCulture = CultureInfo.GetCultureInfo("sv-SE"); + + Assert.Equal("1 µSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Microsievert).ToString(swedishCulture)); + Assert.Equal("1 mrem", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan).ToString(swedishCulture)); + Assert.Equal("1 mSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Millisievert).ToString(swedishCulture)); + Assert.Equal("1 nSv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Nanosievert).ToString(swedishCulture)); + Assert.Equal("1 rem", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.RoentgenEquivalentMan).ToString(swedishCulture)); + Assert.Equal("1 Sv", new RadiationEquivalentDose(1, RadiationEquivalentDoseUnit.Sievert).ToString(swedishCulture)); + } + + [Fact] + public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() + { + var oldCulture = CultureInfo.CurrentCulture; + try + { + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s1")); + Assert.Equal("0.12 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s2")); + Assert.Equal("0.123 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s3")); + Assert.Equal("0.1235 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s4")); + } + finally + { + CultureInfo.CurrentCulture = oldCulture; + } + } + + [Fact] + public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() + { + var culture = CultureInfo.InvariantCulture; + Assert.Equal("0.1 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s1", culture)); + Assert.Equal("0.12 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s2", culture)); + Assert.Equal("0.123 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s3", culture)); + Assert.Equal("0.1235 Sv", new RadiationEquivalentDose(0.123456, RadiationEquivalentDoseUnit.Sievert).ToString("s4", culture)); + } + + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); + + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); + } + + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); + } + + [Fact] + public void Convert_ToBool_ThrowsInvalidCastException() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Throws(() => Convert.ToBoolean(quantity)); + } + + [Fact] + public void Convert_ToByte_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + } + + [Fact] + public void Convert_ToChar_ThrowsInvalidCastException() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Throws(() => Convert.ToChar(quantity)); + } + + [Fact] + public void Convert_ToDateTime_ThrowsInvalidCastException() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Throws(() => Convert.ToDateTime(quantity)); + } + + [Fact] + public void Convert_ToDecimal_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); + } + + [Fact] + public void Convert_ToDouble_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((double)quantity.Value, Convert.ToDouble(quantity)); + } + + [Fact] + public void Convert_ToInt16_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + } + + [Fact] + public void Convert_ToInt32_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + } + + [Fact] + public void Convert_ToInt64_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + } + + [Fact] + public void Convert_ToSByte_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + } + + [Fact] + public void Convert_ToSingle_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + } + + [Fact] + public void Convert_ToString_EqualsToString() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); + } + + [Fact] + public void Convert_ToUInt16_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + } + + [Fact] + public void Convert_ToUInt32_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + } + + [Fact] + public void Convert_ToUInt64_EqualsValueAsSameType() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + } + + [Fact] + public void Convert_ChangeType_SelfType_EqualsSelf() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(RadiationEquivalentDose))); + } + + [Fact] + public void Convert_ChangeType_UnitType_EqualsUnit() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RadiationEquivalentDoseUnit))); + } + + [Fact] + public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(RadiationEquivalentDose.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); + } + + [Fact] + public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Equal(RadiationEquivalentDose.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); + } + + [Fact] + public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); + } + + [Fact] + public void GetHashCode_Equals() + { + var quantity = RadiationEquivalentDose.FromSieverts(1.0); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RadiationEquivalentDose.Info.Name, quantity.Sieverts); + #else + var expected = new {RadiationEquivalentDose.Info.Name, valueInBaseUnit = quantity.Sieverts}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); + } + + [Theory] + [InlineData(1.0)] + [InlineData(-1.0)] + public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) + { + var quantity = RadiationEquivalentDose.FromSieverts(value); + Assert.Equal(RadiationEquivalentDose.FromSieverts(-value), -quantity); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs index ecf3283df7..bff4dbc272 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationExposureTestsBase.g.cs @@ -94,7 +94,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RadiationExposureUnit.CoulombPerKilogram, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RadiationExposure(double.PositiveInfinity, RadiationExposureUnit.CoulombPerKilogram)); @@ -104,7 +104,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RadiationExposure(double.NaN, RadiationExposureUnit.CoulombPerKilogram)); @@ -198,7 +198,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerKilogram_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RadiationExposure.FromCoulombsPerKilogram(double.PositiveInfinity)); @@ -208,7 +208,7 @@ public void FromCoulombsPerKilogram_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCoulombsPerKilogram_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RadiationExposure.FromCoulombsPerKilogram(double.NaN)); @@ -571,8 +571,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RadiationExposureUnit.CoulombPerKilogram, 1, RadiationExposureUnit.CoulombPerKilogram, true)] // Same value and unit. [InlineData(1, RadiationExposureUnit.CoulombPerKilogram, 2, RadiationExposureUnit.CoulombPerKilogram, false)] // Different value. - [InlineData(2, RadiationExposureUnit.CoulombPerKilogram, 1, RadiationExposureUnit.MicrocoulombPerKilogram, false)] // Different value and unit. - [InlineData(1, RadiationExposureUnit.CoulombPerKilogram, 1, RadiationExposureUnit.MicrocoulombPerKilogram, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RadiationExposureUnit unitA, double valueB, RadiationExposureUnit unitB, bool expectEqual) { var a = new RadiationExposure(valueA, unitA); @@ -885,7 +883,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RadiationExposure.FromCoulombsPerKilogram(1.0); - Assert.Equal(new {RadiationExposure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RadiationExposure.Info.Name, quantity.CoulombsPerKilogram); + #else + var expected = new {RadiationExposure.Info.Name, valueInBaseUnit = quantity.CoulombsPerKilogram}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs index 02573832a7..5f0a996896 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadioactivityTestsBase.g.cs @@ -178,7 +178,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RadioactivityUnit.Becquerel, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Radioactivity(double.PositiveInfinity, RadioactivityUnit.Becquerel)); @@ -188,7 +188,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Radioactivity(double.NaN, RadioactivityUnit.Becquerel)); @@ -387,7 +387,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBecquerels_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Radioactivity.FromBecquerels(double.PositiveInfinity)); @@ -397,7 +397,7 @@ public void FromBecquerels_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromBecquerels_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Radioactivity.FromBecquerels(double.NaN)); @@ -1826,8 +1826,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RadioactivityUnit.Becquerel, 1, RadioactivityUnit.Becquerel, true)] // Same value and unit. [InlineData(1, RadioactivityUnit.Becquerel, 2, RadioactivityUnit.Becquerel, false)] // Different value. - [InlineData(2, RadioactivityUnit.Becquerel, 1, RadioactivityUnit.Curie, false)] // Different value and unit. - [InlineData(1, RadioactivityUnit.Becquerel, 1, RadioactivityUnit.Curie, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RadioactivityUnit unitA, double valueB, RadioactivityUnit unitB, bool expectEqual) { var a = new Radioactivity(valueA, unitA); @@ -2182,7 +2180,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Radioactivity.FromBecquerels(1.0); - Assert.Equal(new {Radioactivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Radioactivity.Info.Name, quantity.Becquerels); + #else + var expected = new {Radioactivity.Info.Name, valueInBaseUnit = quantity.Becquerels}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index bcd7625c96..7e3da891f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioChangeRateUnit.DecimalFractionPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RatioChangeRate(double.PositiveInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RatioChangeRate(double.NaN, RatioChangeRateUnit.DecimalFractionPerSecond)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractionsPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromDecimalFractionsPerSecond_WithInfinityValue_DoNotThrowsArgumentE Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractionsPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NaN)); @@ -361,8 +361,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RatioChangeRateUnit.DecimalFractionPerSecond, 1, RatioChangeRateUnit.DecimalFractionPerSecond, true)] // Same value and unit. [InlineData(1, RatioChangeRateUnit.DecimalFractionPerSecond, 2, RatioChangeRateUnit.DecimalFractionPerSecond, false)] // Different value. - [InlineData(2, RatioChangeRateUnit.DecimalFractionPerSecond, 1, RatioChangeRateUnit.PercentPerSecond, false)] // Different value and unit. - [InlineData(1, RatioChangeRateUnit.DecimalFractionPerSecond, 1, RatioChangeRateUnit.PercentPerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RatioChangeRateUnit unitA, double valueB, RatioChangeRateUnit unitB, bool expectEqual) { var a = new RatioChangeRate(valueA, unitA); @@ -663,7 +661,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(new {RatioChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RatioChangeRate.Info.Name, quantity.DecimalFractionsPerSecond); + #else + var expected = new {RatioChangeRate.Info.Name, valueInBaseUnit = quantity.DecimalFractionsPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8b67419d0a..7a7cbbae9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioUnit.DecimalFraction, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Ratio(double.PositiveInfinity, RatioUnit.DecimalFraction)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Ratio(double.NaN, RatioUnit.DecimalFraction)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Ratio.FromDecimalFractions(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Ratio.FromDecimalFractions(double.NaN)); @@ -501,8 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RatioUnit.DecimalFraction, 1, RatioUnit.DecimalFraction, true)] // Same value and unit. [InlineData(1, RatioUnit.DecimalFraction, 2, RatioUnit.DecimalFraction, false)] // Different value. - [InlineData(2, RatioUnit.DecimalFraction, 1, RatioUnit.PartPerBillion, false)] // Different value and unit. - [InlineData(1, RatioUnit.DecimalFraction, 1, RatioUnit.PartPerBillion, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RatioUnit unitA, double valueB, RatioUnit unitB, bool expectEqual) { var a = new Ratio(valueA, unitA); @@ -811,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(new {Ratio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Ratio.Info.Name, quantity.DecimalFractions); + #else + var expected = new {Ratio.Info.Name, valueInBaseUnit = quantity.DecimalFractions}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 2a0cd7413e..7e20077b64 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ReactiveEnergy(double.PositiveInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ReactiveEnergy(double.NaN, ReactiveEnergyUnit.VoltampereReactiveHour)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltampereReactiveHours_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ReactiveEnergy.FromVoltampereReactiveHours(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromVoltampereReactiveHours_WithInfinityValue_DoNotThrowsArgumentExc Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltampereReactiveHours_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ReactiveEnergyUnit.VoltampereReactiveHour, 1, ReactiveEnergyUnit.VoltampereReactiveHour, true)] // Same value and unit. [InlineData(1, ReactiveEnergyUnit.VoltampereReactiveHour, 2, ReactiveEnergyUnit.VoltampereReactiveHour, false)] // Different value. - [InlineData(2, ReactiveEnergyUnit.VoltampereReactiveHour, 1, ReactiveEnergyUnit.KilovoltampereReactiveHour, false)] // Different value and unit. - [InlineData(1, ReactiveEnergyUnit.VoltampereReactiveHour, 1, ReactiveEnergyUnit.KilovoltampereReactiveHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ReactiveEnergyUnit unitA, double valueB, ReactiveEnergyUnit unitB, bool expectEqual) { var a = new ReactiveEnergy(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(new {ReactiveEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ReactiveEnergy.Info.Name, quantity.VoltampereReactiveHours); + #else + var expected = new {ReactiveEnergy.Info.Name, valueInBaseUnit = quantity.VoltampereReactiveHours}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 60499caa3f..fa62572681 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactivePowerUnit.VoltampereReactive, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ReactivePower(double.PositiveInfinity, ReactivePowerUnit.VoltampereReactive)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ReactivePower(double.NaN, ReactivePowerUnit.VoltampereReactive)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltamperesReactive_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ReactivePower.FromVoltamperesReactive(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromVoltamperesReactive_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromVoltamperesReactive_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ReactivePower.FromVoltamperesReactive(double.NaN)); @@ -431,8 +431,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ReactivePowerUnit.VoltampereReactive, 1, ReactivePowerUnit.VoltampereReactive, true)] // Same value and unit. [InlineData(1, ReactivePowerUnit.VoltampereReactive, 2, ReactivePowerUnit.VoltampereReactive, false)] // Different value. - [InlineData(2, ReactivePowerUnit.VoltampereReactive, 1, ReactivePowerUnit.GigavoltampereReactive, false)] // Different value and unit. - [InlineData(1, ReactivePowerUnit.VoltampereReactive, 1, ReactivePowerUnit.GigavoltampereReactive, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ReactivePowerUnit unitA, double valueB, ReactivePowerUnit unitB, bool expectEqual) { var a = new ReactivePower(valueA, unitA); @@ -737,7 +735,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(new {ReactivePower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ReactivePower.Info.Name, quantity.VoltamperesReactive); + #else + var expected = new {ReactivePower.Info.Name, valueInBaseUnit = quantity.VoltamperesReactive}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 1a066dd028..d78efd941d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -106,7 +106,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalAreaUnit.InverseSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ReciprocalArea(double.PositiveInfinity, ReciprocalAreaUnit.InverseSquareMeter)); @@ -116,7 +116,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ReciprocalArea(double.NaN, ReciprocalAreaUnit.InverseSquareMeter)); @@ -225,7 +225,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInverseSquareMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ReciprocalArea.FromInverseSquareMeters(double.PositiveInfinity)); @@ -235,7 +235,7 @@ public void FromInverseSquareMeters_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInverseSquareMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ReciprocalArea.FromInverseSquareMeters(double.NaN)); @@ -676,8 +676,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ReciprocalAreaUnit.InverseSquareMeter, 1, ReciprocalAreaUnit.InverseSquareMeter, true)] // Same value and unit. [InlineData(1, ReciprocalAreaUnit.InverseSquareMeter, 2, ReciprocalAreaUnit.InverseSquareMeter, false)] // Different value. - [InlineData(2, ReciprocalAreaUnit.InverseSquareMeter, 1, ReciprocalAreaUnit.InverseSquareCentimeter, false)] // Different value and unit. - [InlineData(1, ReciprocalAreaUnit.InverseSquareMeter, 1, ReciprocalAreaUnit.InverseSquareCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ReciprocalAreaUnit unitA, double valueB, ReciprocalAreaUnit unitB, bool expectEqual) { var a = new ReciprocalArea(valueA, unitA); @@ -996,7 +994,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(new {ReciprocalArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ReciprocalArea.Info.Name, quantity.InverseSquareMeters); + #else + var expected = new {ReciprocalArea.Info.Name, valueInBaseUnit = quantity.InverseSquareMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 3826eae96b..faaff052dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -102,7 +102,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalLengthUnit.InverseMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ReciprocalLength(double.PositiveInfinity, ReciprocalLengthUnit.InverseMeter)); @@ -112,7 +112,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ReciprocalLength(double.NaN, ReciprocalLengthUnit.InverseMeter)); @@ -216,7 +216,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInverseMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ReciprocalLength.FromInverseMeters(double.PositiveInfinity)); @@ -226,7 +226,7 @@ public void FromInverseMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInverseMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ReciprocalLength.FromInverseMeters(double.NaN)); @@ -881,8 +881,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ReciprocalLengthUnit.InverseMeter, 1, ReciprocalLengthUnit.InverseMeter, true)] // Same value and unit. [InlineData(1, ReciprocalLengthUnit.InverseMeter, 2, ReciprocalLengthUnit.InverseMeter, false)] // Different value. - [InlineData(2, ReciprocalLengthUnit.InverseMeter, 1, ReciprocalLengthUnit.InverseCentimeter, false)] // Different value and unit. - [InlineData(1, ReciprocalLengthUnit.InverseMeter, 1, ReciprocalLengthUnit.InverseCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ReciprocalLengthUnit unitA, double valueB, ReciprocalLengthUnit unitB, bool expectEqual) { var a = new ReciprocalLength(valueA, unitA); @@ -1199,7 +1197,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(new {ReciprocalLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ReciprocalLength.Info.Name, quantity.InverseMeters); + #else + var expected = new {ReciprocalLength.Info.Name, valueInBaseUnit = quantity.InverseMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index be8a616e92..612ef1470c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RelativeHumidityUnit.Percent, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RelativeHumidity(double.PositiveInfinity, RelativeHumidityUnit.Percent)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RelativeHumidity(double.NaN, RelativeHumidityUnit.Percent)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPercent_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RelativeHumidity.FromPercent(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromPercent_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromPercent_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RelativeHumidity.FromPercent(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RelativeHumidityUnit.Percent, 1, RelativeHumidityUnit.Percent, true)] // Same value and unit. [InlineData(1, RelativeHumidityUnit.Percent, 2, RelativeHumidityUnit.Percent, false)] // Different value. - [InlineData(2, RelativeHumidityUnit.Percent, 1, RelativeHumidityUnit.Percent, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RelativeHumidityUnit unitA, double valueB, RelativeHumidityUnit unitB, bool expectEqual) { var a = new RelativeHumidity(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(new {RelativeHumidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RelativeHumidity.Info.Name, quantity.Percent); + #else + var expected = new {RelativeHumidity.Info.Name, valueInBaseUnit = quantity.Percent}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 117c8046e0..ce28e611dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RotationalAcceleration(double.PositiveInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RotationalAcceleration(double.NaN, RotationalAccelerationUnit.RadianPerSecondSquared)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromRadiansPerSecondSquared_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromRadiansPerSecondSquared_WithInfinityValue_DoNotThrowsArgumentExc Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromRadiansPerSecondSquared_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NaN)); @@ -455,8 +455,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RotationalAccelerationUnit.RadianPerSecondSquared, 1, RotationalAccelerationUnit.RadianPerSecondSquared, true)] // Same value and unit. [InlineData(1, RotationalAccelerationUnit.RadianPerSecondSquared, 2, RotationalAccelerationUnit.RadianPerSecondSquared, false)] // Different value. - [InlineData(2, RotationalAccelerationUnit.RadianPerSecondSquared, 1, RotationalAccelerationUnit.DegreePerSecondSquared, false)] // Different value and unit. - [InlineData(1, RotationalAccelerationUnit.RadianPerSecondSquared, 1, RotationalAccelerationUnit.DegreePerSecondSquared, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RotationalAccelerationUnit unitA, double valueB, RotationalAccelerationUnit unitB, bool expectEqual) { var a = new RotationalAcceleration(valueA, unitA); @@ -761,7 +759,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(new {RotationalAcceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RotationalAcceleration.Info.Name, quantity.RadiansPerSecondSquared); + #else + var expected = new {RotationalAcceleration.Info.Name, valueInBaseUnit = quantity.RadiansPerSecondSquared}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index ee731ca9c5..248fe16cb3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -114,7 +114,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalSpeedUnit.RadianPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RotationalSpeed(double.PositiveInfinity, RotationalSpeedUnit.RadianPerSecond)); @@ -124,7 +124,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RotationalSpeed(double.NaN, RotationalSpeedUnit.RadianPerSecond)); @@ -243,7 +243,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromRadiansPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RotationalSpeed.FromRadiansPerSecond(double.PositiveInfinity)); @@ -253,7 +253,7 @@ public void FromRadiansPerSecond_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromRadiansPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RotationalSpeed.FromRadiansPerSecond(double.NaN)); @@ -1178,8 +1178,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RotationalSpeedUnit.RadianPerSecond, 1, RotationalSpeedUnit.RadianPerSecond, true)] // Same value and unit. [InlineData(1, RotationalSpeedUnit.RadianPerSecond, 2, RotationalSpeedUnit.RadianPerSecond, false)] // Different value. - [InlineData(2, RotationalSpeedUnit.RadianPerSecond, 1, RotationalSpeedUnit.CentiradianPerSecond, false)] // Different value and unit. - [InlineData(1, RotationalSpeedUnit.RadianPerSecond, 1, RotationalSpeedUnit.CentiradianPerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RotationalSpeedUnit unitA, double valueB, RotationalSpeedUnit unitB, bool expectEqual) { var a = new RotationalSpeed(valueA, unitA); @@ -1502,7 +1500,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(new {RotationalSpeed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RotationalSpeed.Info.Name, quantity.RadiansPerSecond); + #else + var expected = new {RotationalSpeed.Info.Name, valueInBaseUnit = quantity.RadiansPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 2b58133545..2b3e697bb1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -82,7 +82,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RotationalStiffnessPerLength(double.PositiveInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); @@ -92,7 +92,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RotationalStiffnessPerLength(double.NaN, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); @@ -171,7 +171,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerRadianPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.PositiveInfinity)); @@ -181,7 +181,7 @@ public void FromNewtonMetersPerRadianPerMeter_WithInfinityValue_DoNotThrowsArgum Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerRadianPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NaN)); @@ -658,8 +658,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, 1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, true)] // Same value and unit. [InlineData(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, 2, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, false)] // Different value. - [InlineData(2, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, 1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, false)] // Different value and unit. - [InlineData(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, 1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RotationalStiffnessPerLengthUnit unitA, double valueB, RotationalStiffnessPerLengthUnit unitB, bool expectEqual) { var a = new RotationalStiffnessPerLength(valueA, unitA); @@ -966,7 +964,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(new {RotationalStiffnessPerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RotationalStiffnessPerLength.Info.Name, quantity.NewtonMetersPerRadianPerMeter); + #else + var expected = new {RotationalStiffnessPerLength.Info.Name, valueInBaseUnit = quantity.NewtonMetersPerRadianPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 13d340cd8e..d96c9a636e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -194,7 +194,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new RotationalStiffness(double.PositiveInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); @@ -204,7 +204,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new RotationalStiffness(double.NaN, RotationalStiffnessUnit.NewtonMeterPerRadian)); @@ -423,7 +423,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerRadian_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => RotationalStiffness.FromNewtonMetersPerRadian(double.PositiveInfinity)); @@ -433,7 +433,7 @@ public void FromNewtonMetersPerRadian_WithInfinityValue_DoNotThrowsArgumentExcep Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerRadian_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NaN)); @@ -2930,8 +2930,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, RotationalStiffnessUnit.NewtonMeterPerRadian, 1, RotationalStiffnessUnit.NewtonMeterPerRadian, true)] // Same value and unit. [InlineData(1, RotationalStiffnessUnit.NewtonMeterPerRadian, 2, RotationalStiffnessUnit.NewtonMeterPerRadian, false)] // Different value. - [InlineData(2, RotationalStiffnessUnit.NewtonMeterPerRadian, 1, RotationalStiffnessUnit.CentinewtonMeterPerDegree, false)] // Different value and unit. - [InlineData(1, RotationalStiffnessUnit.NewtonMeterPerRadian, 1, RotationalStiffnessUnit.CentinewtonMeterPerDegree, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RotationalStiffnessUnit unitA, double valueB, RotationalStiffnessUnit unitB, bool expectEqual) { var a = new RotationalStiffness(valueA, unitA); @@ -3294,7 +3292,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(new {RotationalStiffness.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(RotationalStiffness.Info.Name, quantity.NewtonMetersPerRadian); + #else + var expected = new {RotationalStiffness.Info.Name, valueInBaseUnit = quantity.NewtonMetersPerRadian}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 57dc7da0d2..76fc7eac74 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ScalarUnit.Amount, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Scalar(double.PositiveInfinity, ScalarUnit.Amount)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Scalar(double.NaN, ScalarUnit.Amount)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmount_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Scalar.FromAmount(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromAmount_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromAmount_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Scalar.FromAmount(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ScalarUnit.Amount, 1, ScalarUnit.Amount, true)] // Same value and unit. [InlineData(1, ScalarUnit.Amount, 2, ScalarUnit.Amount, false)] // Different value. - [InlineData(2, ScalarUnit.Amount, 1, ScalarUnit.Amount, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ScalarUnit unitA, double valueB, ScalarUnit unitB, bool expectEqual) { var a = new Scalar(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(new {Scalar.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Scalar.Info.Name, quantity.Amount); + #else + var expected = new {Scalar.Info.Name, valueInBaseUnit = quantity.Amount}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 1d75039295..a365024afd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SolidAngleUnit.Steradian, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SolidAngle(double.PositiveInfinity, SolidAngleUnit.Steradian)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SolidAngle(double.NaN, SolidAngleUnit.Steradian)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSteradians_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SolidAngle.FromSteradians(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromSteradians_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSteradians_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SolidAngle.FromSteradians(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SolidAngleUnit.Steradian, 1, SolidAngleUnit.Steradian, true)] // Same value and unit. [InlineData(1, SolidAngleUnit.Steradian, 2, SolidAngleUnit.Steradian, false)] // Different value. - [InlineData(2, SolidAngleUnit.Steradian, 1, SolidAngleUnit.Steradian, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SolidAngleUnit unitA, double valueB, SolidAngleUnit unitB, bool expectEqual) { var a = new SolidAngle(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(new {SolidAngle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SolidAngle.Info.Name, quantity.Steradians); + #else + var expected = new {SolidAngle.Info.Name, valueInBaseUnit = quantity.Steradians}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index c31874a81d..5c0c786bdc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -182,7 +182,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SpecificEnergy(double.PositiveInfinity, SpecificEnergyUnit.JoulePerKilogram)); @@ -192,7 +192,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SpecificEnergy(double.NaN, SpecificEnergyUnit.JoulePerKilogram)); @@ -396,7 +396,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKilogram_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SpecificEnergy.FromJoulesPerKilogram(double.PositiveInfinity)); @@ -406,7 +406,7 @@ public void FromJoulesPerKilogram_WithInfinityValue_DoNotThrowsArgumentException Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKilogram_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SpecificEnergy.FromJoulesPerKilogram(double.NaN)); @@ -1341,8 +1341,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpecificEnergyUnit.JoulePerKilogram, 1, SpecificEnergyUnit.JoulePerKilogram, true)] // Same value and unit. [InlineData(1, SpecificEnergyUnit.JoulePerKilogram, 2, SpecificEnergyUnit.JoulePerKilogram, false)] // Different value. - [InlineData(2, SpecificEnergyUnit.JoulePerKilogram, 1, SpecificEnergyUnit.BtuPerPound, false)] // Different value and unit. - [InlineData(1, SpecificEnergyUnit.JoulePerKilogram, 1, SpecificEnergyUnit.BtuPerPound, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpecificEnergyUnit unitA, double valueB, SpecificEnergyUnit unitB, bool expectEqual) { var a = new SpecificEnergy(valueA, unitA); @@ -1699,7 +1697,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(new {SpecificEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SpecificEnergy.Info.Name, quantity.JoulesPerKilogram); + #else + var expected = new {SpecificEnergy.Info.Name, valueInBaseUnit = quantity.JoulesPerKilogram}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index af0c1ee8ff..d8abbff502 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEntropyUnit.JoulePerKilogramKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SpecificEntropy(double.PositiveInfinity, SpecificEntropyUnit.JoulePerKilogramKelvin)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SpecificEntropy(double.NaN, SpecificEntropyUnit.JoulePerKilogramKelvin)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKilogramKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromJoulesPerKilogramKelvin_WithInfinityValue_DoNotThrowsArgumentExc Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerKilogramKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.NaN)); @@ -630,8 +630,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpecificEntropyUnit.JoulePerKilogramKelvin, 1, SpecificEntropyUnit.JoulePerKilogramKelvin, true)] // Same value and unit. [InlineData(1, SpecificEntropyUnit.JoulePerKilogramKelvin, 2, SpecificEntropyUnit.JoulePerKilogramKelvin, false)] // Different value. - [InlineData(2, SpecificEntropyUnit.JoulePerKilogramKelvin, 1, SpecificEntropyUnit.BtuPerPoundFahrenheit, false)] // Different value and unit. - [InlineData(1, SpecificEntropyUnit.JoulePerKilogramKelvin, 1, SpecificEntropyUnit.BtuPerPoundFahrenheit, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpecificEntropyUnit unitA, double valueB, SpecificEntropyUnit unitB, bool expectEqual) { var a = new SpecificEntropy(valueA, unitA); @@ -946,7 +944,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(new {SpecificEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SpecificEntropy.Info.Name, quantity.JoulesPerKilogramKelvin); + #else + var expected = new {SpecificEntropy.Info.Name, valueInBaseUnit = quantity.JoulesPerKilogramKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 43e0506737..14d947a463 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SpecificFuelConsumption(double.PositiveInfinity, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SpecificFuelConsumption(double.NaN, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGramsPerKiloNewtonSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromGramsPerKiloNewtonSecond_WithInfinityValue_DoNotThrowsArgumentEx Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromGramsPerKiloNewtonSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(double.NaN)); @@ -431,8 +431,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, 1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, true)] // Same value and unit. [InlineData(1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, 2, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, false)] // Different value. - [InlineData(2, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, 1, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, false)] // Different value and unit. - [InlineData(1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, 1, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpecificFuelConsumptionUnit unitA, double valueB, SpecificFuelConsumptionUnit unitB, bool expectEqual) { var a = new SpecificFuelConsumption(valueA, unitA); @@ -737,7 +735,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(new {SpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SpecificFuelConsumption.Info.Name, quantity.GramsPerKiloNewtonSecond); + #else + var expected = new {SpecificFuelConsumption.Info.Name, valueInBaseUnit = quantity.GramsPerKiloNewtonSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 2ff6e37598..db9dc00a61 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -74,7 +74,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SpecificVolume(double.PositiveInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); @@ -84,7 +84,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SpecificVolume(double.NaN, SpecificVolumeUnit.CubicMeterPerKilogram)); @@ -153,7 +153,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerKilogram_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SpecificVolume.FromCubicMetersPerKilogram(double.PositiveInfinity)); @@ -163,7 +163,7 @@ public void FromCubicMetersPerKilogram_WithInfinityValue_DoNotThrowsArgumentExce Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerKilogram_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SpecificVolume.FromCubicMetersPerKilogram(double.NaN)); @@ -396,8 +396,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpecificVolumeUnit.CubicMeterPerKilogram, 1, SpecificVolumeUnit.CubicMeterPerKilogram, true)] // Same value and unit. [InlineData(1, SpecificVolumeUnit.CubicMeterPerKilogram, 2, SpecificVolumeUnit.CubicMeterPerKilogram, false)] // Different value. - [InlineData(2, SpecificVolumeUnit.CubicMeterPerKilogram, 1, SpecificVolumeUnit.CubicFootPerPound, false)] // Different value and unit. - [InlineData(1, SpecificVolumeUnit.CubicMeterPerKilogram, 1, SpecificVolumeUnit.CubicFootPerPound, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpecificVolumeUnit unitA, double valueB, SpecificVolumeUnit unitB, bool expectEqual) { var a = new SpecificVolume(valueA, unitA); @@ -700,7 +698,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(new {SpecificVolume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SpecificVolume.Info.Name, quantity.CubicMetersPerKilogram); + #else + var expected = new {SpecificVolume.Info.Name, valueInBaseUnit = quantity.CubicMetersPerKilogram}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index ba99208dd9..4e586b8177 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -130,7 +130,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificWeightUnit.NewtonPerCubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new SpecificWeight(double.PositiveInfinity, SpecificWeightUnit.NewtonPerCubicMeter)); @@ -140,7 +140,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new SpecificWeight(double.NaN, SpecificWeightUnit.NewtonPerCubicMeter)); @@ -279,7 +279,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => SpecificWeight.FromNewtonsPerCubicMeter(double.PositiveInfinity)); @@ -289,7 +289,7 @@ public void FromNewtonsPerCubicMeter_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonsPerCubicMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => SpecificWeight.FromNewtonsPerCubicMeter(double.NaN)); @@ -886,8 +886,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpecificWeightUnit.NewtonPerCubicMeter, 1, SpecificWeightUnit.NewtonPerCubicMeter, true)] // Same value and unit. [InlineData(1, SpecificWeightUnit.NewtonPerCubicMeter, 2, SpecificWeightUnit.NewtonPerCubicMeter, false)] // Different value. - [InlineData(2, SpecificWeightUnit.NewtonPerCubicMeter, 1, SpecificWeightUnit.KilogramForcePerCubicCentimeter, false)] // Different value and unit. - [InlineData(1, SpecificWeightUnit.NewtonPerCubicMeter, 1, SpecificWeightUnit.KilogramForcePerCubicCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpecificWeightUnit unitA, double valueB, SpecificWeightUnit unitB, bool expectEqual) { var a = new SpecificWeight(valueA, unitA); @@ -1218,7 +1216,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(new {SpecificWeight.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(SpecificWeight.Info.Name, quantity.NewtonsPerCubicMeter); + #else + var expected = new {SpecificWeight.Info.Name, valueInBaseUnit = quantity.NewtonsPerCubicMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index d8e25872a8..0367006934 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -194,7 +194,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpeedUnit.MeterPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Speed(double.PositiveInfinity, SpeedUnit.MeterPerSecond)); @@ -204,7 +204,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Speed(double.NaN, SpeedUnit.MeterPerSecond)); @@ -423,7 +423,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Speed.FromMetersPerSecond(double.PositiveInfinity)); @@ -433,7 +433,7 @@ public void FromMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Speed.FromMetersPerSecond(double.NaN)); @@ -2166,8 +2166,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, SpeedUnit.MeterPerSecond, 1, SpeedUnit.MeterPerSecond, true)] // Same value and unit. [InlineData(1, SpeedUnit.MeterPerSecond, 2, SpeedUnit.MeterPerSecond, false)] // Different value. - [InlineData(2, SpeedUnit.MeterPerSecond, 1, SpeedUnit.CentimeterPerHour, false)] // Different value and unit. - [InlineData(1, SpeedUnit.MeterPerSecond, 1, SpeedUnit.CentimeterPerHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, SpeedUnit unitA, double valueB, SpeedUnit unitB, bool expectEqual) { var a = new Speed(valueA, unitA); @@ -2530,7 +2528,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(new {Speed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Speed.Info.Name, quantity.MetersPerSecond); + #else + var expected = new {Speed.Info.Name, valueInBaseUnit = quantity.MetersPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 1d09dc4657..82f7f2533f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new StandardVolumeFlow(double.PositiveInfinity, StandardVolumeFlowUnit.StandardCubicMeterPerSecond)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new StandardVolumeFlow(double.NaN, StandardVolumeFlowUnit.StandardCubicMeterPerSecond)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromStandardCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => StandardVolumeFlow.FromStandardCubicMetersPerSecond(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromStandardCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgume Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromStandardCubicMetersPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => StandardVolumeFlow.FromStandardCubicMetersPerSecond(double.NaN)); @@ -606,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, 1, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, true)] // Same value and unit. [InlineData(1, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, 2, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, false)] // Different value. - [InlineData(2, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, 1, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, false)] // Different value and unit. - [InlineData(1, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, 1, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, StandardVolumeFlowUnit unitA, double valueB, StandardVolumeFlowUnit unitB, bool expectEqual) { var a = new StandardVolumeFlow(valueA, unitA); @@ -922,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(new {StandardVolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(StandardVolumeFlow.Info.Name, quantity.StandardCubicMetersPerSecond); + #else + var expected = new {StandardVolumeFlow.Info.Name, valueInBaseUnit = quantity.StandardCubicMetersPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index d90248a5ff..eb525195eb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -102,7 +102,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new TemperatureChangeRate(double.PositiveInfinity, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); @@ -112,7 +112,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new TemperatureChangeRate(double.NaN, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); @@ -216,7 +216,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDegreesCelsiusPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.PositiveInfinity)); @@ -226,7 +226,7 @@ public void FromDegreesCelsiusPerSecond_WithInfinityValue_DoNotThrowsArgumentExc Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDegreesCelsiusPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.NaN)); @@ -641,8 +641,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, 1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, true)] // Same value and unit. [InlineData(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, 2, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, false)] // Different value. - [InlineData(2, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, 1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, false)] // Different value and unit. - [InlineData(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, 1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TemperatureChangeRateUnit unitA, double valueB, TemperatureChangeRateUnit unitB, bool expectEqual) { var a = new TemperatureChangeRate(valueA, unitA); @@ -959,7 +957,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(new {TemperatureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(TemperatureChangeRate.Info.Name, quantity.DegreesCelsiusPerSecond); + #else + var expected = new {TemperatureChangeRate.Info.Name, valueInBaseUnit = quantity.DegreesCelsiusPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 1c4304861d..93091f7cab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureDeltaUnit.Kelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new TemperatureDelta(double.PositiveInfinity, TemperatureDeltaUnit.Kelvin)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new TemperatureDelta(double.NaN, TemperatureDeltaUnit.Kelvin)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvins_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => TemperatureDelta.FromKelvins(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromKelvins_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvins_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => TemperatureDelta.FromKelvins(double.NaN)); @@ -606,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TemperatureDeltaUnit.Kelvin, 1, TemperatureDeltaUnit.Kelvin, true)] // Same value and unit. [InlineData(1, TemperatureDeltaUnit.Kelvin, 2, TemperatureDeltaUnit.Kelvin, false)] // Different value. - [InlineData(2, TemperatureDeltaUnit.Kelvin, 1, TemperatureDeltaUnit.DegreeCelsius, false)] // Different value and unit. - [InlineData(1, TemperatureDeltaUnit.Kelvin, 1, TemperatureDeltaUnit.DegreeCelsius, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TemperatureDeltaUnit unitA, double valueB, TemperatureDeltaUnit unitB, bool expectEqual) { var a = new TemperatureDelta(valueA, unitA); @@ -922,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(new {TemperatureDelta.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(TemperatureDelta.Info.Name, quantity.Kelvins); + #else + var expected = new {TemperatureDelta.Info.Name, valueInBaseUnit = quantity.Kelvins}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index 6e983b0018..8c957cd255 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -78,7 +78,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureGradientUnit.KelvinPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new TemperatureGradient(double.PositiveInfinity, TemperatureGradientUnit.KelvinPerMeter)); @@ -88,7 +88,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new TemperatureGradient(double.NaN, TemperatureGradientUnit.KelvinPerMeter)); @@ -162,7 +162,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvinsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => TemperatureGradient.FromKelvinsPerMeter(double.PositiveInfinity)); @@ -172,7 +172,7 @@ public void FromKelvinsPerMeter_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvinsPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => TemperatureGradient.FromKelvinsPerMeter(double.NaN)); @@ -431,8 +431,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TemperatureGradientUnit.KelvinPerMeter, 1, TemperatureGradientUnit.KelvinPerMeter, true)] // Same value and unit. [InlineData(1, TemperatureGradientUnit.KelvinPerMeter, 2, TemperatureGradientUnit.KelvinPerMeter, false)] // Different value. - [InlineData(2, TemperatureGradientUnit.KelvinPerMeter, 1, TemperatureGradientUnit.DegreeCelsiusPerKilometer, false)] // Different value and unit. - [InlineData(1, TemperatureGradientUnit.KelvinPerMeter, 1, TemperatureGradientUnit.DegreeCelsiusPerKilometer, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TemperatureGradientUnit unitA, double valueB, TemperatureGradientUnit unitB, bool expectEqual) { var a = new TemperatureGradient(valueA, unitA); @@ -737,7 +735,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(new {TemperatureGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(TemperatureGradient.Info.Name, quantity.KelvinsPerMeter); + #else + var expected = new {TemperatureGradient.Info.Name, valueInBaseUnit = quantity.KelvinsPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 82937f5a70..64912f3e2f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -102,7 +102,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureUnit.Kelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Temperature(double.PositiveInfinity, TemperatureUnit.Kelvin)); @@ -112,7 +112,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Temperature(double.NaN, TemperatureUnit.Kelvin)); @@ -216,7 +216,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvins_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Temperature.FromKelvins(double.PositiveInfinity)); @@ -226,7 +226,7 @@ public void FromKelvins_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromKelvins_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Temperature.FromKelvins(double.NaN)); @@ -629,8 +629,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TemperatureUnit.Kelvin, 1, TemperatureUnit.Kelvin, true)] // Same value and unit. [InlineData(1, TemperatureUnit.Kelvin, 2, TemperatureUnit.Kelvin, false)] // Different value. - [InlineData(2, TemperatureUnit.Kelvin, 1, TemperatureUnit.DegreeCelsius, false)] // Different value and unit. - [InlineData(1, TemperatureUnit.Kelvin, 1, TemperatureUnit.DegreeCelsius, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TemperatureUnit unitA, double valueB, TemperatureUnit unitB, bool expectEqual) { var a = new Temperature(valueA, unitA); @@ -947,7 +945,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(new {Temperature.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Temperature.Info.Name, quantity.Kelvins); + #else + var expected = new {Temperature.Info.Name, valueInBaseUnit = quantity.Kelvins}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 5b2a396e05..a038c138ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ThermalConductivity(double.PositiveInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ThermalConductivity(double.NaN, ThermalConductivityUnit.WattPerMeterKelvin)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerMeterKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ThermalConductivity.FromWattsPerMeterKelvin(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromWattsPerMeterKelvin_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromWattsPerMeterKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NaN)); @@ -361,8 +361,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ThermalConductivityUnit.WattPerMeterKelvin, 1, ThermalConductivityUnit.WattPerMeterKelvin, true)] // Same value and unit. [InlineData(1, ThermalConductivityUnit.WattPerMeterKelvin, 2, ThermalConductivityUnit.WattPerMeterKelvin, false)] // Different value. - [InlineData(2, ThermalConductivityUnit.WattPerMeterKelvin, 1, ThermalConductivityUnit.BtuPerHourFootFahrenheit, false)] // Different value and unit. - [InlineData(1, ThermalConductivityUnit.WattPerMeterKelvin, 1, ThermalConductivityUnit.BtuPerHourFootFahrenheit, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ThermalConductivityUnit unitA, double valueB, ThermalConductivityUnit unitB, bool expectEqual) { var a = new ThermalConductivity(valueA, unitA); @@ -663,7 +661,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(new {ThermalConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ThermalConductivity.Info.Name, quantity.WattsPerMeterKelvin); + #else + var expected = new {ThermalConductivity.Info.Name, valueInBaseUnit = quantity.WattsPerMeterKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index f85319ac12..3ba8f31f37 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new ThermalResistance(double.PositiveInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new ThermalResistance(double.NaN, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeterKelvinsPerKilowatt_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromSquareMeterKelvinsPerKilowatt_WithInfinityValue_DoNotThrowsArgum Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromSquareMeterKelvinsPerKilowatt_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NaN)); @@ -501,8 +501,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, 1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, true)] // Same value and unit. [InlineData(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, 2, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, false)] // Different value. - [InlineData(2, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, 1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, false)] // Different value and unit. - [InlineData(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, 1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, ThermalResistanceUnit unitA, double valueB, ThermalResistanceUnit unitB, bool expectEqual) { var a = new ThermalResistance(valueA, unitA); @@ -811,7 +809,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(new {ThermalResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(ThermalResistance.Info.Name, quantity.SquareMeterKelvinsPerKilowatt); + #else + var expected = new {ThermalResistance.Info.Name, valueInBaseUnit = quantity.SquareMeterKelvinsPerKilowatt}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 8f0a386c7f..907ee73a88 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -146,7 +146,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new TorquePerLength(double.PositiveInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); @@ -156,7 +156,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new TorquePerLength(double.NaN, TorquePerLengthUnit.NewtonMeterPerMeter)); @@ -315,7 +315,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => TorquePerLength.FromNewtonMetersPerMeter(double.PositiveInfinity)); @@ -325,7 +325,7 @@ public void FromNewtonMetersPerMeter_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMetersPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => TorquePerLength.FromNewtonMetersPerMeter(double.NaN)); @@ -1098,8 +1098,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.NewtonMeterPerMeter, true)] // Same value and unit. [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 2, TorquePerLengthUnit.NewtonMeterPerMeter, false)] // Different value. - [InlineData(2, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, false)] // Different value and unit. - [InlineData(1, TorquePerLengthUnit.NewtonMeterPerMeter, 1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TorquePerLengthUnit unitA, double valueB, TorquePerLengthUnit unitB, bool expectEqual) { var a = new TorquePerLength(valueA, unitA); @@ -1438,7 +1436,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(new {TorquePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(TorquePerLength.Info.Name, quantity.NewtonMetersPerMeter); + #else + var expected = new {TorquePerLength.Info.Name, valueInBaseUnit = quantity.NewtonMetersPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 77191658b1..ae9176c25a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -162,7 +162,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorqueUnit.NewtonMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Torque(double.PositiveInfinity, TorqueUnit.NewtonMeter)); @@ -172,7 +172,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Torque(double.NaN, TorqueUnit.NewtonMeter)); @@ -351,7 +351,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Torque.FromNewtonMeters(double.PositiveInfinity)); @@ -361,7 +361,7 @@ public void FromNewtonMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNewtonMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Torque.FromNewtonMeters(double.NaN)); @@ -1238,8 +1238,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TorqueUnit.NewtonMeter, 1, TorqueUnit.NewtonMeter, true)] // Same value and unit. [InlineData(1, TorqueUnit.NewtonMeter, 2, TorqueUnit.NewtonMeter, false)] // Different value. - [InlineData(2, TorqueUnit.NewtonMeter, 1, TorqueUnit.GramForceCentimeter, false)] // Different value and unit. - [InlineData(1, TorqueUnit.NewtonMeter, 1, TorqueUnit.GramForceCentimeter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TorqueUnit unitA, double valueB, TorqueUnit unitB, bool expectEqual) { var a = new Torque(valueA, unitA); @@ -1586,7 +1584,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(new {Torque.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Torque.Info.Name, quantity.NewtonMeters); + #else + var expected = new {Torque.Info.Name, valueInBaseUnit = quantity.NewtonMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 582a87ef91..3e91fc3852 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TurbidityUnit.NTU, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Turbidity(double.PositiveInfinity, TurbidityUnit.NTU)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Turbidity(double.NaN, TurbidityUnit.NTU)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNTU_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Turbidity.FromNTU(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromNTU_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromNTU_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Turbidity.FromNTU(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, TurbidityUnit.NTU, 1, TurbidityUnit.NTU, true)] // Same value and unit. [InlineData(1, TurbidityUnit.NTU, 2, TurbidityUnit.NTU, false)] // Different value. - [InlineData(2, TurbidityUnit.NTU, 1, TurbidityUnit.NTU, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, TurbidityUnit unitA, double valueB, TurbidityUnit unitB, bool expectEqual) { var a = new Turbidity(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(new {Turbidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Turbidity.Info.Name, quantity.NTU); + #else + var expected = new {Turbidity.Info.Name, valueInBaseUnit = quantity.NTU}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 75243790a9..bfe8d46694 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -66,7 +66,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VitaminAUnit.InternationalUnit, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VitaminA(double.PositiveInfinity, VitaminAUnit.InternationalUnit)); @@ -76,7 +76,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VitaminA(double.NaN, VitaminAUnit.InternationalUnit)); @@ -135,7 +135,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInternationalUnits_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VitaminA.FromInternationalUnits(double.PositiveInfinity)); @@ -145,7 +145,7 @@ public void FromInternationalUnits_WithInfinityValue_DoNotThrowsArgumentExceptio Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromInternationalUnits_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VitaminA.FromInternationalUnits(double.NaN)); @@ -326,7 +326,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VitaminAUnit.InternationalUnit, 1, VitaminAUnit.InternationalUnit, true)] // Same value and unit. [InlineData(1, VitaminAUnit.InternationalUnit, 2, VitaminAUnit.InternationalUnit, false)] // Different value. - [InlineData(2, VitaminAUnit.InternationalUnit, 1, VitaminAUnit.InternationalUnit, false)] // Different value and unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VitaminAUnit unitA, double valueB, VitaminAUnit unitB, bool expectEqual) { var a = new VitaminA(valueA, unitA); @@ -625,7 +624,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(new {VitaminA.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VitaminA.Info.Name, quantity.InternationalUnits); + #else + var expected = new {VitaminA.Info.Name, valueInBaseUnit = quantity.InternationalUnits}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 887809dba8..ba2719983d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -142,7 +142,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeConcentrationUnit.DecimalFraction, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VolumeConcentration(double.PositiveInfinity, VolumeConcentrationUnit.DecimalFraction)); @@ -152,7 +152,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VolumeConcentration(double.NaN, VolumeConcentrationUnit.DecimalFraction)); @@ -306,7 +306,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VolumeConcentration.FromDecimalFractions(double.PositiveInfinity)); @@ -316,7 +316,7 @@ public void FromDecimalFractions_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromDecimalFractions_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VolumeConcentration.FromDecimalFractions(double.NaN)); @@ -1015,8 +1015,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumeConcentrationUnit.DecimalFraction, 1, VolumeConcentrationUnit.DecimalFraction, true)] // Same value and unit. [InlineData(1, VolumeConcentrationUnit.DecimalFraction, 2, VolumeConcentrationUnit.DecimalFraction, false)] // Different value. - [InlineData(2, VolumeConcentrationUnit.DecimalFraction, 1, VolumeConcentrationUnit.CentilitersPerLiter, false)] // Different value and unit. - [InlineData(1, VolumeConcentrationUnit.DecimalFraction, 1, VolumeConcentrationUnit.CentilitersPerLiter, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumeConcentrationUnit unitA, double valueB, VolumeConcentrationUnit unitB, bool expectEqual) { var a = new VolumeConcentration(valueA, unitA); @@ -1353,7 +1351,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(new {VolumeConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VolumeConcentration.Info.Name, quantity.DecimalFractions); + #else + var expected = new {VolumeConcentration.Info.Name, valueInBaseUnit = quantity.DecimalFractions}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 4a98311664..7635fa7a88 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -70,7 +70,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VolumeFlowPerArea(double.PositiveInfinity, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter)); @@ -80,7 +80,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VolumeFlowPerArea(double.NaN, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter)); @@ -144,7 +144,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerSecondPerSquareMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(double.PositiveInfinity)); @@ -154,7 +154,7 @@ public void FromCubicMetersPerSecondPerSquareMeter_WithInfinityValue_DoNotThrows Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerSecondPerSquareMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(double.NaN)); @@ -361,8 +361,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, 1, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, true)] // Same value and unit. [InlineData(1, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, 2, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, false)] // Different value. - [InlineData(2, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, 1, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, false)] // Different value and unit. - [InlineData(1, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, 1, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumeFlowPerAreaUnit unitA, double valueB, VolumeFlowPerAreaUnit unitB, bool expectEqual) { var a = new VolumeFlowPerArea(valueA, unitA); @@ -663,7 +661,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(new {VolumeFlowPerArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VolumeFlowPerArea.Info.Name, quantity.CubicMetersPerSecondPerSquareMeter); + #else + var expected = new {VolumeFlowPerArea.Info.Name, valueInBaseUnit = quantity.CubicMetersPerSecondPerSquareMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 18f5796513..6f3a994a0d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -60,10 +60,18 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase protected abstract double CubicYardsPerHourInOneCubicMeterPerSecond { get; } protected abstract double CubicYardsPerMinuteInOneCubicMeterPerSecond { get; } protected abstract double CubicYardsPerSecondInOneCubicMeterPerSecond { get; } + protected abstract double DecalitersPerDayInOneCubicMeterPerSecond { get; } + protected abstract double DecalitersPerHourInOneCubicMeterPerSecond { get; } + protected abstract double DecalitersPerMinuteInOneCubicMeterPerSecond { get; } + protected abstract double DecalitersPerSecondInOneCubicMeterPerSecond { get; } protected abstract double DecilitersPerDayInOneCubicMeterPerSecond { get; } protected abstract double DecilitersPerHourInOneCubicMeterPerSecond { get; } protected abstract double DecilitersPerMinuteInOneCubicMeterPerSecond { get; } protected abstract double DecilitersPerSecondInOneCubicMeterPerSecond { get; } + protected abstract double HectolitersPerDayInOneCubicMeterPerSecond { get; } + protected abstract double HectolitersPerHourInOneCubicMeterPerSecond { get; } + protected abstract double HectolitersPerMinuteInOneCubicMeterPerSecond { get; } + protected abstract double HectolitersPerSecondInOneCubicMeterPerSecond { get; } protected abstract double KilolitersPerDayInOneCubicMeterPerSecond { get; } protected abstract double KilolitersPerHourInOneCubicMeterPerSecond { get; } protected abstract double KilolitersPerMinuteInOneCubicMeterPerSecond { get; } @@ -129,10 +137,18 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase protected virtual double CubicYardsPerHourTolerance { get { return 1e-5; } } protected virtual double CubicYardsPerMinuteTolerance { get { return 1e-5; } } protected virtual double CubicYardsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecalitersPerDayTolerance { get { return 1e-5; } } + protected virtual double DecalitersPerHourTolerance { get { return 1e-5; } } + protected virtual double DecalitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double DecalitersPerSecondTolerance { get { return 1e-5; } } protected virtual double DecilitersPerDayTolerance { get { return 1e-5; } } protected virtual double DecilitersPerHourTolerance { get { return 1e-5; } } protected virtual double DecilitersPerMinuteTolerance { get { return 1e-5; } } protected virtual double DecilitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double HectolitersPerDayTolerance { get { return 1e-5; } } + protected virtual double HectolitersPerHourTolerance { get { return 1e-5; } } + protected virtual double HectolitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double HectolitersPerSecondTolerance { get { return 1e-5; } } protected virtual double KilolitersPerDayTolerance { get { return 1e-5; } } protected virtual double KilolitersPerHourTolerance { get { return 1e-5; } } protected virtual double KilolitersPerMinuteTolerance { get { return 1e-5; } } @@ -202,10 +218,18 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase VolumeFlowUnit.CubicYardPerHour => (CubicYardsPerHourInOneCubicMeterPerSecond, CubicYardsPerHourTolerance), VolumeFlowUnit.CubicYardPerMinute => (CubicYardsPerMinuteInOneCubicMeterPerSecond, CubicYardsPerMinuteTolerance), VolumeFlowUnit.CubicYardPerSecond => (CubicYardsPerSecondInOneCubicMeterPerSecond, CubicYardsPerSecondTolerance), + VolumeFlowUnit.DecaliterPerDay => (DecalitersPerDayInOneCubicMeterPerSecond, DecalitersPerDayTolerance), + VolumeFlowUnit.DecaliterPerHour => (DecalitersPerHourInOneCubicMeterPerSecond, DecalitersPerHourTolerance), + VolumeFlowUnit.DecaliterPerMinute => (DecalitersPerMinuteInOneCubicMeterPerSecond, DecalitersPerMinuteTolerance), + VolumeFlowUnit.DecaliterPerSecond => (DecalitersPerSecondInOneCubicMeterPerSecond, DecalitersPerSecondTolerance), VolumeFlowUnit.DeciliterPerDay => (DecilitersPerDayInOneCubicMeterPerSecond, DecilitersPerDayTolerance), VolumeFlowUnit.DeciliterPerHour => (DecilitersPerHourInOneCubicMeterPerSecond, DecilitersPerHourTolerance), VolumeFlowUnit.DeciliterPerMinute => (DecilitersPerMinuteInOneCubicMeterPerSecond, DecilitersPerMinuteTolerance), VolumeFlowUnit.DeciliterPerSecond => (DecilitersPerSecondInOneCubicMeterPerSecond, DecilitersPerSecondTolerance), + VolumeFlowUnit.HectoliterPerDay => (HectolitersPerDayInOneCubicMeterPerSecond, HectolitersPerDayTolerance), + VolumeFlowUnit.HectoliterPerHour => (HectolitersPerHourInOneCubicMeterPerSecond, HectolitersPerHourTolerance), + VolumeFlowUnit.HectoliterPerMinute => (HectolitersPerMinuteInOneCubicMeterPerSecond, HectolitersPerMinuteTolerance), + VolumeFlowUnit.HectoliterPerSecond => (HectolitersPerSecondInOneCubicMeterPerSecond, HectolitersPerSecondTolerance), VolumeFlowUnit.KiloliterPerDay => (KilolitersPerDayInOneCubicMeterPerSecond, KilolitersPerDayTolerance), VolumeFlowUnit.KiloliterPerHour => (KilolitersPerHourInOneCubicMeterPerSecond, KilolitersPerHourTolerance), VolumeFlowUnit.KiloliterPerMinute => (KilolitersPerMinuteInOneCubicMeterPerSecond, KilolitersPerMinuteTolerance), @@ -275,10 +299,18 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase new object[] { VolumeFlowUnit.CubicYardPerHour }, new object[] { VolumeFlowUnit.CubicYardPerMinute }, new object[] { VolumeFlowUnit.CubicYardPerSecond }, + new object[] { VolumeFlowUnit.DecaliterPerDay }, + new object[] { VolumeFlowUnit.DecaliterPerHour }, + new object[] { VolumeFlowUnit.DecaliterPerMinute }, + new object[] { VolumeFlowUnit.DecaliterPerSecond }, new object[] { VolumeFlowUnit.DeciliterPerDay }, new object[] { VolumeFlowUnit.DeciliterPerHour }, new object[] { VolumeFlowUnit.DeciliterPerMinute }, new object[] { VolumeFlowUnit.DeciliterPerSecond }, + new object[] { VolumeFlowUnit.HectoliterPerDay }, + new object[] { VolumeFlowUnit.HectoliterPerHour }, + new object[] { VolumeFlowUnit.HectoliterPerMinute }, + new object[] { VolumeFlowUnit.HectoliterPerSecond }, new object[] { VolumeFlowUnit.KiloliterPerDay }, new object[] { VolumeFlowUnit.KiloliterPerHour }, new object[] { VolumeFlowUnit.KiloliterPerMinute }, @@ -330,7 +362,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VolumeFlow(double.PositiveInfinity, VolumeFlowUnit.CubicMeterPerSecond)); @@ -340,7 +372,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VolumeFlow(double.NaN, VolumeFlowUnit.CubicMeterPerSecond)); @@ -409,10 +441,18 @@ public void CubicMeterPerSecondToVolumeFlowUnits() AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerHour, CubicYardsPerHourTolerance); AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerMinute, CubicYardsPerMinuteTolerance); AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.CubicYardsPerSecond, CubicYardsPerSecondTolerance); + AssertEx.EqualTolerance(DecalitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.DecalitersPerDay, DecalitersPerDayTolerance); + AssertEx.EqualTolerance(DecalitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.DecalitersPerHour, DecalitersPerHourTolerance); + AssertEx.EqualTolerance(DecalitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.DecalitersPerMinute, DecalitersPerMinuteTolerance); + AssertEx.EqualTolerance(DecalitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.DecalitersPerSecond, DecalitersPerSecondTolerance); AssertEx.EqualTolerance(DecilitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.DecilitersPerDay, DecilitersPerDayTolerance); AssertEx.EqualTolerance(DecilitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.DecilitersPerHour, DecilitersPerHourTolerance); AssertEx.EqualTolerance(DecilitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.DecilitersPerMinute, DecilitersPerMinuteTolerance); AssertEx.EqualTolerance(DecilitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.DecilitersPerSecond, DecilitersPerSecondTolerance); + AssertEx.EqualTolerance(HectolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.HectolitersPerDay, HectolitersPerDayTolerance); + AssertEx.EqualTolerance(HectolitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.HectolitersPerHour, HectolitersPerHourTolerance); + AssertEx.EqualTolerance(HectolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.HectolitersPerMinute, HectolitersPerMinuteTolerance); + AssertEx.EqualTolerance(HectolitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.HectolitersPerSecond, HectolitersPerSecondTolerance); AssertEx.EqualTolerance(KilolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.KilolitersPerDay, KilolitersPerDayTolerance); AssertEx.EqualTolerance(KilolitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.KilolitersPerHour, KilolitersPerHourTolerance); AssertEx.EqualTolerance(KilolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.KilolitersPerMinute, KilolitersPerMinuteTolerance); @@ -547,189 +587,221 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity21.CubicYardsPerSecond, CubicYardsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, quantity21.Unit); - var quantity22 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerDay); - AssertEx.EqualTolerance(1, quantity22.DecilitersPerDay, DecilitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.DeciliterPerDay, quantity22.Unit); + var quantity22 = VolumeFlow.From(1, VolumeFlowUnit.DecaliterPerDay); + AssertEx.EqualTolerance(1, quantity22.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, quantity22.Unit); + + var quantity23 = VolumeFlow.From(1, VolumeFlowUnit.DecaliterPerHour); + AssertEx.EqualTolerance(1, quantity23.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, quantity23.Unit); + + var quantity24 = VolumeFlow.From(1, VolumeFlowUnit.DecaliterPerMinute); + AssertEx.EqualTolerance(1, quantity24.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, quantity24.Unit); + + var quantity25 = VolumeFlow.From(1, VolumeFlowUnit.DecaliterPerSecond); + AssertEx.EqualTolerance(1, quantity25.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, quantity25.Unit); + + var quantity26 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerDay); + AssertEx.EqualTolerance(1, quantity26.DecilitersPerDay, DecilitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DeciliterPerDay, quantity26.Unit); - var quantity23 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerHour); - AssertEx.EqualTolerance(1, quantity23.DecilitersPerHour, DecilitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.DeciliterPerHour, quantity23.Unit); + var quantity27 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerHour); + AssertEx.EqualTolerance(1, quantity27.DecilitersPerHour, DecilitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DeciliterPerHour, quantity27.Unit); - var quantity24 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerMinute); - AssertEx.EqualTolerance(1, quantity24.DecilitersPerMinute, DecilitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.DeciliterPerMinute, quantity24.Unit); + var quantity28 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerMinute); + AssertEx.EqualTolerance(1, quantity28.DecilitersPerMinute, DecilitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DeciliterPerMinute, quantity28.Unit); - var quantity25 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerSecond); - AssertEx.EqualTolerance(1, quantity25.DecilitersPerSecond, DecilitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, quantity25.Unit); + var quantity29 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerSecond); + AssertEx.EqualTolerance(1, quantity29.DecilitersPerSecond, DecilitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, quantity29.Unit); - var quantity26 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerDay); - AssertEx.EqualTolerance(1, quantity26.KilolitersPerDay, KilolitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.KiloliterPerDay, quantity26.Unit); + var quantity30 = VolumeFlow.From(1, VolumeFlowUnit.HectoliterPerDay); + AssertEx.EqualTolerance(1, quantity30.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, quantity30.Unit); - var quantity27 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerHour); - AssertEx.EqualTolerance(1, quantity27.KilolitersPerHour, KilolitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.KiloliterPerHour, quantity27.Unit); + var quantity31 = VolumeFlow.From(1, VolumeFlowUnit.HectoliterPerHour); + AssertEx.EqualTolerance(1, quantity31.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, quantity31.Unit); - var quantity28 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerMinute); - AssertEx.EqualTolerance(1, quantity28.KilolitersPerMinute, KilolitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.KiloliterPerMinute, quantity28.Unit); + var quantity32 = VolumeFlow.From(1, VolumeFlowUnit.HectoliterPerMinute); + AssertEx.EqualTolerance(1, quantity32.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, quantity32.Unit); - var quantity29 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerSecond); - AssertEx.EqualTolerance(1, quantity29.KilolitersPerSecond, KilolitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.KiloliterPerSecond, quantity29.Unit); + var quantity33 = VolumeFlow.From(1, VolumeFlowUnit.HectoliterPerSecond); + AssertEx.EqualTolerance(1, quantity33.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, quantity33.Unit); - var quantity30 = VolumeFlow.From(1, VolumeFlowUnit.KilousGallonPerMinute); - AssertEx.EqualTolerance(1, quantity30.KilousGallonsPerMinute, KilousGallonsPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.KilousGallonPerMinute, quantity30.Unit); + var quantity34 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerDay); + AssertEx.EqualTolerance(1, quantity34.KilolitersPerDay, KilolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.KiloliterPerDay, quantity34.Unit); - var quantity31 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerDay); - AssertEx.EqualTolerance(1, quantity31.LitersPerDay, LitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.LiterPerDay, quantity31.Unit); + var quantity35 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerHour); + AssertEx.EqualTolerance(1, quantity35.KilolitersPerHour, KilolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.KiloliterPerHour, quantity35.Unit); - var quantity32 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerHour); - AssertEx.EqualTolerance(1, quantity32.LitersPerHour, LitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.LiterPerHour, quantity32.Unit); + var quantity36 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerMinute); + AssertEx.EqualTolerance(1, quantity36.KilolitersPerMinute, KilolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.KiloliterPerMinute, quantity36.Unit); - var quantity33 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerMinute); - AssertEx.EqualTolerance(1, quantity33.LitersPerMinute, LitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.LiterPerMinute, quantity33.Unit); + var quantity37 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerSecond); + AssertEx.EqualTolerance(1, quantity37.KilolitersPerSecond, KilolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.KiloliterPerSecond, quantity37.Unit); - var quantity34 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerSecond); - AssertEx.EqualTolerance(1, quantity34.LitersPerSecond, LitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.LiterPerSecond, quantity34.Unit); + var quantity38 = VolumeFlow.From(1, VolumeFlowUnit.KilousGallonPerMinute); + AssertEx.EqualTolerance(1, quantity38.KilousGallonsPerMinute, KilousGallonsPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.KilousGallonPerMinute, quantity38.Unit); - var quantity35 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerDay); - AssertEx.EqualTolerance(1, quantity35.MegalitersPerDay, MegalitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MegaliterPerDay, quantity35.Unit); + var quantity39 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerDay); + AssertEx.EqualTolerance(1, quantity39.LitersPerDay, LitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.LiterPerDay, quantity39.Unit); - var quantity36 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerHour); - AssertEx.EqualTolerance(1, quantity36.MegalitersPerHour, MegalitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.MegaliterPerHour, quantity36.Unit); + var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerHour); + AssertEx.EqualTolerance(1, quantity40.LitersPerHour, LitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.LiterPerHour, quantity40.Unit); - var quantity37 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerMinute); - AssertEx.EqualTolerance(1, quantity37.MegalitersPerMinute, MegalitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.MegaliterPerMinute, quantity37.Unit); + var quantity41 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerMinute); + AssertEx.EqualTolerance(1, quantity41.LitersPerMinute, LitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.LiterPerMinute, quantity41.Unit); - var quantity38 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerSecond); - AssertEx.EqualTolerance(1, quantity38.MegalitersPerSecond, MegalitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.MegaliterPerSecond, quantity38.Unit); + var quantity42 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerSecond); + AssertEx.EqualTolerance(1, quantity42.LitersPerSecond, LitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.LiterPerSecond, quantity42.Unit); - var quantity39 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerDay); - AssertEx.EqualTolerance(1, quantity39.MegaukGallonsPerDay, MegaukGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MegaukGallonPerDay, quantity39.Unit); + var quantity43 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerDay); + AssertEx.EqualTolerance(1, quantity43.MegalitersPerDay, MegalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MegaliterPerDay, quantity43.Unit); - var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerSecond); - AssertEx.EqualTolerance(1, quantity40.MegaukGallonsPerSecond, MegaukGallonsPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.MegaukGallonPerSecond, quantity40.Unit); + var quantity44 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerHour); + AssertEx.EqualTolerance(1, quantity44.MegalitersPerHour, MegalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.MegaliterPerHour, quantity44.Unit); - var quantity41 = VolumeFlow.From(1, VolumeFlowUnit.MegausGallonPerDay); - AssertEx.EqualTolerance(1, quantity41.MegausGallonsPerDay, MegausGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MegausGallonPerDay, quantity41.Unit); + var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerMinute); + AssertEx.EqualTolerance(1, quantity45.MegalitersPerMinute, MegalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.MegaliterPerMinute, quantity45.Unit); - var quantity42 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerDay); - AssertEx.EqualTolerance(1, quantity42.MicrolitersPerDay, MicrolitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MicroliterPerDay, quantity42.Unit); + var quantity46 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerSecond); + AssertEx.EqualTolerance(1, quantity46.MegalitersPerSecond, MegalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.MegaliterPerSecond, quantity46.Unit); - var quantity43 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerHour); - AssertEx.EqualTolerance(1, quantity43.MicrolitersPerHour, MicrolitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.MicroliterPerHour, quantity43.Unit); + var quantity47 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerDay); + AssertEx.EqualTolerance(1, quantity47.MegaukGallonsPerDay, MegaukGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MegaukGallonPerDay, quantity47.Unit); - var quantity44 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerMinute); - AssertEx.EqualTolerance(1, quantity44.MicrolitersPerMinute, MicrolitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.MicroliterPerMinute, quantity44.Unit); + var quantity48 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerSecond); + AssertEx.EqualTolerance(1, quantity48.MegaukGallonsPerSecond, MegaukGallonsPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.MegaukGallonPerSecond, quantity48.Unit); - var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerSecond); - AssertEx.EqualTolerance(1, quantity45.MicrolitersPerSecond, MicrolitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.MicroliterPerSecond, quantity45.Unit); + var quantity49 = VolumeFlow.From(1, VolumeFlowUnit.MegausGallonPerDay); + AssertEx.EqualTolerance(1, quantity49.MegausGallonsPerDay, MegausGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MegausGallonPerDay, quantity49.Unit); - var quantity46 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerDay); - AssertEx.EqualTolerance(1, quantity46.MillilitersPerDay, MillilitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MilliliterPerDay, quantity46.Unit); + var quantity50 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerDay); + AssertEx.EqualTolerance(1, quantity50.MicrolitersPerDay, MicrolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MicroliterPerDay, quantity50.Unit); - var quantity47 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerHour); - AssertEx.EqualTolerance(1, quantity47.MillilitersPerHour, MillilitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.MilliliterPerHour, quantity47.Unit); + var quantity51 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerHour); + AssertEx.EqualTolerance(1, quantity51.MicrolitersPerHour, MicrolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.MicroliterPerHour, quantity51.Unit); - var quantity48 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerMinute); - AssertEx.EqualTolerance(1, quantity48.MillilitersPerMinute, MillilitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.MilliliterPerMinute, quantity48.Unit); + var quantity52 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerMinute); + AssertEx.EqualTolerance(1, quantity52.MicrolitersPerMinute, MicrolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.MicroliterPerMinute, quantity52.Unit); - var quantity49 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerSecond); - AssertEx.EqualTolerance(1, quantity49.MillilitersPerSecond, MillilitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, quantity49.Unit); + var quantity53 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerSecond); + AssertEx.EqualTolerance(1, quantity53.MicrolitersPerSecond, MicrolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.MicroliterPerSecond, quantity53.Unit); - var quantity50 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonPerDay); - AssertEx.EqualTolerance(1, quantity50.MillionUsGallonsPerDay, MillionUsGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MillionUsGallonPerDay, quantity50.Unit); + var quantity54 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerDay); + AssertEx.EqualTolerance(1, quantity54.MillilitersPerDay, MillilitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MilliliterPerDay, quantity54.Unit); - var quantity51 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); - AssertEx.EqualTolerance(1, quantity51.NanolitersPerDay, NanolitersPerDayTolerance); - Assert.Equal(VolumeFlowUnit.NanoliterPerDay, quantity51.Unit); + var quantity55 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerHour); + AssertEx.EqualTolerance(1, quantity55.MillilitersPerHour, MillilitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.MilliliterPerHour, quantity55.Unit); - var quantity52 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerHour); - AssertEx.EqualTolerance(1, quantity52.NanolitersPerHour, NanolitersPerHourTolerance); - Assert.Equal(VolumeFlowUnit.NanoliterPerHour, quantity52.Unit); + var quantity56 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerMinute); + AssertEx.EqualTolerance(1, quantity56.MillilitersPerMinute, MillilitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.MilliliterPerMinute, quantity56.Unit); - var quantity53 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerMinute); - AssertEx.EqualTolerance(1, quantity53.NanolitersPerMinute, NanolitersPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.NanoliterPerMinute, quantity53.Unit); + var quantity57 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerSecond); + AssertEx.EqualTolerance(1, quantity57.MillilitersPerSecond, MillilitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, quantity57.Unit); - var quantity54 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerSecond); - AssertEx.EqualTolerance(1, quantity54.NanolitersPerSecond, NanolitersPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.NanoliterPerSecond, quantity54.Unit); + var quantity58 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonPerDay); + AssertEx.EqualTolerance(1, quantity58.MillionUsGallonsPerDay, MillionUsGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MillionUsGallonPerDay, quantity58.Unit); - var quantity55 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerDay); - AssertEx.EqualTolerance(1, quantity55.OilBarrelsPerDay, OilBarrelsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.OilBarrelPerDay, quantity55.Unit); + var quantity59 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); + AssertEx.EqualTolerance(1, quantity59.NanolitersPerDay, NanolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.NanoliterPerDay, quantity59.Unit); - var quantity56 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerHour); - AssertEx.EqualTolerance(1, quantity56.OilBarrelsPerHour, OilBarrelsPerHourTolerance); - Assert.Equal(VolumeFlowUnit.OilBarrelPerHour, quantity56.Unit); + var quantity60 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerHour); + AssertEx.EqualTolerance(1, quantity60.NanolitersPerHour, NanolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.NanoliterPerHour, quantity60.Unit); - var quantity57 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerMinute); - AssertEx.EqualTolerance(1, quantity57.OilBarrelsPerMinute, OilBarrelsPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.OilBarrelPerMinute, quantity57.Unit); + var quantity61 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerMinute); + AssertEx.EqualTolerance(1, quantity61.NanolitersPerMinute, NanolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.NanoliterPerMinute, quantity61.Unit); - var quantity58 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerSecond); - AssertEx.EqualTolerance(1, quantity58.OilBarrelsPerSecond, OilBarrelsPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.OilBarrelPerSecond, quantity58.Unit); + var quantity62 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerSecond); + AssertEx.EqualTolerance(1, quantity62.NanolitersPerSecond, NanolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.NanoliterPerSecond, quantity62.Unit); - var quantity59 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerDay); - AssertEx.EqualTolerance(1, quantity59.UkGallonsPerDay, UkGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.UkGallonPerDay, quantity59.Unit); + var quantity63 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerDay); + AssertEx.EqualTolerance(1, quantity63.OilBarrelsPerDay, OilBarrelsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.OilBarrelPerDay, quantity63.Unit); - var quantity60 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerHour); - AssertEx.EqualTolerance(1, quantity60.UkGallonsPerHour, UkGallonsPerHourTolerance); - Assert.Equal(VolumeFlowUnit.UkGallonPerHour, quantity60.Unit); + var quantity64 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerHour); + AssertEx.EqualTolerance(1, quantity64.OilBarrelsPerHour, OilBarrelsPerHourTolerance); + Assert.Equal(VolumeFlowUnit.OilBarrelPerHour, quantity64.Unit); - var quantity61 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerMinute); - AssertEx.EqualTolerance(1, quantity61.UkGallonsPerMinute, UkGallonsPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.UkGallonPerMinute, quantity61.Unit); + var quantity65 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerMinute); + AssertEx.EqualTolerance(1, quantity65.OilBarrelsPerMinute, OilBarrelsPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.OilBarrelPerMinute, quantity65.Unit); - var quantity62 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerSecond); - AssertEx.EqualTolerance(1, quantity62.UkGallonsPerSecond, UkGallonsPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.UkGallonPerSecond, quantity62.Unit); + var quantity66 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerSecond); + AssertEx.EqualTolerance(1, quantity66.OilBarrelsPerSecond, OilBarrelsPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.OilBarrelPerSecond, quantity66.Unit); - var quantity63 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerDay); - AssertEx.EqualTolerance(1, quantity63.UsGallonsPerDay, UsGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.UsGallonPerDay, quantity63.Unit); + var quantity67 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerDay); + AssertEx.EqualTolerance(1, quantity67.UkGallonsPerDay, UkGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.UkGallonPerDay, quantity67.Unit); - var quantity64 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerHour); - AssertEx.EqualTolerance(1, quantity64.UsGallonsPerHour, UsGallonsPerHourTolerance); - Assert.Equal(VolumeFlowUnit.UsGallonPerHour, quantity64.Unit); + var quantity68 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerHour); + AssertEx.EqualTolerance(1, quantity68.UkGallonsPerHour, UkGallonsPerHourTolerance); + Assert.Equal(VolumeFlowUnit.UkGallonPerHour, quantity68.Unit); - var quantity65 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerMinute); - AssertEx.EqualTolerance(1, quantity65.UsGallonsPerMinute, UsGallonsPerMinuteTolerance); - Assert.Equal(VolumeFlowUnit.UsGallonPerMinute, quantity65.Unit); + var quantity69 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerMinute); + AssertEx.EqualTolerance(1, quantity69.UkGallonsPerMinute, UkGallonsPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.UkGallonPerMinute, quantity69.Unit); - var quantity66 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerSecond); - AssertEx.EqualTolerance(1, quantity66.UsGallonsPerSecond, UsGallonsPerSecondTolerance); - Assert.Equal(VolumeFlowUnit.UsGallonPerSecond, quantity66.Unit); + var quantity70 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerSecond); + AssertEx.EqualTolerance(1, quantity70.UkGallonsPerSecond, UkGallonsPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.UkGallonPerSecond, quantity70.Unit); + + var quantity71 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerDay); + AssertEx.EqualTolerance(1, quantity71.UsGallonsPerDay, UsGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.UsGallonPerDay, quantity71.Unit); + + var quantity72 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerHour); + AssertEx.EqualTolerance(1, quantity72.UsGallonsPerHour, UsGallonsPerHourTolerance); + Assert.Equal(VolumeFlowUnit.UsGallonPerHour, quantity72.Unit); + + var quantity73 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerMinute); + AssertEx.EqualTolerance(1, quantity73.UsGallonsPerMinute, UsGallonsPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.UsGallonPerMinute, quantity73.Unit); + + var quantity74 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerSecond); + AssertEx.EqualTolerance(1, quantity74.UsGallonsPerSecond, UsGallonsPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.UsGallonPerSecond, quantity74.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VolumeFlow.FromCubicMetersPerSecond(double.PositiveInfinity)); @@ -739,7 +811,7 @@ public void FromCubicMetersPerSecond_WithInfinityValue_DoNotThrowsArgumentExcept Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerSecond_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VolumeFlow.FromCubicMetersPerSecond(double.NaN)); @@ -773,10 +845,18 @@ public void As() AssertEx.EqualTolerance(CubicYardsPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerHour), CubicYardsPerHourTolerance); AssertEx.EqualTolerance(CubicYardsPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerMinute), CubicYardsPerMinuteTolerance); AssertEx.EqualTolerance(CubicYardsPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.CubicYardPerSecond), CubicYardsPerSecondTolerance); + AssertEx.EqualTolerance(DecalitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DecaliterPerDay), DecalitersPerDayTolerance); + AssertEx.EqualTolerance(DecalitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DecaliterPerHour), DecalitersPerHourTolerance); + AssertEx.EqualTolerance(DecalitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DecaliterPerMinute), DecalitersPerMinuteTolerance); + AssertEx.EqualTolerance(DecalitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DecaliterPerSecond), DecalitersPerSecondTolerance); AssertEx.EqualTolerance(DecilitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DeciliterPerDay), DecilitersPerDayTolerance); AssertEx.EqualTolerance(DecilitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DeciliterPerHour), DecilitersPerHourTolerance); AssertEx.EqualTolerance(DecilitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DeciliterPerMinute), DecilitersPerMinuteTolerance); AssertEx.EqualTolerance(DecilitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.DeciliterPerSecond), DecilitersPerSecondTolerance); + AssertEx.EqualTolerance(HectolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.HectoliterPerDay), HectolitersPerDayTolerance); + AssertEx.EqualTolerance(HectolitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.HectoliterPerHour), HectolitersPerHourTolerance); + AssertEx.EqualTolerance(HectolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.HectoliterPerMinute), HectolitersPerMinuteTolerance); + AssertEx.EqualTolerance(HectolitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.HectoliterPerSecond), HectolitersPerSecondTolerance); AssertEx.EqualTolerance(KilolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.KiloliterPerDay), KilolitersPerDayTolerance); AssertEx.EqualTolerance(KilolitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.KiloliterPerHour), KilolitersPerHourTolerance); AssertEx.EqualTolerance(KilolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.KiloliterPerMinute), KilolitersPerMinuteTolerance); @@ -1106,6 +1186,90 @@ public void Parse() Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = VolumeFlow.Parse("1 dal/day", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daL/d", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daLPD", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daL/h", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daLPH", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 дал/ч", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daL/min", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daLPM", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 дал/мин", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daL/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 daLPS", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 дал/c", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = VolumeFlow.Parse("1 dl/day", CultureInfo.GetCultureInfo("en-US")); @@ -1190,6 +1354,90 @@ public void Parse() Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = VolumeFlow.Parse("1 hl/day", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hL/d", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hLPD", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hL/h", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hLPH", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 гл/ч", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hL/min", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hLPM", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 гл/мин", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hL/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 hLPS", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = VolumeFlow.Parse("1 гл/c", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = VolumeFlow.Parse("1 kl/day", CultureInfo.GetCultureInfo("en-US")); @@ -2095,6 +2343,78 @@ public void TryParse() Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, parsed.Unit); } + { + Assert.True(VolumeFlow.TryParse("1 dal/day", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daL/d", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daLPD", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerDay, DecalitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daL/h", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daLPH", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 дал/ч", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerHour, DecalitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daL/min", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daLPM", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 дал/мин", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerMinute, DecalitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daL/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 daLPS", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 дал/c", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.DecalitersPerSecond, DecalitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsed.Unit); + } + { Assert.True(VolumeFlow.TryParse("1 dl/day", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.DecilitersPerDay, DecilitersPerDayTolerance); @@ -2167,6 +2487,78 @@ public void TryParse() Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, parsed.Unit); } + { + Assert.True(VolumeFlow.TryParse("1 hl/day", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hL/d", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hLPD", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerDay, HectolitersPerDayTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hL/h", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hLPH", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 гл/ч", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerHour, HectolitersPerHourTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hL/min", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hLPM", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 гл/мин", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerMinute, HectolitersPerMinuteTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hL/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 hLPS", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } + + { + Assert.True(VolumeFlow.TryParse("1 гл/c", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.HectolitersPerSecond, HectolitersPerSecondTolerance); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsed.Unit); + } + { Assert.True(VolumeFlow.TryParse("1 kl/day", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.KilolitersPerDay, KilolitersPerDayTolerance); @@ -2832,6 +3224,78 @@ public void ParseUnit() Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = VolumeFlow.ParseUnit("dal/day", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daL/d", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daLPD", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daL/h", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daLPH", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("дал/ч", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daL/min", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daLPM", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("дал/мин", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daL/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("daLPS", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("дал/c", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = VolumeFlow.ParseUnit("dl/day", CultureInfo.GetCultureInfo("en-US")); @@ -2904,6 +3368,78 @@ public void ParseUnit() Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = VolumeFlow.ParseUnit("hl/day", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hL/d", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hLPD", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hL/h", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hLPH", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("гл/ч", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hL/min", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hLPM", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("гл/мин", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hL/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("hLPS", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = VolumeFlow.ParseUnit("гл/c", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = VolumeFlow.ParseUnit("kl/day", CultureInfo.GetCultureInfo("en-US")); @@ -3675,6 +4211,66 @@ public void TryParseUnit() Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, parsedUnit); } + { + Assert.True(VolumeFlow.TryParseUnit("dal/day", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daL/d", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daLPD", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daL/h", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daLPH", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("дал/ч", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daL/min", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daLPM", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("дал/мин", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daL/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("daLPS", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("дал/c", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.DecaliterPerSecond, parsedUnit); + } + { Assert.True(VolumeFlow.TryParseUnit("dl/day", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(VolumeFlowUnit.DeciliterPerDay, parsedUnit); @@ -3735,6 +4331,66 @@ public void TryParseUnit() Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, parsedUnit); } + { + Assert.True(VolumeFlow.TryParseUnit("hl/day", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hL/d", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hLPD", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerDay, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hL/h", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hLPH", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("гл/ч", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerHour, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hL/min", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hLPM", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("гл/мин", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerMinute, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hL/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("hLPS", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } + + { + Assert.True(VolumeFlow.TryParseUnit("гл/c", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(VolumeFlowUnit.HectoliterPerSecond, parsedUnit); + } + { Assert.True(VolumeFlow.TryParseUnit("kl/day", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(VolumeFlowUnit.KiloliterPerDay, parsedUnit); @@ -4165,10 +4821,18 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerHour(cubicmeterpersecond.CubicYardsPerHour).CubicMetersPerSecond, CubicYardsPerHourTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerMinute(cubicmeterpersecond.CubicYardsPerMinute).CubicMetersPerSecond, CubicYardsPerMinuteTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerSecond(cubicmeterpersecond.CubicYardsPerSecond).CubicMetersPerSecond, CubicYardsPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecalitersPerDay(cubicmeterpersecond.DecalitersPerDay).CubicMetersPerSecond, DecalitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecalitersPerHour(cubicmeterpersecond.DecalitersPerHour).CubicMetersPerSecond, DecalitersPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecalitersPerMinute(cubicmeterpersecond.DecalitersPerMinute).CubicMetersPerSecond, DecalitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecalitersPerSecond(cubicmeterpersecond.DecalitersPerSecond).CubicMetersPerSecond, DecalitersPerSecondTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerDay(cubicmeterpersecond.DecilitersPerDay).CubicMetersPerSecond, DecilitersPerDayTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerHour(cubicmeterpersecond.DecilitersPerHour).CubicMetersPerSecond, DecilitersPerHourTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerMinute(cubicmeterpersecond.DecilitersPerMinute).CubicMetersPerSecond, DecilitersPerMinuteTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerSecond(cubicmeterpersecond.DecilitersPerSecond).CubicMetersPerSecond, DecilitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromHectolitersPerDay(cubicmeterpersecond.HectolitersPerDay).CubicMetersPerSecond, HectolitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromHectolitersPerHour(cubicmeterpersecond.HectolitersPerHour).CubicMetersPerSecond, HectolitersPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromHectolitersPerMinute(cubicmeterpersecond.HectolitersPerMinute).CubicMetersPerSecond, HectolitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromHectolitersPerSecond(cubicmeterpersecond.HectolitersPerSecond).CubicMetersPerSecond, HectolitersPerSecondTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerDay(cubicmeterpersecond.KilolitersPerDay).CubicMetersPerSecond, KilolitersPerDayTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerHour(cubicmeterpersecond.KilolitersPerHour).CubicMetersPerSecond, KilolitersPerHourTolerance); AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerMinute(cubicmeterpersecond.KilolitersPerMinute).CubicMetersPerSecond, KilolitersPerMinuteTolerance); @@ -4268,8 +4932,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumeFlowUnit.CubicMeterPerSecond, 1, VolumeFlowUnit.CubicMeterPerSecond, true)] // Same value and unit. [InlineData(1, VolumeFlowUnit.CubicMeterPerSecond, 2, VolumeFlowUnit.CubicMeterPerSecond, false)] // Different value. - [InlineData(2, VolumeFlowUnit.CubicMeterPerSecond, 1, VolumeFlowUnit.AcreFootPerDay, false)] // Different value and unit. - [InlineData(1, VolumeFlowUnit.CubicMeterPerSecond, 1, VolumeFlowUnit.AcreFootPerDay, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumeFlowUnit unitA, double valueB, VolumeFlowUnit unitB, bool expectEqual) { var a = new VolumeFlow(valueA, unitA); @@ -4379,10 +5041,18 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 yd³/h", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerHour).ToString()); Assert.Equal("1 yd³/min", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerMinute).ToString()); Assert.Equal("1 yd³/s", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerSecond).ToString()); + Assert.Equal("1 dal/day", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerDay).ToString()); + Assert.Equal("1 daL/h", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerHour).ToString()); + Assert.Equal("1 daL/min", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerMinute).ToString()); + Assert.Equal("1 daL/s", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerSecond).ToString()); Assert.Equal("1 dl/day", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerDay).ToString()); Assert.Equal("1 dL/h", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerHour).ToString()); Assert.Equal("1 dL/min", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerMinute).ToString()); Assert.Equal("1 dL/s", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerSecond).ToString()); + Assert.Equal("1 hl/day", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerDay).ToString()); + Assert.Equal("1 hL/h", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerHour).ToString()); + Assert.Equal("1 hL/min", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerMinute).ToString()); + Assert.Equal("1 hL/s", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerSecond).ToString()); Assert.Equal("1 kl/day", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerDay).ToString()); Assert.Equal("1 kL/h", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerHour).ToString()); Assert.Equal("1 kL/min", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerMinute).ToString()); @@ -4459,10 +5129,18 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 yd³/h", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerHour).ToString(swedishCulture)); Assert.Equal("1 yd³/min", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerMinute).ToString(swedishCulture)); Assert.Equal("1 yd³/s", new VolumeFlow(1, VolumeFlowUnit.CubicYardPerSecond).ToString(swedishCulture)); + Assert.Equal("1 dal/day", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerDay).ToString(swedishCulture)); + Assert.Equal("1 daL/h", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerHour).ToString(swedishCulture)); + Assert.Equal("1 daL/min", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerMinute).ToString(swedishCulture)); + Assert.Equal("1 daL/s", new VolumeFlow(1, VolumeFlowUnit.DecaliterPerSecond).ToString(swedishCulture)); Assert.Equal("1 dl/day", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerDay).ToString(swedishCulture)); Assert.Equal("1 dL/h", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerHour).ToString(swedishCulture)); Assert.Equal("1 dL/min", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerMinute).ToString(swedishCulture)); Assert.Equal("1 dL/s", new VolumeFlow(1, VolumeFlowUnit.DeciliterPerSecond).ToString(swedishCulture)); + Assert.Equal("1 hl/day", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerDay).ToString(swedishCulture)); + Assert.Equal("1 hL/h", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerHour).ToString(swedishCulture)); + Assert.Equal("1 hL/min", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerMinute).ToString(swedishCulture)); + Assert.Equal("1 hL/s", new VolumeFlow(1, VolumeFlowUnit.HectoliterPerSecond).ToString(swedishCulture)); Assert.Equal("1 kl/day", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerDay).ToString(swedishCulture)); Assert.Equal("1 kL/h", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerHour).ToString(swedishCulture)); Assert.Equal("1 kL/min", new VolumeFlow(1, VolumeFlowUnit.KiloliterPerMinute).ToString(swedishCulture)); @@ -4700,7 +5378,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(new {VolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VolumeFlow.Info.Name, quantity.CubicMetersPerSecond); + #else + var expected = new {VolumeFlow.Info.Name, valueInBaseUnit = quantity.CubicMetersPerSecond}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 2277fcc6e5..87d799df87 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VolumePerLength(double.PositiveInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VolumePerLength(double.NaN, VolumePerLengthUnit.CubicMeterPerMeter)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerMeter_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromCubicMetersPerMeter_WithInfinityValue_DoNotThrowsArgumentExcepti Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMetersPerMeter_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN)); @@ -606,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumePerLengthUnit.CubicMeterPerMeter, 1, VolumePerLengthUnit.CubicMeterPerMeter, true)] // Same value and unit. [InlineData(1, VolumePerLengthUnit.CubicMeterPerMeter, 2, VolumePerLengthUnit.CubicMeterPerMeter, false)] // Different value. - [InlineData(2, VolumePerLengthUnit.CubicMeterPerMeter, 1, VolumePerLengthUnit.CubicYardPerFoot, false)] // Different value and unit. - [InlineData(1, VolumePerLengthUnit.CubicMeterPerMeter, 1, VolumePerLengthUnit.CubicYardPerFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumePerLengthUnit unitA, double valueB, VolumePerLengthUnit unitB, bool expectEqual) { var a = new VolumePerLength(valueA, unitA); @@ -922,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(new {VolumePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VolumePerLength.Info.Name, quantity.CubicMetersPerMeter); + #else + var expected = new {VolumePerLength.Info.Name, valueInBaseUnit = quantity.CubicMetersPerMeter}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index bd4e998ef2..c633ceae53 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -278,7 +278,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeUnit.CubicMeter, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new Volume(double.PositiveInfinity, VolumeUnit.CubicMeter)); @@ -288,7 +288,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new Volume(double.NaN, VolumeUnit.CubicMeter)); @@ -612,7 +612,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMeters_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => Volume.FromCubicMeters(double.PositiveInfinity)); @@ -622,7 +622,7 @@ public void FromCubicMeters_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromCubicMeters_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => Volume.FromCubicMeters(double.NaN)); @@ -3201,8 +3201,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumeUnit.CubicMeter, 1, VolumeUnit.CubicMeter, true)] // Same value and unit. [InlineData(1, VolumeUnit.CubicMeter, 2, VolumeUnit.CubicMeter, false)] // Different value. - [InlineData(2, VolumeUnit.CubicMeter, 1, VolumeUnit.AcreFoot, false)] // Different value and unit. - [InlineData(1, VolumeUnit.CubicMeter, 1, VolumeUnit.AcreFoot, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumeUnit unitA, double valueB, VolumeUnit unitB, bool expectEqual) { var a = new Volume(valueA, unitA); @@ -3607,7 +3605,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(new {Volume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(Volume.Info.Name, quantity.CubicMeters); + #else + var expected = new {Volume.Info.Name, valueInBaseUnit = quantity.CubicMeters}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index a19d57356b..76b2be4dc1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -98,7 +98,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new VolumetricHeatCapacity(double.PositiveInfinity, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin)); @@ -108,7 +108,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new VolumetricHeatCapacity(double.NaN, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin)); @@ -207,7 +207,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerCubicMeterKelvin_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(double.PositiveInfinity)); @@ -217,7 +217,7 @@ public void FromJoulesPerCubicMeterKelvin_WithInfinityValue_DoNotThrowsArgumentE Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromJoulesPerCubicMeterKelvin_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(double.NaN)); @@ -606,8 +606,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, 1, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, true)] // Same value and unit. [InlineData(1, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, 2, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, false)] // Different value. - [InlineData(2, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, 1, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, false)] // Different value and unit. - [InlineData(1, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, 1, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, VolumetricHeatCapacityUnit unitA, double valueB, VolumetricHeatCapacityUnit unitB, bool expectEqual) { var a = new VolumetricHeatCapacity(valueA, unitA); @@ -922,7 +920,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(new {VolumetricHeatCapacity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(VolumetricHeatCapacity.Info.Name, quantity.JoulesPerCubicMeterKelvin); + #else + var expected = new {VolumetricHeatCapacity.Info.Name, valueInBaseUnit = quantity.JoulesPerCubicMeterKelvin}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 891a03e312..c5f10d9c67 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -86,7 +86,7 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity.Unit); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => new WarpingMomentOfInertia(double.PositiveInfinity, WarpingMomentOfInertiaUnit.MeterToTheSixth)); @@ -96,7 +96,7 @@ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void Ctor_WithNaNValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => new WarpingMomentOfInertia(double.NaN, WarpingMomentOfInertiaUnit.MeterToTheSixth)); @@ -180,7 +180,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersToTheSixth_WithInfinityValue_DoNotThrowsArgumentException() { var exception1 = Record.Exception(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.PositiveInfinity)); @@ -190,7 +190,7 @@ public void FromMetersToTheSixth_WithInfinityValue_DoNotThrowsArgumentException( Assert.Null(exception2); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void FromMetersToTheSixth_WithNanValue_DoNotThrowsArgumentException() { var exception = Record.Exception(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NaN)); @@ -645,8 +645,6 @@ public void CompareToThrowsOnNull() [Theory] [InlineData(1, WarpingMomentOfInertiaUnit.MeterToTheSixth, 1, WarpingMomentOfInertiaUnit.MeterToTheSixth, true)] // Same value and unit. [InlineData(1, WarpingMomentOfInertiaUnit.MeterToTheSixth, 2, WarpingMomentOfInertiaUnit.MeterToTheSixth, false)] // Different value. - [InlineData(2, WarpingMomentOfInertiaUnit.MeterToTheSixth, 1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, false)] // Different value and unit. - [InlineData(1, WarpingMomentOfInertiaUnit.MeterToTheSixth, 1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, WarpingMomentOfInertiaUnit unitA, double valueB, WarpingMomentOfInertiaUnit unitB, bool expectEqual) { var a = new WarpingMomentOfInertia(valueA, unitA); @@ -955,7 +953,12 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(new {WarpingMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + #if NET7_0_OR_GREATER + var expected = HashCode.Combine(WarpingMomentOfInertia.Info.Name, quantity.MetersToTheSixth); + #else + var expected = new {WarpingMomentOfInertia.Info.Name, valueInBaseUnit = quantity.MetersToTheSixth}.GetHashCode(); + #endif + Assert.Equal(expected, quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs index 02da53de1f..0d8e9d803d 100644 --- a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs +++ b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs @@ -26,9 +26,15 @@ public void LengthEquals_GivenMaxError_ReturnsTrueIfWithinError() 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), - "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), 0, ComparisonType.Relative), + "Example of floating precision arithmetic that would originally produces slightly different results is now correct:" + + "this is due to the implicit rounding (16 significant digits) that is applied when constructing from double."); + + Assert.True(Length.FromMeters((1 + 0.39) / double.MaxValue).Equals(Length.FromMeters(1.39 / double.MaxValue), 0, ComparisonType.Relative), + "This is also true for very small values as they would be rounded the same way."); + + Assert.False((1.39 / double.MaxValue).Equals(Length.FromMeters(1.39 / double.MaxValue).Value.ToDouble()), + "The opposite conversion is not guaranteed to round-trip"); } [Fact] diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 3e9ca33dbe..2e02f36b43 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -16,7 +16,7 @@ public class QuantityTest // Exclude Undefined value private static readonly int QuantityCount = Quantity.ByName.Count; - [Theory] + [Theory(Skip = "https://github.com/danm-de/Fractions/issues/26")] [InlineData(double.NaN)] [InlineData(double.PositiveInfinity)] [InlineData(double.NegativeInfinity)] @@ -27,7 +27,7 @@ public void From_GivenNaNOrInfinity_DoNotThrowsArgumentException(double value) Assert.Null(exception); } - [Theory] + [Theory(Skip = "https://github.com/danm-de/Fractions/issues/26")] [InlineData(double.NaN)] [InlineData(double.PositiveInfinity)] [InlineData(double.NegativeInfinity)] diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index 555153121c..d0ba4c9774 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -218,7 +218,7 @@ public void TryFromUnitAbbreviation_AmbiguousAbbreviation_ReturnsFalse() Assert.Null(q); } - [Fact] + [Fact(Skip = "https://github.com/danm-de/Fractions/issues/26")] public void AllowSpecialValue() { try @@ -227,7 +227,7 @@ public void AllowSpecialValue() } catch (ArgumentException) { - Assert.True(false, "Special double values (NaN, -Inf, +Inf) must be allowed."); + Assert.Fail("Special double values (NaN, -Inf, +Inf) must be allowed."); } } diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index fe7ae8c10c..1c98682f66 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -167,7 +167,7 @@ public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnit(doubl [InlineData(1, "Length", "Meter", "UnknownToUnit")] public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); + Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out QuantityValue result)); Assert.Equal(0, result); } @@ -179,7 +179,7 @@ public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, stri public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByName() return value."); + Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out QuantityValue result), "TryConvertByName() return value."); Assert.Equal(expectedValue, result); } @@ -214,7 +214,7 @@ public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUn [InlineData(1, "Length", "m", "UnknownToUnit", "en-US")] public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit, string culture) { - Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result, culture)); + Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out QuantityValue result, culture)); Assert.Equal(0, result); } @@ -225,7 +225,7 @@ public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputVal [InlineData(1000, 1, "ElectricCurrent", "kA", "A", "en-US")] public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit, string culture) { - Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result, culture), "TryConvertByAbbreviation() return value."); + Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out QuantityValue result, culture), "TryConvertByAbbreviation() return value."); Assert.Equal(expectedValue, result); } } diff --git a/UnitsNet.Tests/UnitMathTests.cs b/UnitsNet.Tests/UnitMathTests.cs index fbb4f1d16e..1972e6fdc5 100644 --- a/UnitsNet.Tests/UnitMathTests.cs +++ b/UnitsNet.Tests/UnitMathTests.cs @@ -45,14 +45,6 @@ public void AbsoluteValueOfNullReferenceThrowsException() Assert.Throws(() => quantity.Abs()); } - [Fact] - public void AverageOfDifferentUnitsThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - - Assert.Throws(() => units.Average(LengthUnit.Centimeter)); - } - [Fact] public void AverageOfEmptySourceThrowsException() { @@ -61,14 +53,6 @@ public void AverageOfEmptySourceThrowsException() Assert.Throws(() => units.Average(LengthUnit.Centimeter)); } - [Fact] - public void AverageOfLengthsWithNullValueThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), null!}; - - Assert.Throws(() => units.Average(LengthUnit.Centimeter)); - } - [Fact] public void AverageOfLengthsCalculatesCorrectly() { @@ -119,22 +103,6 @@ public void MaxOfTwoLengthsReturnsTheLargestValue() Assert.Equal(LengthUnit.Meter, max.Unit); } - [Fact] - public void MaxOfDifferentUnitsThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - - Assert.Throws(() => units.Max(LengthUnit.Centimeter)); - } - - [Fact] - public void MaxOfLengthsWithNullValueThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), null!}; - - Assert.Throws(() => units.Max(LengthUnit.Centimeter)); - } - [Fact] public void MaxOfEmptySourceThrowsException() { @@ -193,22 +161,6 @@ public void MinOfTwoLengthsReturnsTheSmallestValue() Assert.Equal(LengthUnit.Centimeter, min.Unit); } - [Fact] - public void MinOfDifferentUnitsThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - - Assert.Throws(() => units.Min(LengthUnit.Centimeter)); - } - - [Fact] - public void MinOfLengthsWithNullValueThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), null!}; - - Assert.Throws(() => units.Min(LengthUnit.Centimeter)); - } - [Fact] public void MinOfEmptySourceThrowsException() { @@ -255,22 +207,6 @@ public void MinOfLengthsWithSelectorCalculatesCorrectly() Assert.Equal(LengthUnit.Centimeter, min.Unit); } - [Fact] - public void SumOfDifferentUnitsThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - - Assert.Throws(() => units.Sum(LengthUnit.Centimeter)); - } - - [Fact] - public void SumOfLengthsWithNullValueThrowsException() - { - var units = new IQuantity[] {Length.FromMeters(1), null!}; - - Assert.Throws(() => units.Sum(LengthUnit.Centimeter)); - } - [Fact] public void SumOfEmptySourceReturnsZero() { diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 9fbd0a02f3..fe4c5610ba 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net48 + net8.0 latest true CS0618 @@ -24,10 +24,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 83b85777cf..31f1abed00 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -11,27 +11,38 @@ public partial struct AmountOfSubstance { /// /// The Avogadro constant is the number of constituent particles, usually molecules, - /// atoms or ions that are contained in the amount of substance given by one mole. It is the proportionality factor that relates + /// atoms or ions that are contained in the amount of substance given by one mole. It is the proportionality factor + /// that relates /// the molar mass of a substance to the mass of a sample, is designated with the symbol NA or L[1], and has the value /// 6.02214076e23 mol−1 in the International System of Units (SI). /// /// - /// Pending revisions in the base set of SI units necessitated redefinitions of the concepts of chemical quantity. The Avogadro number, - /// and its definition, was deprecated in favor of the Avogadro constant and its definition. Based on measurements made through the - /// middle of 2017 which calculated a value for the Avogadro constant of NA = 6.022140758(62)×1023 mol−1, the redefinition of SI units - /// is planned to take effect on 20 May 2019. The value of the constant will be fixed to exactly 6.02214076×1023 mol−1. - /// See here: https://www.bipm.org/utils/common/pdf/CGPM-2018/26th-CGPM-Resolutions.pdf + /// The Avogadro constant NA is related to other physical constants and properties. + /// + /// It relates the molar gas constant R and the Boltzmann constant kB, which in the SI is defined to be exactly + /// 1.380649×10−23 J/K:[9] + /// + /// R = kB NA = 8.314462618... J⋅mol−1⋅K−1 + /// + /// It relates the Faraday constant F and the elementary charge e, which in the SI is defined as exactly + /// 1.602176634×10−19 coulombs:[9] + /// + /// F = e NA = 9.648533212...×104 C⋅mol−1 + /// + /// It relates the molar mass constant Mu and the atomic mass constant mu currently 1.66053906660(50)×10−27 + /// kg:[25] + /// + /// Mu = mu NA = 0.99999999965(30)×10−3 kg⋅mol−1 /// - public static double AvogadroConstant { get; } = 6.02214076e23; + public static QuantityValue AvogadroConstant { get; } = 6.02214076e23m; /// /// Calculates the number of particles (atoms or molecules) in this amount of substance using the . /// /// The number of particles (atoms or molecules) in this amount of substance. - public double NumberOfParticles() + public QuantityValue NumberOfParticles() { - var moles = ToUnit(AmountOfSubstanceUnit.Mole); - return AvogadroConstant * moles.Value; + return AvogadroConstant * As(AmountOfSubstanceUnit.Mole); } /// Get from and a given . diff --git a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs index cc0a3cfcdf..2c8598b266 100644 --- a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs @@ -24,7 +24,7 @@ public AmplitudeRatio(ElectricPotential voltage) "The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V."); // E(dBV) = 20*log10(value(V)/reference(V)) - _value = 20 * Math.Log10(voltage.Volts / 1); + _value = QuantityValue.FromDoubleRounded(20 * Math.Log10(voltage.Volts.ToDouble() / 1)); _unit = AmplitudeRatioUnit.DecibelVolt; } @@ -40,7 +40,7 @@ public AmplitudeRatio(ElectricPotential voltage) public ElectricPotential ToElectricPotential() { // E(V) = 1V * 10^(E(dBV)/20) - return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); + return ElectricPotential.FromVolts(QuantityValue.FromDoubleRounded(Math.Pow(10, DecibelVolts.ToDouble() / 20))); } /// @@ -51,7 +51,7 @@ public ElectricPotential ToElectricPotential() public PowerRatio ToPowerRatio( ElectricResistance impedance ) { // P(dBW) = E(dBV) - 10*log10(Z(Ω)/1) - return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); + return PowerRatio.FromDecibelWatts(DecibelVolts - QuantityValue.FromDoubleRounded(10 * Math.Log10(impedance.Ohms.ToDouble() / 1))); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/Area.extra.cs b/UnitsNet/CustomCode/Quantities/Area.extra.cs index 3a9d28e973..08d3b7e3a0 100644 --- a/UnitsNet/CustomCode/Quantities/Area.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Area.extra.cs @@ -12,14 +12,14 @@ public partial struct Area /// Get circle area from a diameter. public static Area FromCircleDiameter(Length diameter) { - var radius = Length.FromMeters(diameter.Meters / 2d); + var radius = Length.FromMeters(diameter.Meters / 2); return FromCircleRadius(radius); } /// Get circle area from a radius. public static Area FromCircleRadius(Length radius) { - return FromSquareMeters(Math.PI * radius.Meters * radius.Meters); + return FromSquareMeters(UnitMath.PI * radius.Meters * radius.Meters); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index b72b51285a..2e4dcca07a 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using UnitsNet.Units; namespace UnitsNet { @@ -18,11 +17,17 @@ public partial struct Duration /// The TimeSpan with the same time as the duration public TimeSpan ToTimeSpan() { - if (Seconds > TimeSpan.MaxValue.TotalSeconds) throw new ArgumentOutOfRangeException(nameof(Seconds), + if (Seconds > TimeSpan.MaxValue.TotalSeconds) + { + throw new ArgumentOutOfRangeException(nameof(Seconds), "The duration is too large for a TimeSpan, which would roll over from positive to negative."); + } - if (Seconds < TimeSpan.MinValue.TotalSeconds) throw new ArgumentOutOfRangeException(nameof(Seconds), + if (Seconds < TimeSpan.MinValue.TotalSeconds) + { + throw new ArgumentOutOfRangeException(nameof(Seconds), "The duration is too small for a TimeSpan, which would roll over from negative to positive."); + } return TimeSpan.FromTicks((long)(Seconds * TimeSpan.TicksPerSecond)); } @@ -30,13 +35,13 @@ public TimeSpan ToTimeSpan() /// Get from plus . public static DateTime operator +(DateTime time, Duration duration) { - return time.AddSeconds(duration.Seconds); + return time.AddSeconds(duration.Seconds.ToDouble()); } /// Get from minus . public static DateTime operator -(DateTime time, Duration duration) { - return time.AddSeconds(-duration.Seconds); + return time.AddSeconds(-duration.Seconds.ToDouble()); } /// Implicitly cast to . @@ -48,7 +53,7 @@ public static implicit operator TimeSpan(Duration duration) /// Implicitly cast to . public static implicit operator Duration(TimeSpan duration) { - return FromSeconds(duration.TotalSeconds); + return FromSeconds(QuantityValue.FromDoubleRounded(duration.TotalSeconds)); } /// True if is less than . diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index d729d18b18..1683ce5dc2 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -10,7 +10,7 @@ public partial struct Force /// Get from divided by . public static Force FromPressureByArea(Pressure p, Area area) { - double newtons = p.Pascals * area.SquareMeters; + QuantityValue newtons = p.Pascals * area.SquareMeters; return new Force(newtons, ForceUnit.Newton); } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index 3d251b249f..4e88d56aca 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Text.RegularExpressions; using System.Threading; using UnitsNet.Units; @@ -11,7 +12,7 @@ namespace UnitsNet { public partial struct Length { - private const double InchesInOneFoot = 12; + private static readonly QuantityValue InchesInOneFoot = 12; /// /// Converts the length to a customary feet/inches combination. @@ -20,18 +21,15 @@ public FeetInches FeetInches { get { - var inInches = Inches; - var feet = Math.Truncate(inInches / InchesInOneFoot); - var inches = inInches % InchesInOneFoot; - - return new FeetInches(feet, inches); + QuantityValue totalInches = Inches; + return new FeetInches((BigInteger) (totalInches / InchesInOneFoot), totalInches % InchesInOneFoot); } } /// /// Get length from combination of feet and inches. /// - public static Length FromFeetInches(double feet, double inches) + public static Length FromFeetInches(QuantityValue feet, QuantityValue inches) { return FromInches(InchesInOneFoot*feet + inches); } @@ -122,7 +120,7 @@ public sealed class FeetInches /// /// Construct from feet and inches. /// - public FeetInches(double feet, double inches) + public FeetInches(BigInteger feet, QuantityValue inches) { Feet = feet; Inches = inches; @@ -131,12 +129,12 @@ public FeetInches(double feet, double inches) /// /// The feet value it was constructed with. /// - public double Feet { get; } + public BigInteger Feet { get; } /// /// The inches value it was constructed with. /// - public double Inches { get; } + public QuantityValue Inches { get; } /// public override string ToString() @@ -161,7 +159,7 @@ public string ToString(IFormatProvider? cultureInfo) // Note that it isn't customary to use fractions - one wouldn't say "I am 5 feet and 4.5 inches". // So inches are rounded when converting from base units to feet/inches. - return string.Format(cultureInfo, "{0:n0} {1} {2:n0} {3}", Feet, footUnit, Math.Round(Inches), inchUnit); + return string.Format(cultureInfo, "{0:n0} {1} {2:n0} {3}", Feet, footUnit, Math.Round(Inches.ToDouble()), inchUnit); } /// @@ -189,9 +187,10 @@ public string ToArchitecturalString(int fractionDenominator) { throw new ArgumentOutOfRangeException(nameof(fractionDenominator), "Denominator for fractional inch must be greater than zero."); } - - var inchTrunc = (int)Math.Truncate(Inches); - var numerator = (int)Math.Round((Inches - inchTrunc) * fractionDenominator); + + // TODO this could probably be done better with the fractions + var inchTrunc = (int)Math.Truncate(Inches.ToDouble()); + var numerator = (int)Math.Round((Inches - inchTrunc).ToDouble() * fractionDenominator); if (numerator == fractionDenominator) { diff --git a/UnitsNet/CustomCode/Quantities/Level.extra.cs b/UnitsNet/CustomCode/Quantities/Level.extra.cs index a7b1a82825..b2bce65378 100644 --- a/UnitsNet/CustomCode/Quantities/Level.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Level.extra.cs @@ -27,7 +27,7 @@ public Level(double quantity, double reference) throw new ArgumentOutOfRangeException(nameof(reference), errorMessage); // ReSharper restore CompareOfFloatsByEqualityOperator - _value = 10*Math.Log10(quantity/reference); + _value = QuantityValue.FromDoubleRounded(10*Math.Log10(quantity/reference)); _unit = LevelUnit.Decibel; } } diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index 906feca314..f93ccf3043 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -4,6 +4,7 @@ using System; using System.Threading; using System.Globalization; +using System.Numerics; using UnitsNet.Units; namespace UnitsNet @@ -20,7 +21,7 @@ public static Mass FromGravitationalForce(Force f) /// StonePounds related code makes it easier to work with Stone/Pound combination, which are customarily used in the UK /// to express body weight. For example, someone weighs 11 stone 4 pounds (about 72 kilograms). /// - private const double StonesInOnePound = 14.0; + private static readonly QuantityValue StonesInOnePound = 14; /// /// Converts the mass to a customary stone/pounds combination. @@ -29,10 +30,10 @@ public StonePounds StonePounds { get { - var inPounds = Pounds; + QuantityValue inPounds = Pounds; - var stones = Math.Truncate(inPounds / StonesInOnePound); - var pounds = inPounds % StonesInOnePound; + var stones = (BigInteger)(inPounds / StonesInOnePound); // BigInteger division returns the quotient (equivalent to Math.Truncate) + QuantityValue pounds = inPounds % StonesInOnePound; return new StonePounds(stones, pounds); } @@ -41,7 +42,7 @@ public StonePounds StonePounds /// /// Get Mass from combination of stone and pounds. /// - public static Mass FromStonePounds(double stone, double pounds) + public static Mass FromStonePounds(QuantityValue stone, QuantityValue pounds) { return FromPounds(StonesInOnePound*stone + pounds); } @@ -56,7 +57,7 @@ public sealed class StonePounds /// /// Construct from stone and pounds. /// - public StonePounds(double stone, double pounds) + public StonePounds(QuantityValue stone, QuantityValue pounds) { Stone = stone; Pounds = pounds; @@ -65,12 +66,12 @@ public StonePounds(double stone, double pounds) /// /// The stone value it was created with. /// - public double Stone { get; } + public QuantityValue Stone { get; } /// /// The pounds value it was created with. /// - public double Pounds { get; } + public QuantityValue Pounds { get; } /// public override string ToString() @@ -95,7 +96,7 @@ public string ToString(IFormatProvider? cultureInfo) // Note that it isn't customary to use fractions - one wouldn't say "I am 11 stone and 4.5 pounds". // So pounds are rounded here. - return string.Format(cultureInfo, "{0:n0} {1} {2:n0} {3}", Stone, stoneUnit, Math.Round(Pounds), poundUnit); + return string.Format(cultureInfo, "{0:n0} {1} {2:n0} {3}", Stone, stoneUnit, Math.Round(Pounds.ToDouble()), poundUnit); } } } diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index e4c4f07fe6..96eed1db32 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -21,7 +21,7 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10((double)power.Watts); + _value = QuantityValue.FromDoubleRounded(10 * Math.Log10(power.Watts.ToDouble())); _unit = PowerRatioUnit.DecibelWatt; } @@ -37,7 +37,7 @@ public PowerRatio(Power power) public Power ToPower() { // P(W) = 1W * 10^(P(dBW)/10) - return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); + return Power.FromWatts(QuantityValue.FromDoubleRounded(Math.Pow(10, DecibelWatts.ToDouble() / 10))); } /// @@ -47,7 +47,7 @@ public Power ToPower() public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance) { // E(dBV) = 10*log10(Z(Ω)/1) + P(dBW) - return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); + return AmplitudeRatio.FromDecibelVolts(QuantityValue.FromDoubleRounded(10 * Math.Log10(impedance.Ohms.ToDouble() / 1)) + DecibelWatts); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index 4556009fc6..cced823c7b 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -58,9 +58,9 @@ public partial struct Temperature /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . - public Temperature Multiply(double factor, TemperatureUnit unit) + public Temperature Multiply(QuantityValue factor, TemperatureUnit unit) { - double resultInUnit = As(unit) * factor; + QuantityValue resultInUnit = As(unit) * factor; return From(resultInUnit, unit); } @@ -75,9 +75,9 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// Factor to multiply by. /// Unit to perform multiplication in. /// The resulting . - public Temperature Divide(double divisor, TemperatureUnit unit) + public Temperature Divide(QuantityValue divisor, TemperatureUnit unit) { - double resultInUnit = As(unit) / divisor; + QuantityValue resultInUnit = As(unit) / divisor; return From(resultInUnit, unit); } } diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index 8d59082bcf..1a38190ae6 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -46,7 +46,7 @@ public static bool TryGetUnitInfo(Enum unitEnum, [NotNullWhen(true)] out UnitInf /// Unit enum value. /// An object. /// Unit value is not a known unit enum type. - public static IQuantity From(double value, Enum unit) + public static IQuantity From(QuantityValue value, Enum unit) { return TryFrom(value, unit, out IQuantity? quantity) ? quantity @@ -61,7 +61,7 @@ public static IQuantity From(double value, Enum unit) /// The invariant unit enum name, such as "Meter". Does not support localization. /// An object. /// Unit value is not a known unit enum type. - public static IQuantity From(double value, string quantityName, string unitName) + public static IQuantity From(QuantityValue value, string quantityName, string unitName) { // Get enum value for this unit, f.ex. LengthUnit.Meter for unit name "Meter". return UnitConverter.TryParseUnit(quantityName, unitName, out Enum? unitValue) && @@ -78,14 +78,14 @@ public static IQuantity From(double value, string quantityName, string unitName) /// Unit abbreviation matching is case-insensitive.
///
/// This will fail if more than one unit across all quantities share the same unit abbreviation.
- /// Prefer or instead. + /// Prefer or instead. /// /// Numeric value. /// Unit abbreviation, such as "kg" for . /// An object. /// Unit abbreviation is not known. /// Multiple units found matching the given unit abbreviation. - public static IQuantity FromUnitAbbreviation(double value, string unitAbbreviation) => FromUnitAbbreviation(null, value, unitAbbreviation); + public static IQuantity FromUnitAbbreviation(QuantityValue value, string unitAbbreviation) => FromUnitAbbreviation(null, value, unitAbbreviation); /// /// Dynamically construct a quantity from a numeric value and a unit abbreviation. @@ -95,7 +95,7 @@ public static IQuantity From(double value, string quantityName, string unitName) /// Unit abbreviation matching is case-insensitive.
///
/// This will fail if more than one unit across all quantities share the same unit abbreviation.
- /// Prefer or instead. + /// Prefer or instead. /// /// The format provider to use for lookup. Defaults to if null. /// Numeric value. @@ -103,7 +103,7 @@ public static IQuantity From(double value, string quantityName, string unitName) /// An object. /// Unit abbreviation is not known. /// Multiple units found matching the given unit abbreviation. - public static IQuantity FromUnitAbbreviation(IFormatProvider? formatProvider, double value, string unitAbbreviation) + public static IQuantity FromUnitAbbreviation(IFormatProvider? formatProvider, QuantityValue value, string unitAbbreviation) { // TODO Optimize this with UnitValueAbbreviationLookup via UnitAbbreviationsCache.TryGetUnitValueAbbreviationLookup. List units = GetUnitsForAbbreviation(formatProvider, unitAbbreviation); @@ -129,7 +129,7 @@ public static IQuantity FromUnitAbbreviation(IFormatProvider? formatProvider, do /// The invariant quantity name, such as "Length". Does not support localization. /// The constructed quantity, if successful, otherwise null. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(double value, string quantityName, string unitName, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryFrom(QuantityValue value, string quantityName, string unitName, [NotNullWhen(true)] out IQuantity? quantity) { quantity = default; @@ -145,14 +145,14 @@ public static bool TryFrom(double value, string quantityName, string unitName, [ /// Unit abbreviation matching is case-insensitive.
///
/// This will fail if more than one unit across all quantities share the same unit abbreviation.
- /// Prefer or instead. + /// Prefer or instead. /// /// Numeric value. /// Unit abbreviation, such as "kg" for . /// The quantity if successful, otherwise null. /// True if successful. /// Unit value is not a known unit enum type. - public static bool TryFromUnitAbbreviation(double value, string unitAbbreviation, [NotNullWhen(true)] out IQuantity? quantity) => + public static bool TryFromUnitAbbreviation(QuantityValue value, string unitAbbreviation, [NotNullWhen(true)] out IQuantity? quantity) => TryFromUnitAbbreviation(null, value, unitAbbreviation, out quantity); /// @@ -163,7 +163,7 @@ public static bool TryFromUnitAbbreviation(double value, string unitAbbreviation /// Unit abbreviation matching is case-insensitive.
///
/// This will fail if more than one unit across all quantities share the same unit abbreviation.
- /// Prefer or instead. + /// Prefer or instead. /// /// The format provider to use for lookup. Defaults to if null. /// Numeric value. @@ -171,7 +171,7 @@ public static bool TryFromUnitAbbreviation(double value, string unitAbbreviation /// The quantity if successful, otherwise null. /// True if successful. /// Unit value is not a known unit enum type. - public static bool TryFromUnitAbbreviation(IFormatProvider? formatProvider, double value, string unitAbbreviation, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryFromUnitAbbreviation(IFormatProvider? formatProvider, QuantityValue value, string unitAbbreviation, [NotNullWhen(true)] out IQuantity? quantity) { // TODO Optimize this with UnitValueAbbreviationLookup via UnitAbbreviationsCache.TryGetUnitValueAbbreviationLookup. List units = GetUnitsForAbbreviation(formatProvider, unitAbbreviation); diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index dfbea7a01b..00389fa1dd 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -17,7 +17,7 @@ namespace UnitsNet ///
/// The type of quantity to create, such as . /// The type of unit enum that belongs to this quantity, such as for . - public delegate TQuantity QuantityFromDelegate(double value, TUnitType fromUnit) + public delegate TQuantity QuantityFromDelegate(QuantityValue value, TUnitType fromUnit) where TQuantity : IQuantity where TUnitType : Enum; @@ -183,8 +183,8 @@ private TQuantity ParseWithRegex(string valueString, where TQuantity : IQuantity where TUnitType : Enum { - var value = double.Parse(valueString, ParseNumberStyles, formatProvider); - var parsedUnit = _unitParser.Parse(unitString, formatProvider); + var value = QuantityValue.Parse(valueString, ParseNumberStyles, formatProvider); + TUnitType parsedUnit = _unitParser.Parse(unitString, formatProvider); return fromDelegate(value, parsedUnit); } @@ -202,11 +202,15 @@ private bool TryParseWithRegex(string? valueString, { result = default; - if (!double.TryParse(valueString, ParseNumberStyles, formatProvider, out var value)) - return false; + if (!QuantityValue.TryParse(valueString, ParseNumberStyles, formatProvider, out QuantityValue value)) + { + return false; + } - if (!_unitParser.TryParse(unitString, formatProvider, out var parsedUnit)) - return false; + if (!_unitParser.TryParse(unitString, formatProvider, out TUnitType parsedUnit)) + { + return false; + } result = fromDelegate(value, parsedUnit); return true; @@ -218,7 +222,7 @@ private static bool TryExtractValueAndUnit(Regex regex, string str, [NotNullWhen // the regex coming in contains all allowed units as strings. // That means if the unit in str is not formatted right - // the regex.Match will ether put str or string.empty into Groups[0] and Groups[1] + // the regex.Match will either put str or string.empty into Groups[0] and Groups[1] // Therefore a mismatch can be detected by comparing the values of this two groups. if (match.Groups[0].Value == match.Groups[1].Value) { diff --git a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs index 5291b7d77b..784e54b0c0 100644 --- a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs +++ b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs @@ -29,7 +29,7 @@ public struct ReferencePressure ///
public Pressure AtmosphericPressure { get; set; } - private static readonly Pressure DefaultAtmosphericPressure = new Pressure(1, PressureUnit.Atmosphere); + private static readonly Pressure DefaultAtmosphericPressure = new(1, PressureUnit.Atmosphere); /// /// Gets a list of options: , @@ -130,7 +130,7 @@ private Pressure As(PressureReference reference) /// /// The to convert to. /// The value of pressure at - private double AsBaseNumericType(PressureReference reference) + private QuantityValue AsBaseNumericType(PressureReference reference) { var baseReferenceValue = AsBaseReference(); @@ -156,7 +156,7 @@ private double AsBaseNumericType(PressureReference reference) /// ///
/// The value of pressure at the - private double AsBaseReference() + private QuantityValue AsBaseReference() { switch (Reference) { diff --git a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs index ef37b00697..f5a96bfcef 100644 --- a/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AbsorbedDoseOfIonizingRadiation.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. ///
[DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,7 +97,7 @@ static AbsorbedDoseOfIonizingRadiation() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public AbsorbedDoseOfIonizingRadiation(double value, AbsorbedDoseOfIonizingRadiationUnit unit) + public AbsorbedDoseOfIonizingRadiation(QuantityValue value, AbsorbedDoseOfIonizingRadiationUnit unit) { _value = value; _unit = unit; @@ -110,7 +111,7 @@ public AbsorbedDoseOfIonizingRadiation(double value, AbsorbedDoseOfIonizingRadia /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) + public AbsorbedDoseOfIonizingRadiation(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -161,10 +162,10 @@ public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,82 +190,82 @@ public AbsorbedDoseOfIonizingRadiation(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Centigrays => As(AbsorbedDoseOfIonizingRadiationUnit.Centigray); + public QuantityValue Centigrays => As(AbsorbedDoseOfIonizingRadiationUnit.Centigray); /// /// Gets a value of this quantity converted into /// - public double Femtograys => As(AbsorbedDoseOfIonizingRadiationUnit.Femtogray); + public QuantityValue Femtograys => As(AbsorbedDoseOfIonizingRadiationUnit.Femtogray); /// /// Gets a value of this quantity converted into /// - public double Gigagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Gigagray); + public QuantityValue Gigagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Gigagray); /// /// Gets a value of this quantity converted into /// - public double Grays => As(AbsorbedDoseOfIonizingRadiationUnit.Gray); + public QuantityValue Grays => As(AbsorbedDoseOfIonizingRadiationUnit.Gray); /// /// Gets a value of this quantity converted into /// - public double Kilograys => As(AbsorbedDoseOfIonizingRadiationUnit.Kilogray); + public QuantityValue Kilograys => As(AbsorbedDoseOfIonizingRadiationUnit.Kilogray); /// /// Gets a value of this quantity converted into /// - public double Kilorads => As(AbsorbedDoseOfIonizingRadiationUnit.Kilorad); + public QuantityValue Kilorads => As(AbsorbedDoseOfIonizingRadiationUnit.Kilorad); /// /// Gets a value of this quantity converted into /// - public double Megagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Megagray); + public QuantityValue Megagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Megagray); /// /// Gets a value of this quantity converted into /// - public double Megarads => As(AbsorbedDoseOfIonizingRadiationUnit.Megarad); + public QuantityValue Megarads => As(AbsorbedDoseOfIonizingRadiationUnit.Megarad); /// /// Gets a value of this quantity converted into /// - public double Micrograys => As(AbsorbedDoseOfIonizingRadiationUnit.Microgray); + public QuantityValue Micrograys => As(AbsorbedDoseOfIonizingRadiationUnit.Microgray); /// /// Gets a value of this quantity converted into /// - public double Milligrays => As(AbsorbedDoseOfIonizingRadiationUnit.Milligray); + public QuantityValue Milligrays => As(AbsorbedDoseOfIonizingRadiationUnit.Milligray); /// /// Gets a value of this quantity converted into /// - public double Millirads => As(AbsorbedDoseOfIonizingRadiationUnit.Millirad); + public QuantityValue Millirads => As(AbsorbedDoseOfIonizingRadiationUnit.Millirad); /// /// Gets a value of this quantity converted into /// - public double Nanograys => As(AbsorbedDoseOfIonizingRadiationUnit.Nanogray); + public QuantityValue Nanograys => As(AbsorbedDoseOfIonizingRadiationUnit.Nanogray); /// /// Gets a value of this quantity converted into /// - public double Petagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Petagray); + public QuantityValue Petagrays => As(AbsorbedDoseOfIonizingRadiationUnit.Petagray); /// /// Gets a value of this quantity converted into /// - public double Picograys => As(AbsorbedDoseOfIonizingRadiationUnit.Picogray); + public QuantityValue Picograys => As(AbsorbedDoseOfIonizingRadiationUnit.Picogray); /// /// Gets a value of this quantity converted into /// - public double Rads => As(AbsorbedDoseOfIonizingRadiationUnit.Rad); + public QuantityValue Rads => As(AbsorbedDoseOfIonizingRadiationUnit.Rad); /// /// Gets a value of this quantity converted into /// - public double Teragrays => As(AbsorbedDoseOfIonizingRadiationUnit.Teragray); + public QuantityValue Teragrays => As(AbsorbedDoseOfIonizingRadiationUnit.Teragray); #endregion @@ -342,7 +343,7 @@ public static string GetAbbreviation(AbsorbedDoseOfIonizingRadiationUnit unit, I /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromCentigrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromCentigrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Centigray); } @@ -350,7 +351,7 @@ public static AbsorbedDoseOfIonizingRadiation FromCentigrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromFemtograys(double value) + public static AbsorbedDoseOfIonizingRadiation FromFemtograys(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Femtogray); } @@ -358,7 +359,7 @@ public static AbsorbedDoseOfIonizingRadiation FromFemtograys(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromGigagrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromGigagrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Gigagray); } @@ -366,7 +367,7 @@ public static AbsorbedDoseOfIonizingRadiation FromGigagrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromGrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromGrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Gray); } @@ -374,7 +375,7 @@ public static AbsorbedDoseOfIonizingRadiation FromGrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromKilograys(double value) + public static AbsorbedDoseOfIonizingRadiation FromKilograys(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Kilogray); } @@ -382,7 +383,7 @@ public static AbsorbedDoseOfIonizingRadiation FromKilograys(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromKilorads(double value) + public static AbsorbedDoseOfIonizingRadiation FromKilorads(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Kilorad); } @@ -390,7 +391,7 @@ public static AbsorbedDoseOfIonizingRadiation FromKilorads(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromMegagrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromMegagrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Megagray); } @@ -398,7 +399,7 @@ public static AbsorbedDoseOfIonizingRadiation FromMegagrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromMegarads(double value) + public static AbsorbedDoseOfIonizingRadiation FromMegarads(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Megarad); } @@ -406,7 +407,7 @@ public static AbsorbedDoseOfIonizingRadiation FromMegarads(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromMicrograys(double value) + public static AbsorbedDoseOfIonizingRadiation FromMicrograys(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Microgray); } @@ -414,7 +415,7 @@ public static AbsorbedDoseOfIonizingRadiation FromMicrograys(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromMilligrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromMilligrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Milligray); } @@ -422,7 +423,7 @@ public static AbsorbedDoseOfIonizingRadiation FromMilligrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromMillirads(double value) + public static AbsorbedDoseOfIonizingRadiation FromMillirads(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Millirad); } @@ -430,7 +431,7 @@ public static AbsorbedDoseOfIonizingRadiation FromMillirads(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromNanograys(double value) + public static AbsorbedDoseOfIonizingRadiation FromNanograys(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Nanogray); } @@ -438,7 +439,7 @@ public static AbsorbedDoseOfIonizingRadiation FromNanograys(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromPetagrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromPetagrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Petagray); } @@ -446,7 +447,7 @@ public static AbsorbedDoseOfIonizingRadiation FromPetagrays(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromPicograys(double value) + public static AbsorbedDoseOfIonizingRadiation FromPicograys(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Picogray); } @@ -454,7 +455,7 @@ public static AbsorbedDoseOfIonizingRadiation FromPicograys(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromRads(double value) + public static AbsorbedDoseOfIonizingRadiation FromRads(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Rad); } @@ -462,7 +463,7 @@ public static AbsorbedDoseOfIonizingRadiation FromRads(double value) /// /// Creates a from . /// - public static AbsorbedDoseOfIonizingRadiation FromTeragrays(double value) + public static AbsorbedDoseOfIonizingRadiation FromTeragrays(QuantityValue value) { return new AbsorbedDoseOfIonizingRadiation(value, AbsorbedDoseOfIonizingRadiationUnit.Teragray); } @@ -473,7 +474,7 @@ public static AbsorbedDoseOfIonizingRadiation FromTeragrays(double value) /// Value to convert from. /// Unit to convert from. /// AbsorbedDoseOfIonizingRadiation unit value. - public static AbsorbedDoseOfIonizingRadiation From(double value, AbsorbedDoseOfIonizingRadiationUnit fromUnit) + public static AbsorbedDoseOfIonizingRadiation From(QuantityValue value, AbsorbedDoseOfIonizingRadiationUnit fromUnit) { return new AbsorbedDoseOfIonizingRadiation(value, fromUnit); } @@ -645,25 +646,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Absor } /// Get from multiplying value and . - public static AbsorbedDoseOfIonizingRadiation operator *(double left, AbsorbedDoseOfIonizingRadiation right) + public static AbsorbedDoseOfIonizingRadiation operator *(QuantityValue left, AbsorbedDoseOfIonizingRadiation right) { return new AbsorbedDoseOfIonizingRadiation(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AbsorbedDoseOfIonizingRadiation operator *(AbsorbedDoseOfIonizingRadiation left, double right) + public static AbsorbedDoseOfIonizingRadiation operator *(AbsorbedDoseOfIonizingRadiation left, QuantityValue right) { return new AbsorbedDoseOfIonizingRadiation(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AbsorbedDoseOfIonizingRadiation operator /(AbsorbedDoseOfIonizingRadiation left, double right) + public static AbsorbedDoseOfIonizingRadiation operator /(AbsorbedDoseOfIonizingRadiation left, QuantityValue right) { return new AbsorbedDoseOfIonizingRadiation(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AbsorbedDoseOfIonizingRadiation left, AbsorbedDoseOfIonizingRadiation right) + public static QuantityValue operator /(AbsorbedDoseOfIonizingRadiation left, AbsorbedDoseOfIonizingRadiation right) { return left.Grays / right.Grays; } @@ -696,27 +697,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Absor return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict equality of two quantities. public static bool operator ==(AbsorbedDoseOfIonizingRadiation left, AbsorbedDoseOfIonizingRadiation right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(AbsorbedDoseOfIonizingRadiation left, AbsorbedDoseOfIonizingRadiation right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is AbsorbedDoseOfIonizingRadiation otherQuantity)) @@ -726,15 +720,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(AbsorbedDoseOfIonizingRadiation other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -817,10 +808,10 @@ public bool Equals(AbsorbedDoseOfIonizingRadiation other, double tolerance, Comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -837,7 +828,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AbsorbedDoseOfIonizingRadiation other, AbsorbedDoseOfIonizingRadiation tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -850,7 +841,12 @@ public bool Equals(AbsorbedDoseOfIonizingRadiation other, AbsorbedDoseOfIonizing /// A hash code for the current AbsorbedDoseOfIonizingRadiation. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -861,7 +857,7 @@ public override int GetHashCode() /// Convert to the unit representation . ///
/// Value converted to the specified unit. - public double As(AbsorbedDoseOfIonizingRadiationUnit unit) + public QuantityValue As(AbsorbedDoseOfIonizingRadiationUnit unit) { if (Unit == unit) return Value; @@ -870,7 +866,7 @@ public double As(AbsorbedDoseOfIonizingRadiationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -885,7 +881,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AbsorbedDoseOfIonizingRadiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AbsorbedDoseOfIonizingRadiationUnit)} is supported.", nameof(unit)); @@ -951,38 +947,38 @@ private bool TryToUnit(AbsorbedDoseOfIonizingRadiationUnit unit, [NotNullWhen(tr AbsorbedDoseOfIonizingRadiation? convertedOrNull = (Unit, unit) switch { // AbsorbedDoseOfIonizingRadiationUnit -> BaseUnit - (AbsorbedDoseOfIonizingRadiationUnit.Centigray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-2d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Femtogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-15d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Gigagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e9d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Kilogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e3d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Kilorad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value / 100) * 1e3d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Megagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e6d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Megarad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value / 100) * 1e6d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Microgray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-6d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Milligray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-3d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Millirad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value / 100) * 1e-3d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Nanogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-9d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Petagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e15d, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Picogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e-12d, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Centigray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 100, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Femtogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Gigagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Kilogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Kilorad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 10, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Megagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Megarad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 10000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Microgray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Milligray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Millirad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 100000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Nanogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Petagray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Picogray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), (AbsorbedDoseOfIonizingRadiationUnit.Rad, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value / 100, AbsorbedDoseOfIonizingRadiationUnit.Gray), - (AbsorbedDoseOfIonizingRadiationUnit.Teragray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation((_value) * 1e12d, AbsorbedDoseOfIonizingRadiationUnit.Gray), + (AbsorbedDoseOfIonizingRadiationUnit.Teragray, AbsorbedDoseOfIonizingRadiationUnit.Gray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000000, AbsorbedDoseOfIonizingRadiationUnit.Gray), // BaseUnit -> AbsorbedDoseOfIonizingRadiationUnit - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Centigray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-2d, AbsorbedDoseOfIonizingRadiationUnit.Centigray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Femtogray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-15d, AbsorbedDoseOfIonizingRadiationUnit.Femtogray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Gigagray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e9d, AbsorbedDoseOfIonizingRadiationUnit.Gigagray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Kilogray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e3d, AbsorbedDoseOfIonizingRadiationUnit.Kilogray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Kilorad) => new AbsorbedDoseOfIonizingRadiation((_value * 100) / 1e3d, AbsorbedDoseOfIonizingRadiationUnit.Kilorad), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Megagray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e6d, AbsorbedDoseOfIonizingRadiationUnit.Megagray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Megarad) => new AbsorbedDoseOfIonizingRadiation((_value * 100) / 1e6d, AbsorbedDoseOfIonizingRadiationUnit.Megarad), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Microgray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-6d, AbsorbedDoseOfIonizingRadiationUnit.Microgray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Milligray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-3d, AbsorbedDoseOfIonizingRadiationUnit.Milligray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Millirad) => new AbsorbedDoseOfIonizingRadiation((_value * 100) / 1e-3d, AbsorbedDoseOfIonizingRadiationUnit.Millirad), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Nanogray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-9d, AbsorbedDoseOfIonizingRadiationUnit.Nanogray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Petagray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e15d, AbsorbedDoseOfIonizingRadiationUnit.Petagray), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Picogray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e-12d, AbsorbedDoseOfIonizingRadiationUnit.Picogray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Centigray) => new AbsorbedDoseOfIonizingRadiation(_value * 100, AbsorbedDoseOfIonizingRadiationUnit.Centigray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Femtogray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000000000, AbsorbedDoseOfIonizingRadiationUnit.Femtogray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Gigagray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000, AbsorbedDoseOfIonizingRadiationUnit.Gigagray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Kilogray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000, AbsorbedDoseOfIonizingRadiationUnit.Kilogray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Kilorad) => new AbsorbedDoseOfIonizingRadiation(_value / 10, AbsorbedDoseOfIonizingRadiationUnit.Kilorad), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Megagray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000, AbsorbedDoseOfIonizingRadiationUnit.Megagray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Megarad) => new AbsorbedDoseOfIonizingRadiation(_value / 10000, AbsorbedDoseOfIonizingRadiationUnit.Megarad), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Microgray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000, AbsorbedDoseOfIonizingRadiationUnit.Microgray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Milligray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000, AbsorbedDoseOfIonizingRadiationUnit.Milligray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Millirad) => new AbsorbedDoseOfIonizingRadiation(_value * 100000, AbsorbedDoseOfIonizingRadiationUnit.Millirad), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Nanogray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000, AbsorbedDoseOfIonizingRadiationUnit.Nanogray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Petagray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000000000, AbsorbedDoseOfIonizingRadiationUnit.Petagray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Picogray) => new AbsorbedDoseOfIonizingRadiation(_value * 1000000000000, AbsorbedDoseOfIonizingRadiationUnit.Picogray), (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Rad) => new AbsorbedDoseOfIonizingRadiation(_value * 100, AbsorbedDoseOfIonizingRadiationUnit.Rad), - (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Teragray) => new AbsorbedDoseOfIonizingRadiation((_value) / 1e12d, AbsorbedDoseOfIonizingRadiationUnit.Teragray), + (AbsorbedDoseOfIonizingRadiationUnit.Gray, AbsorbedDoseOfIonizingRadiationUnit.Teragray) => new AbsorbedDoseOfIonizingRadiation(_value / 1000000000000, AbsorbedDoseOfIonizingRadiationUnit.Teragray), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 89724a7161..56b81ac90d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. ///
[DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -101,7 +99,7 @@ static Acceleration() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Acceleration(double value, AccelerationUnit unit) + public Acceleration(QuantityValue value, AccelerationUnit unit) { _value = value; _unit = unit; @@ -115,7 +113,7 @@ public Acceleration(double value, AccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Acceleration(double value, UnitSystem unitSystem) + public Acceleration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -166,10 +164,10 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,72 +192,72 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); + public QuantityValue CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); + public QuantityValue DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); + public QuantityValue FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); + public QuantityValue InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); + public QuantityValue KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double KnotsPerHour => As(AccelerationUnit.KnotPerHour); + public QuantityValue KnotsPerHour => As(AccelerationUnit.KnotPerHour); /// /// Gets a value of this quantity converted into /// - public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); + public QuantityValue KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); /// /// Gets a value of this quantity converted into /// - public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); + public QuantityValue KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); /// /// Gets a value of this quantity converted into /// - public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); + public QuantityValue MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); + public QuantityValue MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); + public QuantityValue MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double MillistandardGravity => As(AccelerationUnit.MillistandardGravity); + public QuantityValue MillistandardGravity => As(AccelerationUnit.MillistandardGravity); /// /// Gets a value of this quantity converted into /// - public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); + public QuantityValue NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double StandardGravity => As(AccelerationUnit.StandardGravity); + public QuantityValue StandardGravity => As(AccelerationUnit.StandardGravity); #endregion @@ -333,7 +331,7 @@ public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static Acceleration FromCentimetersPerSecondSquared(double value) + public static Acceleration FromCentimetersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared); } @@ -341,7 +339,7 @@ public static Acceleration FromCentimetersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromDecimetersPerSecondSquared(double value) + public static Acceleration FromDecimetersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared); } @@ -349,7 +347,7 @@ public static Acceleration FromDecimetersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromFeetPerSecondSquared(double value) + public static Acceleration FromFeetPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.FootPerSecondSquared); } @@ -357,7 +355,7 @@ public static Acceleration FromFeetPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromInchesPerSecondSquared(double value) + public static Acceleration FromInchesPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.InchPerSecondSquared); } @@ -365,7 +363,7 @@ public static Acceleration FromInchesPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromKilometersPerSecondSquared(double value) + public static Acceleration FromKilometersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared); } @@ -373,7 +371,7 @@ public static Acceleration FromKilometersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromKnotsPerHour(double value) + public static Acceleration FromKnotsPerHour(QuantityValue value) { return new Acceleration(value, AccelerationUnit.KnotPerHour); } @@ -381,7 +379,7 @@ public static Acceleration FromKnotsPerHour(double value) /// /// Creates a from . /// - public static Acceleration FromKnotsPerMinute(double value) + public static Acceleration FromKnotsPerMinute(QuantityValue value) { return new Acceleration(value, AccelerationUnit.KnotPerMinute); } @@ -389,7 +387,7 @@ public static Acceleration FromKnotsPerMinute(double value) /// /// Creates a from . /// - public static Acceleration FromKnotsPerSecond(double value) + public static Acceleration FromKnotsPerSecond(QuantityValue value) { return new Acceleration(value, AccelerationUnit.KnotPerSecond); } @@ -397,7 +395,7 @@ public static Acceleration FromKnotsPerSecond(double value) /// /// Creates a from . /// - public static Acceleration FromMetersPerSecondSquared(double value) + public static Acceleration FromMetersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared); } @@ -405,7 +403,7 @@ public static Acceleration FromMetersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromMicrometersPerSecondSquared(double value) + public static Acceleration FromMicrometersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared); } @@ -413,7 +411,7 @@ public static Acceleration FromMicrometersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromMillimetersPerSecondSquared(double value) + public static Acceleration FromMillimetersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared); } @@ -421,7 +419,7 @@ public static Acceleration FromMillimetersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromMillistandardGravity(double value) + public static Acceleration FromMillistandardGravity(QuantityValue value) { return new Acceleration(value, AccelerationUnit.MillistandardGravity); } @@ -429,7 +427,7 @@ public static Acceleration FromMillistandardGravity(double value) /// /// Creates a from . /// - public static Acceleration FromNanometersPerSecondSquared(double value) + public static Acceleration FromNanometersPerSecondSquared(QuantityValue value) { return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared); } @@ -437,7 +435,7 @@ public static Acceleration FromNanometersPerSecondSquared(double value) /// /// Creates a from . /// - public static Acceleration FromStandardGravity(double value) + public static Acceleration FromStandardGravity(QuantityValue value) { return new Acceleration(value, AccelerationUnit.StandardGravity); } @@ -448,7 +446,7 @@ public static Acceleration FromStandardGravity(double value) /// Value to convert from. /// Unit to convert from. /// Acceleration unit value. - public static Acceleration From(double value, AccelerationUnit fromUnit) + public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit) { return new Acceleration(value, fromUnit); } @@ -620,25 +618,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel } /// Get from multiplying value and . - public static Acceleration operator *(double left, Acceleration right) + public static Acceleration operator *(QuantityValue left, Acceleration right) { return new Acceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Acceleration operator *(Acceleration left, double right) + public static Acceleration operator *(Acceleration left, QuantityValue right) { return new Acceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Acceleration operator /(Acceleration left, double right) + public static Acceleration operator /(Acceleration left, QuantityValue right) { return new Acceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Acceleration left, Acceleration right) + public static QuantityValue operator /(Acceleration left, Acceleration right) { return left.MetersPerSecondSquared / right.MetersPerSecondSquared; } @@ -705,27 +703,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Acceleration left, Acceleration right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Acceleration other, Acceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Acceleration left, Acceleration right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Acceleration otherQuantity)) @@ -735,15 +726,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Acceleration other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -826,10 +814,10 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -846,7 +834,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Acceleration other, Acceleration tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -859,7 +847,12 @@ public bool Equals(Acceleration other, Acceleration tolerance) /// A hash code for the current Acceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -870,7 +863,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AccelerationUnit unit) + public QuantityValue As(AccelerationUnit unit) { if (Unit == unit) return Value; @@ -879,7 +872,7 @@ public double As(AccelerationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -894,7 +887,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); @@ -960,34 +953,34 @@ private bool TryToUnit(AccelerationUnit unit, [NotNullWhen(true)] out Accelerati Acceleration? convertedOrNull = (Unit, unit) switch { // AccelerationUnit -> BaseUnit - (AccelerationUnit.CentimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e-2d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.DecimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e-1d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.FootPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 0.304800, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.InchPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 0.0254, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.KilometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e3d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.KnotPerHour, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 0.5144444444444 / 3600, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.KnotPerMinute, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 0.5144444444444 / 60, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.KnotPerSecond, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 0.5144444444444, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.MicrometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e-6d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.MillimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e-3d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.MillistandardGravity, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value * 9.80665) * 1e-3d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.NanometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration((_value) * 1e-9d, AccelerationUnit.MeterPerSecondSquared), - (AccelerationUnit.StandardGravity, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 9.80665, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.CentimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value / 100, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.DecimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value / 10, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.FootPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(381, 1250, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.InchPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(127, 5000, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.KilometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * 1000, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.KnotPerHour, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(1286111111111, 9000000000000000, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.KnotPerMinute, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(1286111111111, 150000000000000, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.KnotPerSecond, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(1286111111111, 2500000000000, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.MicrometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value / 1000000, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.MillimeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value / 1000, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.MillistandardGravity, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(196133, 20000000, false), AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.NanometerPerSecondSquared, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value / 1000000000, AccelerationUnit.MeterPerSecondSquared), + (AccelerationUnit.StandardGravity, AccelerationUnit.MeterPerSecondSquared) => new Acceleration(_value * new QuantityValue(196133, 20000, false), AccelerationUnit.MeterPerSecondSquared), // BaseUnit -> AccelerationUnit - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.CentimeterPerSecondSquared) => new Acceleration((_value) / 1e-2d, AccelerationUnit.CentimeterPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.DecimeterPerSecondSquared) => new Acceleration((_value) / 1e-1d, AccelerationUnit.DecimeterPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.FootPerSecondSquared) => new Acceleration(_value / 0.304800, AccelerationUnit.FootPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.InchPerSecondSquared) => new Acceleration(_value / 0.0254, AccelerationUnit.InchPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KilometerPerSecondSquared) => new Acceleration((_value) / 1e3d, AccelerationUnit.KilometerPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerHour) => new Acceleration(_value / 0.5144444444444 * 3600, AccelerationUnit.KnotPerHour), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerMinute) => new Acceleration(_value / 0.5144444444444 * 60, AccelerationUnit.KnotPerMinute), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerSecond) => new Acceleration(_value / 0.5144444444444, AccelerationUnit.KnotPerSecond), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MicrometerPerSecondSquared) => new Acceleration((_value) / 1e-6d, AccelerationUnit.MicrometerPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MillimeterPerSecondSquared) => new Acceleration((_value) / 1e-3d, AccelerationUnit.MillimeterPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MillistandardGravity) => new Acceleration((_value / 9.80665) / 1e-3d, AccelerationUnit.MillistandardGravity), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.NanometerPerSecondSquared) => new Acceleration((_value) / 1e-9d, AccelerationUnit.NanometerPerSecondSquared), - (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.StandardGravity) => new Acceleration(_value / 9.80665, AccelerationUnit.StandardGravity), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.CentimeterPerSecondSquared) => new Acceleration(_value * 100, AccelerationUnit.CentimeterPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.DecimeterPerSecondSquared) => new Acceleration(_value * 10, AccelerationUnit.DecimeterPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.FootPerSecondSquared) => new Acceleration(_value * new QuantityValue(1250, 381, false), AccelerationUnit.FootPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.InchPerSecondSquared) => new Acceleration(_value * new QuantityValue(5000, 127, false), AccelerationUnit.InchPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KilometerPerSecondSquared) => new Acceleration(_value / 1000, AccelerationUnit.KilometerPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerHour) => new Acceleration(_value * new QuantityValue(9000000000000000, 1286111111111, false), AccelerationUnit.KnotPerHour), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerMinute) => new Acceleration(_value * new QuantityValue(150000000000000, 1286111111111, false), AccelerationUnit.KnotPerMinute), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.KnotPerSecond) => new Acceleration(_value * new QuantityValue(2500000000000, 1286111111111, false), AccelerationUnit.KnotPerSecond), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MicrometerPerSecondSquared) => new Acceleration(_value * 1000000, AccelerationUnit.MicrometerPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MillimeterPerSecondSquared) => new Acceleration(_value * 1000, AccelerationUnit.MillimeterPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MillistandardGravity) => new Acceleration(_value * new QuantityValue(20000000, 196133, false), AccelerationUnit.MillistandardGravity), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.NanometerPerSecondSquared) => new Acceleration(_value * 1000000000, AccelerationUnit.NanometerPerSecondSquared), + (AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.StandardGravity) => new Acceleration(_value * new QuantityValue(20000, 196133, false), AccelerationUnit.StandardGravity), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 58975e193f..4dad9b00ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -104,7 +102,7 @@ static AmountOfSubstance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) + public AmountOfSubstance(QuantityValue value, AmountOfSubstanceUnit unit) { _value = value; _unit = unit; @@ -118,7 +116,7 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmountOfSubstance(double value, UnitSystem unitSystem) + public AmountOfSubstance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -169,10 +167,10 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -197,87 +195,87 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Centimoles => As(AmountOfSubstanceUnit.Centimole); + public QuantityValue Centimoles => As(AmountOfSubstanceUnit.Centimole); /// /// Gets a value of this quantity converted into /// - public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); + public QuantityValue CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); /// /// Gets a value of this quantity converted into /// - public double Decimoles => As(AmountOfSubstanceUnit.Decimole); + public QuantityValue Decimoles => As(AmountOfSubstanceUnit.Decimole); /// /// Gets a value of this quantity converted into /// - public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); + public QuantityValue DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); /// /// Gets a value of this quantity converted into /// - public double Femtomoles => As(AmountOfSubstanceUnit.Femtomole); + public QuantityValue Femtomoles => As(AmountOfSubstanceUnit.Femtomole); /// /// Gets a value of this quantity converted into /// - public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole); + public QuantityValue Kilomoles => As(AmountOfSubstanceUnit.Kilomole); /// /// Gets a value of this quantity converted into /// - public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); + public QuantityValue KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); /// /// Gets a value of this quantity converted into /// - public double Megamoles => As(AmountOfSubstanceUnit.Megamole); + public QuantityValue Megamoles => As(AmountOfSubstanceUnit.Megamole); /// /// Gets a value of this quantity converted into /// - public double Micromoles => As(AmountOfSubstanceUnit.Micromole); + public QuantityValue Micromoles => As(AmountOfSubstanceUnit.Micromole); /// /// Gets a value of this quantity converted into /// - public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); + public QuantityValue MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); /// /// Gets a value of this quantity converted into /// - public double Millimoles => As(AmountOfSubstanceUnit.Millimole); + public QuantityValue Millimoles => As(AmountOfSubstanceUnit.Millimole); /// /// Gets a value of this quantity converted into /// - public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); + public QuantityValue MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); /// /// Gets a value of this quantity converted into /// - public double Moles => As(AmountOfSubstanceUnit.Mole); + public QuantityValue Moles => As(AmountOfSubstanceUnit.Mole); /// /// Gets a value of this quantity converted into /// - public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole); + public QuantityValue Nanomoles => As(AmountOfSubstanceUnit.Nanomole); /// /// Gets a value of this quantity converted into /// - public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); + public QuantityValue NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); /// /// Gets a value of this quantity converted into /// - public double Picomoles => As(AmountOfSubstanceUnit.Picomole); + public QuantityValue Picomoles => As(AmountOfSubstanceUnit.Picomole); /// /// Gets a value of this quantity converted into /// - public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole); + public QuantityValue PoundMoles => As(AmountOfSubstanceUnit.PoundMole); #endregion @@ -357,7 +355,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider /// /// Creates a from . /// - public static AmountOfSubstance FromCentimoles(double value) + public static AmountOfSubstance FromCentimoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole); } @@ -365,7 +363,7 @@ public static AmountOfSubstance FromCentimoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromCentipoundMoles(double value) + public static AmountOfSubstance FromCentipoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole); } @@ -373,7 +371,7 @@ public static AmountOfSubstance FromCentipoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromDecimoles(double value) + public static AmountOfSubstance FromDecimoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole); } @@ -381,7 +379,7 @@ public static AmountOfSubstance FromDecimoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromDecipoundMoles(double value) + public static AmountOfSubstance FromDecipoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole); } @@ -389,7 +387,7 @@ public static AmountOfSubstance FromDecipoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromFemtomoles(double value) + public static AmountOfSubstance FromFemtomoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Femtomole); } @@ -397,7 +395,7 @@ public static AmountOfSubstance FromFemtomoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromKilomoles(double value) + public static AmountOfSubstance FromKilomoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole); } @@ -405,7 +403,7 @@ public static AmountOfSubstance FromKilomoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromKilopoundMoles(double value) + public static AmountOfSubstance FromKilopoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole); } @@ -413,7 +411,7 @@ public static AmountOfSubstance FromKilopoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMegamoles(double value) + public static AmountOfSubstance FromMegamoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole); } @@ -421,7 +419,7 @@ public static AmountOfSubstance FromMegamoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMicromoles(double value) + public static AmountOfSubstance FromMicromoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole); } @@ -429,7 +427,7 @@ public static AmountOfSubstance FromMicromoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMicropoundMoles(double value) + public static AmountOfSubstance FromMicropoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole); } @@ -437,7 +435,7 @@ public static AmountOfSubstance FromMicropoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMillimoles(double value) + public static AmountOfSubstance FromMillimoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole); } @@ -445,7 +443,7 @@ public static AmountOfSubstance FromMillimoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMillipoundMoles(double value) + public static AmountOfSubstance FromMillipoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole); } @@ -453,7 +451,7 @@ public static AmountOfSubstance FromMillipoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromMoles(double value) + public static AmountOfSubstance FromMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole); } @@ -461,7 +459,7 @@ public static AmountOfSubstance FromMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromNanomoles(double value) + public static AmountOfSubstance FromNanomoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole); } @@ -469,7 +467,7 @@ public static AmountOfSubstance FromNanomoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromNanopoundMoles(double value) + public static AmountOfSubstance FromNanopoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole); } @@ -477,7 +475,7 @@ public static AmountOfSubstance FromNanopoundMoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromPicomoles(double value) + public static AmountOfSubstance FromPicomoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.Picomole); } @@ -485,7 +483,7 @@ public static AmountOfSubstance FromPicomoles(double value) /// /// Creates a from . /// - public static AmountOfSubstance FromPoundMoles(double value) + public static AmountOfSubstance FromPoundMoles(QuantityValue value) { return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole); } @@ -496,7 +494,7 @@ public static AmountOfSubstance FromPoundMoles(double value) /// Value to convert from. /// Unit to convert from. /// AmountOfSubstance unit value. - public static AmountOfSubstance From(double value, AmountOfSubstanceUnit fromUnit) + public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit fromUnit) { return new AmountOfSubstance(value, fromUnit); } @@ -668,25 +666,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun } /// Get from multiplying value and . - public static AmountOfSubstance operator *(double left, AmountOfSubstance right) + public static AmountOfSubstance operator *(QuantityValue left, AmountOfSubstance right) { return new AmountOfSubstance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AmountOfSubstance operator *(AmountOfSubstance left, double right) + public static AmountOfSubstance operator *(AmountOfSubstance left, QuantityValue right) { return new AmountOfSubstance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AmountOfSubstance operator /(AmountOfSubstance left, double right) + public static AmountOfSubstance operator /(AmountOfSubstance left, QuantityValue right) { return new AmountOfSubstance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AmountOfSubstance left, AmountOfSubstance right) + public static QuantityValue operator /(AmountOfSubstance left, AmountOfSubstance right) { return left.Moles / right.Moles; } @@ -753,27 +751,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmountOfSubstance other, AmountOfSubstance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is AmountOfSubstance otherQuantity)) @@ -783,15 +774,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(AmountOfSubstance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -874,10 +862,10 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -894,7 +882,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AmountOfSubstance other, AmountOfSubstance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -907,7 +895,12 @@ public bool Equals(AmountOfSubstance other, AmountOfSubstance tolerance) /// A hash code for the current AmountOfSubstance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -918,7 +911,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmountOfSubstanceUnit unit) + public QuantityValue As(AmountOfSubstanceUnit unit) { if (Unit == unit) return Value; @@ -927,7 +920,7 @@ public double As(AmountOfSubstanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -942,7 +935,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); @@ -1008,40 +1001,40 @@ private bool TryToUnit(AmountOfSubstanceUnit unit, [NotNullWhen(true)] out Amoun AmountOfSubstance? convertedOrNull = (Unit, unit) switch { // AmountOfSubstanceUnit -> BaseUnit - (AmountOfSubstanceUnit.Centimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-2d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e-2d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Decimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-1d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e-1d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Femtomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-15d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Kilomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e3d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e3d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Megamole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e6d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Micromole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-6d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e-6d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Millimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-3d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e-3d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Nanomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-9d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value * 453.59237) * 1e-9d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.Picomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance((_value) * 1e-12d, AmountOfSubstanceUnit.Mole), - (AmountOfSubstanceUnit.PoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * 453.59237, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Centimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 100, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 10000000, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Decimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 10, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 1000000, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Femtomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 1000000000000000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Kilomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * 1000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 100, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Megamole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * 1000000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Micromole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 1000000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 100000000000, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Millimole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 1000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 100000000, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Nanomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 1000000000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 100000000000000, false), AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.Picomole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value / 1000000000000, AmountOfSubstanceUnit.Mole), + (AmountOfSubstanceUnit.PoundMole, AmountOfSubstanceUnit.Mole) => new AmountOfSubstance(_value * new QuantityValue(45359237, 100000, false), AmountOfSubstanceUnit.Mole), // BaseUnit -> AmountOfSubstanceUnit - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Centimole) => new AmountOfSubstance((_value) / 1e-2d, AmountOfSubstanceUnit.Centimole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.CentipoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e-2d, AmountOfSubstanceUnit.CentipoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Decimole) => new AmountOfSubstance((_value) / 1e-1d, AmountOfSubstanceUnit.Decimole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.DecipoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e-1d, AmountOfSubstanceUnit.DecipoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Femtomole) => new AmountOfSubstance((_value) / 1e-15d, AmountOfSubstanceUnit.Femtomole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Kilomole) => new AmountOfSubstance((_value) / 1e3d, AmountOfSubstanceUnit.Kilomole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.KilopoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e3d, AmountOfSubstanceUnit.KilopoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Megamole) => new AmountOfSubstance((_value) / 1e6d, AmountOfSubstanceUnit.Megamole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Micromole) => new AmountOfSubstance((_value) / 1e-6d, AmountOfSubstanceUnit.Micromole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.MicropoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e-6d, AmountOfSubstanceUnit.MicropoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Millimole) => new AmountOfSubstance((_value) / 1e-3d, AmountOfSubstanceUnit.Millimole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.MillipoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e-3d, AmountOfSubstanceUnit.MillipoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Nanomole) => new AmountOfSubstance((_value) / 1e-9d, AmountOfSubstanceUnit.Nanomole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.NanopoundMole) => new AmountOfSubstance((_value / 453.59237) / 1e-9d, AmountOfSubstanceUnit.NanopoundMole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Picomole) => new AmountOfSubstance((_value) / 1e-12d, AmountOfSubstanceUnit.Picomole), - (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.PoundMole) => new AmountOfSubstance(_value / 453.59237, AmountOfSubstanceUnit.PoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Centimole) => new AmountOfSubstance(_value * 100, AmountOfSubstanceUnit.Centimole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.CentipoundMole) => new AmountOfSubstance(_value * new QuantityValue(10000000, 45359237, false), AmountOfSubstanceUnit.CentipoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Decimole) => new AmountOfSubstance(_value * 10, AmountOfSubstanceUnit.Decimole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.DecipoundMole) => new AmountOfSubstance(_value * new QuantityValue(1000000, 45359237, false), AmountOfSubstanceUnit.DecipoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Femtomole) => new AmountOfSubstance(_value * 1000000000000000, AmountOfSubstanceUnit.Femtomole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Kilomole) => new AmountOfSubstance(_value / 1000, AmountOfSubstanceUnit.Kilomole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.KilopoundMole) => new AmountOfSubstance(_value * new QuantityValue(100, 45359237, false), AmountOfSubstanceUnit.KilopoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Megamole) => new AmountOfSubstance(_value / 1000000, AmountOfSubstanceUnit.Megamole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Micromole) => new AmountOfSubstance(_value * 1000000, AmountOfSubstanceUnit.Micromole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.MicropoundMole) => new AmountOfSubstance(_value * new QuantityValue(100000000000, 45359237, false), AmountOfSubstanceUnit.MicropoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Millimole) => new AmountOfSubstance(_value * 1000, AmountOfSubstanceUnit.Millimole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.MillipoundMole) => new AmountOfSubstance(_value * new QuantityValue(100000000, 45359237, false), AmountOfSubstanceUnit.MillipoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Nanomole) => new AmountOfSubstance(_value * 1000000000, AmountOfSubstanceUnit.Nanomole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.NanopoundMole) => new AmountOfSubstance(_value * new QuantityValue(100000000000000, 45359237, false), AmountOfSubstanceUnit.NanopoundMole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Picomole) => new AmountOfSubstance(_value * 1000000000000, AmountOfSubstanceUnit.Picomole), + (AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.PoundMole) => new AmountOfSubstance(_value * new QuantityValue(100000, 45359237, false), AmountOfSubstanceUnit.PoundMole), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 146c85d43f..4659c0b549 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static AmplitudeRatio() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public AmplitudeRatio(double value, AmplitudeRatioUnit unit) + public AmplitudeRatio(QuantityValue value, AmplitudeRatioUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmplitudeRatio(double value, UnitSystem unitSystem) + public AmplitudeRatio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,22 +175,22 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); + public QuantityValue DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); /// /// Gets a value of this quantity converted into /// - public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); + public QuantityValue DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); /// /// Gets a value of this quantity converted into /// - public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); + public QuantityValue DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); /// /// Gets a value of this quantity converted into /// - public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); + public QuantityValue DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); #endregion @@ -243,7 +244,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static AmplitudeRatio FromDecibelMicrovolts(double value) + public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue value) { return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt); } @@ -251,7 +252,7 @@ public static AmplitudeRatio FromDecibelMicrovolts(double value) /// /// Creates a from . /// - public static AmplitudeRatio FromDecibelMillivolts(double value) + public static AmplitudeRatio FromDecibelMillivolts(QuantityValue value) { return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt); } @@ -259,7 +260,7 @@ public static AmplitudeRatio FromDecibelMillivolts(double value) /// /// Creates a from . /// - public static AmplitudeRatio FromDecibelsUnloaded(double value) + public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue value) { return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded); } @@ -267,7 +268,7 @@ public static AmplitudeRatio FromDecibelsUnloaded(double value) /// /// Creates a from . /// - public static AmplitudeRatio FromDecibelVolts(double value) + public static AmplitudeRatio FromDecibelVolts(QuantityValue value) { return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt); } @@ -278,7 +279,7 @@ public static AmplitudeRatio FromDecibelVolts(double value) /// Value to convert from. /// Unit to convert from. /// AmplitudeRatio unit value. - public static AmplitudeRatio From(double value, AmplitudeRatioUnit fromUnit) + public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUnit) { return new AmplitudeRatio(value, fromUnit); } @@ -442,7 +443,10 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic addition // Formula: 20 * log10(10^(x/20) + 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value / 20) + Math.Pow(10, right.ToUnit(left.Unit).Value / 20)), left.Unit); + // TODO see if we can switch to operating in linear space: left + right.ToUnit(left.Unit) + return new AmplitudeRatio(20 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 20).ToDouble()) + Math.Pow(10, (right.ToUnit(left.Unit).Value / 20).ToDouble()))), + left.Unit); } /// Get from logarithmic subtraction of two . @@ -450,35 +454,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic subtraction // Formula: 20 * log10(10^(x/20) - 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value / 20) - Math.Pow(10, right.ToUnit(left.Unit).Value / 20)), left.Unit); + // TODO see if we can switch to operating in linear space: left - right.ToUnit(left.Unit) + return new AmplitudeRatio(20 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 20).ToDouble()) - Math.Pow(10, (right.ToUnit(left.Unit).Value / 20).ToDouble()))), + left.Unit); } /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(double left, AmplitudeRatio right) + public static AmplitudeRatio operator *(QuantityValue left, AmplitudeRatio right) { // Logarithmic multiplication = addition + // TODO see if we can switch to operating in linear space: left * right.ToUnit(left.Unit) return new AmplitudeRatio(left + right.Value, right.Unit); } /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(AmplitudeRatio left, double right) + public static AmplitudeRatio operator *(AmplitudeRatio left, QuantityValue right) { // Logarithmic multiplication = addition return new AmplitudeRatio(left.Value + right, left.Unit); } /// Get from logarithmic division of by value. - public static AmplitudeRatio operator /(AmplitudeRatio left, double right) + public static AmplitudeRatio operator /(AmplitudeRatio left, QuantityValue right) { // Logarithmic division = subtraction return new AmplitudeRatio(left.Value - right, left.Unit); } /// Get ratio value from logarithmic division of by . - public static double operator /(AmplitudeRatio left, AmplitudeRatio right) + public static QuantityValue operator /(AmplitudeRatio left, AmplitudeRatio right) { // Logarithmic division = subtraction - return Convert.ToDouble(left.Value - right.ToUnit(left.Unit).Value); + return left.Value - right.ToUnit(left.Unit).Value; } #endregion @@ -509,27 +517,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AmplitudeRatio other, AmplitudeRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is AmplitudeRatio otherQuantity)) @@ -539,15 +540,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(AmplitudeRatio other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +628,10 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -650,7 +648,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AmplitudeRatio other, AmplitudeRatio tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -663,7 +661,12 @@ public bool Equals(AmplitudeRatio other, AmplitudeRatio tolerance) /// A hash code for the current AmplitudeRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -674,7 +677,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmplitudeRatioUnit unit) + public QuantityValue As(AmplitudeRatioUnit unit) { if (Unit == unit) return Value; @@ -683,7 +686,7 @@ public double As(AmplitudeRatioUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -698,7 +701,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); @@ -764,14 +767,14 @@ private bool TryToUnit(AmplitudeRatioUnit unit, [NotNullWhen(true)] out Amplitud AmplitudeRatio? convertedOrNull = (Unit, unit) switch { // AmplitudeRatioUnit -> BaseUnit - (AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value - 120, AmplitudeRatioUnit.DecibelVolt), - (AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value - 60, AmplitudeRatioUnit.DecibelVolt), - (AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value - 2.218487499, AmplitudeRatioUnit.DecibelVolt), + (AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value + -120, AmplitudeRatioUnit.DecibelVolt), + (AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value + -60, AmplitudeRatioUnit.DecibelVolt), + (AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatioUnit.DecibelVolt) => new AmplitudeRatio(_value + new QuantityValue(-2218487499, 1000000000, false), AmplitudeRatioUnit.DecibelVolt), // BaseUnit -> AmplitudeRatioUnit (AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelMicrovolt) => new AmplitudeRatio(_value + 120, AmplitudeRatioUnit.DecibelMicrovolt), (AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelMillivolt) => new AmplitudeRatio(_value + 60, AmplitudeRatioUnit.DecibelMillivolt), - (AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelUnloaded) => new AmplitudeRatio(_value + 2.218487499, AmplitudeRatioUnit.DecibelUnloaded), + (AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelUnloaded) => new AmplitudeRatio(_value + new QuantityValue(2218487499, 1000000000, false), AmplitudeRatioUnit.DecibelUnloaded), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 4779c595ef..5f3d73c905 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -56,7 +54,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -101,7 +99,7 @@ static Angle() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Angle(double value, AngleUnit unit) + public Angle(QuantityValue value, AngleUnit unit) { _value = value; _unit = unit; @@ -115,7 +113,7 @@ public Angle(double value, AngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Angle(double value, UnitSystem unitSystem) + public Angle(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -166,10 +164,10 @@ public Angle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,82 +192,82 @@ public Angle(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Arcminutes => As(AngleUnit.Arcminute); + public QuantityValue Arcminutes => As(AngleUnit.Arcminute); /// /// Gets a value of this quantity converted into /// - public double Arcseconds => As(AngleUnit.Arcsecond); + public QuantityValue Arcseconds => As(AngleUnit.Arcsecond); /// /// Gets a value of this quantity converted into /// - public double Centiradians => As(AngleUnit.Centiradian); + public QuantityValue Centiradians => As(AngleUnit.Centiradian); /// /// Gets a value of this quantity converted into /// - public double Deciradians => As(AngleUnit.Deciradian); + public QuantityValue Deciradians => As(AngleUnit.Deciradian); /// /// Gets a value of this quantity converted into /// - public double Degrees => As(AngleUnit.Degree); + public QuantityValue Degrees => As(AngleUnit.Degree); /// /// Gets a value of this quantity converted into /// - public double Gradians => As(AngleUnit.Gradian); + public QuantityValue Gradians => As(AngleUnit.Gradian); /// /// Gets a value of this quantity converted into /// - public double Microdegrees => As(AngleUnit.Microdegree); + public QuantityValue Microdegrees => As(AngleUnit.Microdegree); /// /// Gets a value of this quantity converted into /// - public double Microradians => As(AngleUnit.Microradian); + public QuantityValue Microradians => As(AngleUnit.Microradian); /// /// Gets a value of this quantity converted into /// - public double Millidegrees => As(AngleUnit.Millidegree); + public QuantityValue Millidegrees => As(AngleUnit.Millidegree); /// /// Gets a value of this quantity converted into /// - public double Milliradians => As(AngleUnit.Milliradian); + public QuantityValue Milliradians => As(AngleUnit.Milliradian); /// /// Gets a value of this quantity converted into /// - public double Nanodegrees => As(AngleUnit.Nanodegree); + public QuantityValue Nanodegrees => As(AngleUnit.Nanodegree); /// /// Gets a value of this quantity converted into /// - public double Nanoradians => As(AngleUnit.Nanoradian); + public QuantityValue Nanoradians => As(AngleUnit.Nanoradian); /// /// Gets a value of this quantity converted into /// - public double NatoMils => As(AngleUnit.NatoMil); + public QuantityValue NatoMils => As(AngleUnit.NatoMil); /// /// Gets a value of this quantity converted into /// - public double Radians => As(AngleUnit.Radian); + public QuantityValue Radians => As(AngleUnit.Radian); /// /// Gets a value of this quantity converted into /// - public double Revolutions => As(AngleUnit.Revolution); + public QuantityValue Revolutions => As(AngleUnit.Revolution); /// /// Gets a value of this quantity converted into /// - public double Tilt => As(AngleUnit.Tilt); + public QuantityValue Tilt => As(AngleUnit.Tilt); #endregion @@ -347,7 +345,7 @@ public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Angle FromArcminutes(double value) + public static Angle FromArcminutes(QuantityValue value) { return new Angle(value, AngleUnit.Arcminute); } @@ -355,7 +353,7 @@ public static Angle FromArcminutes(double value) /// /// Creates a from . /// - public static Angle FromArcseconds(double value) + public static Angle FromArcseconds(QuantityValue value) { return new Angle(value, AngleUnit.Arcsecond); } @@ -363,7 +361,7 @@ public static Angle FromArcseconds(double value) /// /// Creates a from . /// - public static Angle FromCentiradians(double value) + public static Angle FromCentiradians(QuantityValue value) { return new Angle(value, AngleUnit.Centiradian); } @@ -371,7 +369,7 @@ public static Angle FromCentiradians(double value) /// /// Creates a from . /// - public static Angle FromDeciradians(double value) + public static Angle FromDeciradians(QuantityValue value) { return new Angle(value, AngleUnit.Deciradian); } @@ -379,7 +377,7 @@ public static Angle FromDeciradians(double value) /// /// Creates a from . /// - public static Angle FromDegrees(double value) + public static Angle FromDegrees(QuantityValue value) { return new Angle(value, AngleUnit.Degree); } @@ -387,7 +385,7 @@ public static Angle FromDegrees(double value) /// /// Creates a from . /// - public static Angle FromGradians(double value) + public static Angle FromGradians(QuantityValue value) { return new Angle(value, AngleUnit.Gradian); } @@ -395,7 +393,7 @@ public static Angle FromGradians(double value) /// /// Creates a from . /// - public static Angle FromMicrodegrees(double value) + public static Angle FromMicrodegrees(QuantityValue value) { return new Angle(value, AngleUnit.Microdegree); } @@ -403,7 +401,7 @@ public static Angle FromMicrodegrees(double value) /// /// Creates a from . /// - public static Angle FromMicroradians(double value) + public static Angle FromMicroradians(QuantityValue value) { return new Angle(value, AngleUnit.Microradian); } @@ -411,7 +409,7 @@ public static Angle FromMicroradians(double value) /// /// Creates a from . /// - public static Angle FromMillidegrees(double value) + public static Angle FromMillidegrees(QuantityValue value) { return new Angle(value, AngleUnit.Millidegree); } @@ -419,7 +417,7 @@ public static Angle FromMillidegrees(double value) /// /// Creates a from . /// - public static Angle FromMilliradians(double value) + public static Angle FromMilliradians(QuantityValue value) { return new Angle(value, AngleUnit.Milliradian); } @@ -427,7 +425,7 @@ public static Angle FromMilliradians(double value) /// /// Creates a from . /// - public static Angle FromNanodegrees(double value) + public static Angle FromNanodegrees(QuantityValue value) { return new Angle(value, AngleUnit.Nanodegree); } @@ -435,7 +433,7 @@ public static Angle FromNanodegrees(double value) /// /// Creates a from . /// - public static Angle FromNanoradians(double value) + public static Angle FromNanoradians(QuantityValue value) { return new Angle(value, AngleUnit.Nanoradian); } @@ -443,7 +441,7 @@ public static Angle FromNanoradians(double value) /// /// Creates a from . /// - public static Angle FromNatoMils(double value) + public static Angle FromNatoMils(QuantityValue value) { return new Angle(value, AngleUnit.NatoMil); } @@ -451,7 +449,7 @@ public static Angle FromNatoMils(double value) /// /// Creates a from . /// - public static Angle FromRadians(double value) + public static Angle FromRadians(QuantityValue value) { return new Angle(value, AngleUnit.Radian); } @@ -459,7 +457,7 @@ public static Angle FromRadians(double value) /// /// Creates a from . /// - public static Angle FromRevolutions(double value) + public static Angle FromRevolutions(QuantityValue value) { return new Angle(value, AngleUnit.Revolution); } @@ -467,7 +465,7 @@ public static Angle FromRevolutions(double value) /// /// Creates a from . /// - public static Angle FromTilt(double value) + public static Angle FromTilt(QuantityValue value) { return new Angle(value, AngleUnit.Tilt); } @@ -478,7 +476,7 @@ public static Angle FromTilt(double value) /// Value to convert from. /// Unit to convert from. /// Angle unit value. - public static Angle From(double value, AngleUnit fromUnit) + public static Angle From(QuantityValue value, AngleUnit fromUnit) { return new Angle(value, fromUnit); } @@ -650,25 +648,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle } /// Get from multiplying value and . - public static Angle operator *(double left, Angle right) + public static Angle operator *(QuantityValue left, Angle right) { return new Angle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Angle operator *(Angle left, double right) + public static Angle operator *(Angle left, QuantityValue right) { return new Angle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Angle operator /(Angle left, double right) + public static Angle operator /(Angle left, QuantityValue right) { return new Angle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Angle left, Angle right) + public static QuantityValue operator /(Angle left, Angle right) { return left.Degrees / right.Degrees; } @@ -723,27 +721,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Angle left, Angle right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Angle other, Angle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Angle left, Angle right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Angle otherQuantity)) @@ -753,15 +744,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Angle other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +832,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -864,7 +852,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Angle other, Angle tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -877,7 +865,12 @@ public bool Equals(Angle other, Angle tolerance) /// A hash code for the current Angle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -888,7 +881,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AngleUnit unit) + public QuantityValue As(AngleUnit unit) { if (Unit == unit) return Value; @@ -897,7 +890,7 @@ public double As(AngleUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -912,7 +905,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); @@ -980,36 +973,36 @@ private bool TryToUnit(AngleUnit unit, [NotNullWhen(true)] out Angle? converted) // AngleUnit -> BaseUnit (AngleUnit.Arcminute, AngleUnit.Degree) => new Angle(_value / 60, AngleUnit.Degree), (AngleUnit.Arcsecond, AngleUnit.Degree) => new Angle(_value / 3600, AngleUnit.Degree), - (AngleUnit.Centiradian, AngleUnit.Degree) => new Angle((_value * 180 / Math.PI) * 1e-2d, AngleUnit.Degree), - (AngleUnit.Deciradian, AngleUnit.Degree) => new Angle((_value * 180 / Math.PI) * 1e-1d, AngleUnit.Degree), - (AngleUnit.Gradian, AngleUnit.Degree) => new Angle(_value * 0.9, AngleUnit.Degree), - (AngleUnit.Microdegree, AngleUnit.Degree) => new Angle((_value) * 1e-6d, AngleUnit.Degree), - (AngleUnit.Microradian, AngleUnit.Degree) => new Angle((_value * 180 / Math.PI) * 1e-6d, AngleUnit.Degree), - (AngleUnit.Millidegree, AngleUnit.Degree) => new Angle((_value) * 1e-3d, AngleUnit.Degree), - (AngleUnit.Milliradian, AngleUnit.Degree) => new Angle((_value * 180 / Math.PI) * 1e-3d, AngleUnit.Degree), - (AngleUnit.Nanodegree, AngleUnit.Degree) => new Angle((_value) * 1e-9d, AngleUnit.Degree), - (AngleUnit.Nanoradian, AngleUnit.Degree) => new Angle((_value * 180 / Math.PI) * 1e-9d, AngleUnit.Degree), - (AngleUnit.NatoMil, AngleUnit.Degree) => new Angle(_value * 9 / 160, AngleUnit.Degree), - (AngleUnit.Radian, AngleUnit.Degree) => new Angle(_value * 180 / Math.PI, AngleUnit.Degree), + (AngleUnit.Centiradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(180000000000000, 314159265358979, false), AngleUnit.Degree), + (AngleUnit.Deciradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(1800000000000000, 314159265358979, false), AngleUnit.Degree), + (AngleUnit.Gradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(9, 10, false), AngleUnit.Degree), + (AngleUnit.Microdegree, AngleUnit.Degree) => new Angle(_value / 1000000, AngleUnit.Degree), + (AngleUnit.Microradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(18000000000, 314159265358979, false), AngleUnit.Degree), + (AngleUnit.Millidegree, AngleUnit.Degree) => new Angle(_value / 1000, AngleUnit.Degree), + (AngleUnit.Milliradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(18000000000000, 314159265358979, false), AngleUnit.Degree), + (AngleUnit.Nanodegree, AngleUnit.Degree) => new Angle(_value / 1000000000, AngleUnit.Degree), + (AngleUnit.Nanoradian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(18000000, 314159265358979, false), AngleUnit.Degree), + (AngleUnit.NatoMil, AngleUnit.Degree) => new Angle(_value * new QuantityValue(9, 160, false), AngleUnit.Degree), + (AngleUnit.Radian, AngleUnit.Degree) => new Angle(_value * new QuantityValue(18000000000000000, 314159265358979, false), AngleUnit.Degree), (AngleUnit.Revolution, AngleUnit.Degree) => new Angle(_value * 360, AngleUnit.Degree), - (AngleUnit.Tilt, AngleUnit.Degree) => new Angle(Math.Asin(_value) * 180 / Math.PI, AngleUnit.Degree), + (AngleUnit.Tilt, AngleUnit.Degree) => new Angle(QuantityValue.FromDoubleRounded(Math.Asin((_value).ToDouble())) * new QuantityValue(18000000000000000, 314159265358979, false), AngleUnit.Degree), // BaseUnit -> AngleUnit (AngleUnit.Degree, AngleUnit.Arcminute) => new Angle(_value * 60, AngleUnit.Arcminute), (AngleUnit.Degree, AngleUnit.Arcsecond) => new Angle(_value * 3600, AngleUnit.Arcsecond), - (AngleUnit.Degree, AngleUnit.Centiradian) => new Angle((_value / 180 * Math.PI) / 1e-2d, AngleUnit.Centiradian), - (AngleUnit.Degree, AngleUnit.Deciradian) => new Angle((_value / 180 * Math.PI) / 1e-1d, AngleUnit.Deciradian), - (AngleUnit.Degree, AngleUnit.Gradian) => new Angle(_value / 0.9, AngleUnit.Gradian), - (AngleUnit.Degree, AngleUnit.Microdegree) => new Angle((_value) / 1e-6d, AngleUnit.Microdegree), - (AngleUnit.Degree, AngleUnit.Microradian) => new Angle((_value / 180 * Math.PI) / 1e-6d, AngleUnit.Microradian), - (AngleUnit.Degree, AngleUnit.Millidegree) => new Angle((_value) / 1e-3d, AngleUnit.Millidegree), - (AngleUnit.Degree, AngleUnit.Milliradian) => new Angle((_value / 180 * Math.PI) / 1e-3d, AngleUnit.Milliradian), - (AngleUnit.Degree, AngleUnit.Nanodegree) => new Angle((_value) / 1e-9d, AngleUnit.Nanodegree), - (AngleUnit.Degree, AngleUnit.Nanoradian) => new Angle((_value / 180 * Math.PI) / 1e-9d, AngleUnit.Nanoradian), - (AngleUnit.Degree, AngleUnit.NatoMil) => new Angle(_value * 160 / 9, AngleUnit.NatoMil), - (AngleUnit.Degree, AngleUnit.Radian) => new Angle(_value / 180 * Math.PI, AngleUnit.Radian), + (AngleUnit.Degree, AngleUnit.Centiradian) => new Angle(_value * new QuantityValue(314159265358979, 180000000000000, false), AngleUnit.Centiradian), + (AngleUnit.Degree, AngleUnit.Deciradian) => new Angle(_value * new QuantityValue(314159265358979, 1800000000000000, false), AngleUnit.Deciradian), + (AngleUnit.Degree, AngleUnit.Gradian) => new Angle(_value * new QuantityValue(10, 9, false), AngleUnit.Gradian), + (AngleUnit.Degree, AngleUnit.Microdegree) => new Angle(_value * 1000000, AngleUnit.Microdegree), + (AngleUnit.Degree, AngleUnit.Microradian) => new Angle(_value * new QuantityValue(314159265358979, 18000000000, false), AngleUnit.Microradian), + (AngleUnit.Degree, AngleUnit.Millidegree) => new Angle(_value * 1000, AngleUnit.Millidegree), + (AngleUnit.Degree, AngleUnit.Milliradian) => new Angle(_value * new QuantityValue(314159265358979, 18000000000000, false), AngleUnit.Milliradian), + (AngleUnit.Degree, AngleUnit.Nanodegree) => new Angle(_value * 1000000000, AngleUnit.Nanodegree), + (AngleUnit.Degree, AngleUnit.Nanoradian) => new Angle(_value * new QuantityValue(314159265358979, 18000000, false), AngleUnit.Nanoradian), + (AngleUnit.Degree, AngleUnit.NatoMil) => new Angle(_value * new QuantityValue(160, 9, false), AngleUnit.NatoMil), + (AngleUnit.Degree, AngleUnit.Radian) => new Angle(_value * new QuantityValue(314159265358979, 18000000000000000, false), AngleUnit.Radian), (AngleUnit.Degree, AngleUnit.Revolution) => new Angle(_value / 360, AngleUnit.Revolution), - (AngleUnit.Degree, AngleUnit.Tilt) => new Angle(Math.Sin(_value / 180 * Math.PI), AngleUnit.Tilt), + (AngleUnit.Degree, AngleUnit.Tilt) => new Angle(QuantityValue.FromDoubleRounded(Math.Sin((_value * new QuantityValue(314159265358979, 18000000000000000, false)).ToDouble())), AngleUnit.Tilt), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 67a25cbe11..80224d8275 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,7 +81,7 @@ static ApparentEnergy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ApparentEnergy(double value, ApparentEnergyUnit unit) + public ApparentEnergy(QuantityValue value, ApparentEnergyUnit unit) { _value = value; _unit = unit; @@ -94,7 +95,7 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentEnergy(double value, UnitSystem unitSystem) + public ApparentEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -145,10 +146,10 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,17 +174,17 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); + public QuantityValue KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); /// /// Gets a value of this quantity converted into /// - public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); + public QuantityValue MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); /// /// Gets a value of this quantity converted into /// - public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); + public QuantityValue VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); #endregion @@ -235,7 +236,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static ApparentEnergy FromKilovoltampereHours(double value) + public static ApparentEnergy FromKilovoltampereHours(QuantityValue value) { return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour); } @@ -243,7 +244,7 @@ public static ApparentEnergy FromKilovoltampereHours(double value) /// /// Creates a from . /// - public static ApparentEnergy FromMegavoltampereHours(double value) + public static ApparentEnergy FromMegavoltampereHours(QuantityValue value) { return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour); } @@ -251,7 +252,7 @@ public static ApparentEnergy FromMegavoltampereHours(double value) /// /// Creates a from . /// - public static ApparentEnergy FromVoltampereHours(double value) + public static ApparentEnergy FromVoltampereHours(QuantityValue value) { return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour); } @@ -262,7 +263,7 @@ public static ApparentEnergy FromVoltampereHours(double value) /// Value to convert from. /// Unit to convert from. /// ApparentEnergy unit value. - public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit) + public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit) { return new ApparentEnergy(value, fromUnit); } @@ -434,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentEnergy operator *(double left, ApparentEnergy right) + public static ApparentEnergy operator *(QuantityValue left, ApparentEnergy right) { return new ApparentEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentEnergy operator *(ApparentEnergy left, double right) + public static ApparentEnergy operator *(ApparentEnergy left, QuantityValue right) { return new ApparentEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentEnergy operator /(ApparentEnergy left, double right) + public static ApparentEnergy operator /(ApparentEnergy left, QuantityValue right) { return new ApparentEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ApparentEnergy left, ApparentEnergy right) + public static QuantityValue operator /(ApparentEnergy left, ApparentEnergy right) { return left.VoltampereHours / right.VoltampereHours; } @@ -485,27 +486,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ApparentEnergy left, ApparentEnergy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ApparentEnergy left, ApparentEnergy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ApparentEnergy otherQuantity)) @@ -515,15 +509,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ApparentEnergy other, ApparentEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ApparentEnergy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -606,10 +597,10 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -626,7 +617,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ApparentEnergy other, ApparentEnergy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -639,7 +630,12 @@ public bool Equals(ApparentEnergy other, ApparentEnergy tolerance) /// A hash code for the current ApparentEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -650,7 +646,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentEnergyUnit unit) + public QuantityValue As(ApparentEnergyUnit unit) { if (Unit == unit) return Value; @@ -659,7 +655,7 @@ public double As(ApparentEnergyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,7 +670,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); @@ -740,12 +736,12 @@ private bool TryToUnit(ApparentEnergyUnit unit, [NotNullWhen(true)] out Apparent ApparentEnergy? convertedOrNull = (Unit, unit) switch { // ApparentEnergyUnit -> BaseUnit - (ApparentEnergyUnit.KilovoltampereHour, ApparentEnergyUnit.VoltampereHour) => new ApparentEnergy((_value) * 1e3d, ApparentEnergyUnit.VoltampereHour), - (ApparentEnergyUnit.MegavoltampereHour, ApparentEnergyUnit.VoltampereHour) => new ApparentEnergy((_value) * 1e6d, ApparentEnergyUnit.VoltampereHour), + (ApparentEnergyUnit.KilovoltampereHour, ApparentEnergyUnit.VoltampereHour) => new ApparentEnergy(_value * 1000, ApparentEnergyUnit.VoltampereHour), + (ApparentEnergyUnit.MegavoltampereHour, ApparentEnergyUnit.VoltampereHour) => new ApparentEnergy(_value * 1000000, ApparentEnergyUnit.VoltampereHour), // BaseUnit -> ApparentEnergyUnit - (ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.KilovoltampereHour) => new ApparentEnergy((_value) / 1e3d, ApparentEnergyUnit.KilovoltampereHour), - (ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.MegavoltampereHour) => new ApparentEnergy((_value) / 1e6d, ApparentEnergyUnit.MegavoltampereHour), + (ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.KilovoltampereHour) => new ApparentEnergy(_value / 1000, ApparentEnergyUnit.KilovoltampereHour), + (ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.MegavoltampereHour) => new ApparentEnergy(_value / 1000000, ApparentEnergyUnit.MegavoltampereHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 18a87f8927..6dc7f2ddcb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static ApparentPower() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ApparentPower(double value, ApparentPowerUnit unit) + public ApparentPower(QuantityValue value, ApparentPowerUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public ApparentPower(double value, ApparentPowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentPower(double value, UnitSystem unitSystem) + public ApparentPower(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,32 +177,32 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); + public QuantityValue Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); /// /// Gets a value of this quantity converted into /// - public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); + public QuantityValue Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); /// /// Gets a value of this quantity converted into /// - public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); + public QuantityValue Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); /// /// Gets a value of this quantity converted into /// - public double Microvoltamperes => As(ApparentPowerUnit.Microvoltampere); + public QuantityValue Microvoltamperes => As(ApparentPowerUnit.Microvoltampere); /// /// Gets a value of this quantity converted into /// - public double Millivoltamperes => As(ApparentPowerUnit.Millivoltampere); + public QuantityValue Millivoltamperes => As(ApparentPowerUnit.Millivoltampere); /// /// Gets a value of this quantity converted into /// - public double Voltamperes => As(ApparentPowerUnit.Voltampere); + public QuantityValue Voltamperes => As(ApparentPowerUnit.Voltampere); #endregion @@ -259,7 +260,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static ApparentPower FromGigavoltamperes(double value) + public static ApparentPower FromGigavoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere); } @@ -267,7 +268,7 @@ public static ApparentPower FromGigavoltamperes(double value) /// /// Creates a from . /// - public static ApparentPower FromKilovoltamperes(double value) + public static ApparentPower FromKilovoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere); } @@ -275,7 +276,7 @@ public static ApparentPower FromKilovoltamperes(double value) /// /// Creates a from . /// - public static ApparentPower FromMegavoltamperes(double value) + public static ApparentPower FromMegavoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Megavoltampere); } @@ -283,7 +284,7 @@ public static ApparentPower FromMegavoltamperes(double value) /// /// Creates a from . /// - public static ApparentPower FromMicrovoltamperes(double value) + public static ApparentPower FromMicrovoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Microvoltampere); } @@ -291,7 +292,7 @@ public static ApparentPower FromMicrovoltamperes(double value) /// /// Creates a from . /// - public static ApparentPower FromMillivoltamperes(double value) + public static ApparentPower FromMillivoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Millivoltampere); } @@ -299,7 +300,7 @@ public static ApparentPower FromMillivoltamperes(double value) /// /// Creates a from . /// - public static ApparentPower FromVoltamperes(double value) + public static ApparentPower FromVoltamperes(QuantityValue value) { return new ApparentPower(value, ApparentPowerUnit.Voltampere); } @@ -310,7 +311,7 @@ public static ApparentPower FromVoltamperes(double value) /// Value to convert from. /// Unit to convert from. /// ApparentPower unit value. - public static ApparentPower From(double value, ApparentPowerUnit fromUnit) + public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit) { return new ApparentPower(value, fromUnit); } @@ -482,25 +483,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentPower operator *(double left, ApparentPower right) + public static ApparentPower operator *(QuantityValue left, ApparentPower right) { return new ApparentPower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentPower operator *(ApparentPower left, double right) + public static ApparentPower operator *(ApparentPower left, QuantityValue right) { return new ApparentPower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentPower operator /(ApparentPower left, double right) + public static ApparentPower operator /(ApparentPower left, QuantityValue right) { return new ApparentPower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ApparentPower left, ApparentPower right) + public static QuantityValue operator /(ApparentPower left, ApparentPower right) { return left.Voltamperes / right.Voltamperes; } @@ -533,27 +534,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ApparentPower left, ApparentPower right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ApparentPower left, ApparentPower right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ApparentPower otherQuantity)) @@ -563,15 +557,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ApparentPower other, ApparentPower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ApparentPower other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -654,10 +645,10 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -674,7 +665,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ApparentPower other, ApparentPower tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -687,7 +678,12 @@ public bool Equals(ApparentPower other, ApparentPower tolerance) /// A hash code for the current ApparentPower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -698,7 +694,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentPowerUnit unit) + public QuantityValue As(ApparentPowerUnit unit) { if (Unit == unit) return Value; @@ -707,7 +703,7 @@ public double As(ApparentPowerUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -722,7 +718,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); @@ -788,18 +784,18 @@ private bool TryToUnit(ApparentPowerUnit unit, [NotNullWhen(true)] out ApparentP ApparentPower? convertedOrNull = (Unit, unit) switch { // ApparentPowerUnit -> BaseUnit - (ApparentPowerUnit.Gigavoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower((_value) * 1e9d, ApparentPowerUnit.Voltampere), - (ApparentPowerUnit.Kilovoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower((_value) * 1e3d, ApparentPowerUnit.Voltampere), - (ApparentPowerUnit.Megavoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower((_value) * 1e6d, ApparentPowerUnit.Voltampere), - (ApparentPowerUnit.Microvoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower((_value) * 1e-6d, ApparentPowerUnit.Voltampere), - (ApparentPowerUnit.Millivoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower((_value) * 1e-3d, ApparentPowerUnit.Voltampere), + (ApparentPowerUnit.Gigavoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower(_value * 1000000000, ApparentPowerUnit.Voltampere), + (ApparentPowerUnit.Kilovoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower(_value * 1000, ApparentPowerUnit.Voltampere), + (ApparentPowerUnit.Megavoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower(_value * 1000000, ApparentPowerUnit.Voltampere), + (ApparentPowerUnit.Microvoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower(_value / 1000000, ApparentPowerUnit.Voltampere), + (ApparentPowerUnit.Millivoltampere, ApparentPowerUnit.Voltampere) => new ApparentPower(_value / 1000, ApparentPowerUnit.Voltampere), // BaseUnit -> ApparentPowerUnit - (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Gigavoltampere) => new ApparentPower((_value) / 1e9d, ApparentPowerUnit.Gigavoltampere), - (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Kilovoltampere) => new ApparentPower((_value) / 1e3d, ApparentPowerUnit.Kilovoltampere), - (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Megavoltampere) => new ApparentPower((_value) / 1e6d, ApparentPowerUnit.Megavoltampere), - (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Microvoltampere) => new ApparentPower((_value) / 1e-6d, ApparentPowerUnit.Microvoltampere), - (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Millivoltampere) => new ApparentPower((_value) / 1e-3d, ApparentPowerUnit.Millivoltampere), + (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Gigavoltampere) => new ApparentPower(_value / 1000000000, ApparentPowerUnit.Gigavoltampere), + (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Kilovoltampere) => new ApparentPower(_value / 1000, ApparentPowerUnit.Kilovoltampere), + (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Megavoltampere) => new ApparentPower(_value / 1000000, ApparentPowerUnit.Megavoltampere), + (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Microvoltampere) => new ApparentPower(_value * 1000000, ApparentPowerUnit.Microvoltampere), + (ApparentPowerUnit.Voltampere, ApparentPowerUnit.Millivoltampere) => new ApparentPower(_value * 1000, ApparentPowerUnit.Millivoltampere), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 4dbb6648d8..6958a7a7a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -46,6 +44,7 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IDivisionOperators, + IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, @@ -53,8 +52,10 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, #endif IComparable, @@ -67,7 +68,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -110,7 +111,7 @@ static Area() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Area(double value, AreaUnit unit) + public Area(QuantityValue value, AreaUnit unit) { _value = value; _unit = unit; @@ -124,7 +125,7 @@ public Area(double value, AreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Area(double value, UnitSystem unitSystem) + public Area(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -175,10 +176,10 @@ public Area(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -203,72 +204,72 @@ public Area(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Acres => As(AreaUnit.Acre); + public QuantityValue Acres => As(AreaUnit.Acre); /// /// Gets a value of this quantity converted into /// - public double Hectares => As(AreaUnit.Hectare); + public QuantityValue Hectares => As(AreaUnit.Hectare); /// /// Gets a value of this quantity converted into /// - public double SquareCentimeters => As(AreaUnit.SquareCentimeter); + public QuantityValue SquareCentimeters => As(AreaUnit.SquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double SquareDecimeters => As(AreaUnit.SquareDecimeter); + public QuantityValue SquareDecimeters => As(AreaUnit.SquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double SquareFeet => As(AreaUnit.SquareFoot); + public QuantityValue SquareFeet => As(AreaUnit.SquareFoot); /// /// Gets a value of this quantity converted into /// - public double SquareInches => As(AreaUnit.SquareInch); + public QuantityValue SquareInches => As(AreaUnit.SquareInch); /// /// Gets a value of this quantity converted into /// - public double SquareKilometers => As(AreaUnit.SquareKilometer); + public QuantityValue SquareKilometers => As(AreaUnit.SquareKilometer); /// /// Gets a value of this quantity converted into /// - public double SquareMeters => As(AreaUnit.SquareMeter); + public QuantityValue SquareMeters => As(AreaUnit.SquareMeter); /// /// Gets a value of this quantity converted into /// - public double SquareMicrometers => As(AreaUnit.SquareMicrometer); + public QuantityValue SquareMicrometers => As(AreaUnit.SquareMicrometer); /// /// Gets a value of this quantity converted into /// - public double SquareMiles => As(AreaUnit.SquareMile); + public QuantityValue SquareMiles => As(AreaUnit.SquareMile); /// /// Gets a value of this quantity converted into /// - public double SquareMillimeters => As(AreaUnit.SquareMillimeter); + public QuantityValue SquareMillimeters => As(AreaUnit.SquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); + public QuantityValue SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); /// /// Gets a value of this quantity converted into /// - public double SquareYards => As(AreaUnit.SquareYard); + public QuantityValue SquareYards => As(AreaUnit.SquareYard); /// /// Gets a value of this quantity converted into /// - public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); + public QuantityValue UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); #endregion @@ -342,7 +343,7 @@ public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Area FromAcres(double value) + public static Area FromAcres(QuantityValue value) { return new Area(value, AreaUnit.Acre); } @@ -350,7 +351,7 @@ public static Area FromAcres(double value) /// /// Creates a from . /// - public static Area FromHectares(double value) + public static Area FromHectares(QuantityValue value) { return new Area(value, AreaUnit.Hectare); } @@ -358,7 +359,7 @@ public static Area FromHectares(double value) /// /// Creates a from . /// - public static Area FromSquareCentimeters(double value) + public static Area FromSquareCentimeters(QuantityValue value) { return new Area(value, AreaUnit.SquareCentimeter); } @@ -366,7 +367,7 @@ public static Area FromSquareCentimeters(double value) /// /// Creates a from . /// - public static Area FromSquareDecimeters(double value) + public static Area FromSquareDecimeters(QuantityValue value) { return new Area(value, AreaUnit.SquareDecimeter); } @@ -374,7 +375,7 @@ public static Area FromSquareDecimeters(double value) /// /// Creates a from . /// - public static Area FromSquareFeet(double value) + public static Area FromSquareFeet(QuantityValue value) { return new Area(value, AreaUnit.SquareFoot); } @@ -382,7 +383,7 @@ public static Area FromSquareFeet(double value) /// /// Creates a from . /// - public static Area FromSquareInches(double value) + public static Area FromSquareInches(QuantityValue value) { return new Area(value, AreaUnit.SquareInch); } @@ -390,7 +391,7 @@ public static Area FromSquareInches(double value) /// /// Creates a from . /// - public static Area FromSquareKilometers(double value) + public static Area FromSquareKilometers(QuantityValue value) { return new Area(value, AreaUnit.SquareKilometer); } @@ -398,7 +399,7 @@ public static Area FromSquareKilometers(double value) /// /// Creates a from . /// - public static Area FromSquareMeters(double value) + public static Area FromSquareMeters(QuantityValue value) { return new Area(value, AreaUnit.SquareMeter); } @@ -406,7 +407,7 @@ public static Area FromSquareMeters(double value) /// /// Creates a from . /// - public static Area FromSquareMicrometers(double value) + public static Area FromSquareMicrometers(QuantityValue value) { return new Area(value, AreaUnit.SquareMicrometer); } @@ -414,7 +415,7 @@ public static Area FromSquareMicrometers(double value) /// /// Creates a from . /// - public static Area FromSquareMiles(double value) + public static Area FromSquareMiles(QuantityValue value) { return new Area(value, AreaUnit.SquareMile); } @@ -422,7 +423,7 @@ public static Area FromSquareMiles(double value) /// /// Creates a from . /// - public static Area FromSquareMillimeters(double value) + public static Area FromSquareMillimeters(QuantityValue value) { return new Area(value, AreaUnit.SquareMillimeter); } @@ -430,7 +431,7 @@ public static Area FromSquareMillimeters(double value) /// /// Creates a from . /// - public static Area FromSquareNauticalMiles(double value) + public static Area FromSquareNauticalMiles(QuantityValue value) { return new Area(value, AreaUnit.SquareNauticalMile); } @@ -438,7 +439,7 @@ public static Area FromSquareNauticalMiles(double value) /// /// Creates a from . /// - public static Area FromSquareYards(double value) + public static Area FromSquareYards(QuantityValue value) { return new Area(value, AreaUnit.SquareYard); } @@ -446,7 +447,7 @@ public static Area FromSquareYards(double value) /// /// Creates a from . /// - public static Area FromUsSurveySquareFeet(double value) + public static Area FromUsSurveySquareFeet(QuantityValue value) { return new Area(value, AreaUnit.UsSurveySquareFoot); } @@ -457,7 +458,7 @@ public static Area FromUsSurveySquareFeet(double value) /// Value to convert from. /// Unit to convert from. /// Area unit value. - public static Area From(double value, AreaUnit fromUnit) + public static Area From(QuantityValue value, AreaUnit fromUnit) { return new Area(value, fromUnit); } @@ -629,25 +630,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU } /// Get from multiplying value and . - public static Area operator *(double left, Area right) + public static Area operator *(QuantityValue left, Area right) { return new Area(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Area operator *(Area left, double right) + public static Area operator *(Area left, QuantityValue right) { return new Area(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Area operator /(Area left, double right) + public static Area operator /(Area left, QuantityValue right) { return new Area(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Area left, Area right) + public static QuantityValue operator /(Area left, Area right) { return left.SquareMeters / right.SquareMeters; } @@ -660,7 +661,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU /// The corresponding inverse quantity, . public ReciprocalArea Inverse() { - return SquareMeters == 0.0 ? ReciprocalArea.Zero : ReciprocalArea.FromInverseSquareMeters(1 / SquareMeters); + return ReciprocalArea.FromInverseSquareMeters(QuantityValue.Inverse(SquareMeters)); } /// Get from / . @@ -687,6 +688,12 @@ public ReciprocalArea Inverse() return KinematicViscosity.FromSquareMetersPerSecond(area.SquareMeters / duration.Seconds); } + /// Get from * . + public static Length operator *(Area area, ReciprocalLength reciprocalLength) + { + return Length.FromMeters(area.SquareMeters * reciprocalLength.InverseMeters); + } + /// Get from / . public static Length operator /(Area area, Length length) { @@ -729,6 +736,12 @@ public ReciprocalArea Inverse() return Ratio.FromDecimalFractions(area.SquareMeters * reciprocalArea.InverseSquareMeters); } + /// Get from / . + public static ReciprocalLength operator /(Area area, Volume volume) + { + return ReciprocalLength.FromInverseMeters(area.SquareMeters / volume.CubicMeters); + } + /// Get from * . public static Torque operator *(Area area, ForcePerLength forcePerLength) { @@ -741,6 +754,12 @@ public ReciprocalArea Inverse() return Volume.FromCubicMeters(area.SquareMeters * length.Meters); } + /// Get from / . + public static Volume operator /(Area area, ReciprocalLength reciprocalLength) + { + return Volume.FromCubicMeters(area.SquareMeters / reciprocalLength.InverseMeters); + } + /// Get from * . public static VolumeFlow operator *(Area area, Speed speed) { @@ -775,27 +794,20 @@ public ReciprocalArea Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Area left, Area right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Area other, Area tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Area left, Area right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Area otherQuantity)) @@ -805,15 +817,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Area other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -896,10 +905,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -916,7 +925,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Area other, Area tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -929,7 +938,12 @@ public bool Equals(Area other, Area tolerance) /// A hash code for the current Area. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -940,7 +954,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaUnit unit) + public QuantityValue As(AreaUnit unit) { if (Unit == unit) return Value; @@ -949,7 +963,7 @@ public double As(AreaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -964,7 +978,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); @@ -1030,34 +1044,34 @@ private bool TryToUnit(AreaUnit unit, [NotNullWhen(true)] out Area? converted) Area? convertedOrNull = (Unit, unit) switch { // AreaUnit -> BaseUnit - (AreaUnit.Acre, AreaUnit.SquareMeter) => new Area(_value * 4046.8564224, AreaUnit.SquareMeter), - (AreaUnit.Hectare, AreaUnit.SquareMeter) => new Area(_value * 1e4, AreaUnit.SquareMeter), - (AreaUnit.SquareCentimeter, AreaUnit.SquareMeter) => new Area(_value * 1e-4, AreaUnit.SquareMeter), - (AreaUnit.SquareDecimeter, AreaUnit.SquareMeter) => new Area(_value * 1e-2, AreaUnit.SquareMeter), - (AreaUnit.SquareFoot, AreaUnit.SquareMeter) => new Area(_value * 9.290304e-2, AreaUnit.SquareMeter), - (AreaUnit.SquareInch, AreaUnit.SquareMeter) => new Area(_value * 0.00064516, AreaUnit.SquareMeter), - (AreaUnit.SquareKilometer, AreaUnit.SquareMeter) => new Area(_value * 1e6, AreaUnit.SquareMeter), - (AreaUnit.SquareMicrometer, AreaUnit.SquareMeter) => new Area(_value * 1e-12, AreaUnit.SquareMeter), - (AreaUnit.SquareMile, AreaUnit.SquareMeter) => new Area(_value * 1609.344 * 1609.344, AreaUnit.SquareMeter), - (AreaUnit.SquareMillimeter, AreaUnit.SquareMeter) => new Area(_value * 1e-6, AreaUnit.SquareMeter), + (AreaUnit.Acre, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(316160658, 78125, false), AreaUnit.SquareMeter), + (AreaUnit.Hectare, AreaUnit.SquareMeter) => new Area(_value * 10000, AreaUnit.SquareMeter), + (AreaUnit.SquareCentimeter, AreaUnit.SquareMeter) => new Area(_value / 10000, AreaUnit.SquareMeter), + (AreaUnit.SquareDecimeter, AreaUnit.SquareMeter) => new Area(_value / 100, AreaUnit.SquareMeter), + (AreaUnit.SquareFoot, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(145161, 1562500, false), AreaUnit.SquareMeter), + (AreaUnit.SquareInch, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(16129, 25000000, false), AreaUnit.SquareMeter), + (AreaUnit.SquareKilometer, AreaUnit.SquareMeter) => new Area(_value * 1000000, AreaUnit.SquareMeter), + (AreaUnit.SquareMicrometer, AreaUnit.SquareMeter) => new Area(_value / 1000000000000, AreaUnit.SquareMeter), + (AreaUnit.SquareMile, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(40468564224, 15625, false), AreaUnit.SquareMeter), + (AreaUnit.SquareMillimeter, AreaUnit.SquareMeter) => new Area(_value / 1000000, AreaUnit.SquareMeter), (AreaUnit.SquareNauticalMile, AreaUnit.SquareMeter) => new Area(_value * 3429904, AreaUnit.SquareMeter), - (AreaUnit.SquareYard, AreaUnit.SquareMeter) => new Area(_value * 0.9144 * 0.9144, AreaUnit.SquareMeter), - (AreaUnit.UsSurveySquareFoot, AreaUnit.SquareMeter) => new Area(_value * (1200.0 / 3937.0) * (1200.0 / 3937.0), AreaUnit.SquareMeter), + (AreaUnit.SquareYard, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(1306449, 1562500, false), AreaUnit.SquareMeter), + (AreaUnit.UsSurveySquareFoot, AreaUnit.SquareMeter) => new Area(_value * new QuantityValue(1440000, 15499969, false), AreaUnit.SquareMeter), // BaseUnit -> AreaUnit - (AreaUnit.SquareMeter, AreaUnit.Acre) => new Area(_value / 4046.8564224, AreaUnit.Acre), - (AreaUnit.SquareMeter, AreaUnit.Hectare) => new Area(_value / 1e4, AreaUnit.Hectare), - (AreaUnit.SquareMeter, AreaUnit.SquareCentimeter) => new Area(_value / 1e-4, AreaUnit.SquareCentimeter), - (AreaUnit.SquareMeter, AreaUnit.SquareDecimeter) => new Area(_value / 1e-2, AreaUnit.SquareDecimeter), - (AreaUnit.SquareMeter, AreaUnit.SquareFoot) => new Area(_value / 9.290304e-2, AreaUnit.SquareFoot), - (AreaUnit.SquareMeter, AreaUnit.SquareInch) => new Area(_value / 0.00064516, AreaUnit.SquareInch), - (AreaUnit.SquareMeter, AreaUnit.SquareKilometer) => new Area(_value / 1e6, AreaUnit.SquareKilometer), - (AreaUnit.SquareMeter, AreaUnit.SquareMicrometer) => new Area(_value / 1e-12, AreaUnit.SquareMicrometer), - (AreaUnit.SquareMeter, AreaUnit.SquareMile) => new Area(_value / 1609.344 / 1609.344, AreaUnit.SquareMile), - (AreaUnit.SquareMeter, AreaUnit.SquareMillimeter) => new Area(_value / 1e-6, AreaUnit.SquareMillimeter), + (AreaUnit.SquareMeter, AreaUnit.Acre) => new Area(_value * new QuantityValue(78125, 316160658, false), AreaUnit.Acre), + (AreaUnit.SquareMeter, AreaUnit.Hectare) => new Area(_value / 10000, AreaUnit.Hectare), + (AreaUnit.SquareMeter, AreaUnit.SquareCentimeter) => new Area(_value * 10000, AreaUnit.SquareCentimeter), + (AreaUnit.SquareMeter, AreaUnit.SquareDecimeter) => new Area(_value * 100, AreaUnit.SquareDecimeter), + (AreaUnit.SquareMeter, AreaUnit.SquareFoot) => new Area(_value * new QuantityValue(1562500, 145161, false), AreaUnit.SquareFoot), + (AreaUnit.SquareMeter, AreaUnit.SquareInch) => new Area(_value * new QuantityValue(25000000, 16129, false), AreaUnit.SquareInch), + (AreaUnit.SquareMeter, AreaUnit.SquareKilometer) => new Area(_value / 1000000, AreaUnit.SquareKilometer), + (AreaUnit.SquareMeter, AreaUnit.SquareMicrometer) => new Area(_value * 1000000000000, AreaUnit.SquareMicrometer), + (AreaUnit.SquareMeter, AreaUnit.SquareMile) => new Area(_value * new QuantityValue(15625, 40468564224, false), AreaUnit.SquareMile), + (AreaUnit.SquareMeter, AreaUnit.SquareMillimeter) => new Area(_value * 1000000, AreaUnit.SquareMillimeter), (AreaUnit.SquareMeter, AreaUnit.SquareNauticalMile) => new Area(_value / 3429904, AreaUnit.SquareNauticalMile), - (AreaUnit.SquareMeter, AreaUnit.SquareYard) => new Area(_value / 0.9144 / 0.9144, AreaUnit.SquareYard), - (AreaUnit.SquareMeter, AreaUnit.UsSurveySquareFoot) => new Area(_value / (1200.0 / 3937.0) / (1200.0 / 3937.0), AreaUnit.UsSurveySquareFoot), + (AreaUnit.SquareMeter, AreaUnit.SquareYard) => new Area(_value * new QuantityValue(1562500, 1306449, false), AreaUnit.SquareYard), + (AreaUnit.SquareMeter, AreaUnit.UsSurveySquareFoot) => new Area(_value * new QuantityValue(15499969, 1440000, false), AreaUnit.UsSurveySquareFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index a75fc2a7c7..b0cfbed0ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,7 +84,7 @@ static AreaDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public AreaDensity(double value, AreaDensityUnit unit) + public AreaDensity(QuantityValue value, AreaDensityUnit unit) { _value = value; _unit = unit; @@ -100,7 +98,7 @@ public AreaDensity(double value, AreaDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaDensity(double value, UnitSystem unitSystem) + public AreaDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -151,10 +149,10 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,17 +177,17 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramsPerSquareMeter => As(AreaDensityUnit.GramPerSquareMeter); + public QuantityValue GramsPerSquareMeter => As(AreaDensityUnit.GramPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); + public QuantityValue KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); + public QuantityValue MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); #endregion @@ -241,7 +239,7 @@ public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static AreaDensity FromGramsPerSquareMeter(double value) + public static AreaDensity FromGramsPerSquareMeter(QuantityValue value) { return new AreaDensity(value, AreaDensityUnit.GramPerSquareMeter); } @@ -249,7 +247,7 @@ public static AreaDensity FromGramsPerSquareMeter(double value) /// /// Creates a from . /// - public static AreaDensity FromKilogramsPerSquareMeter(double value) + public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue value) { return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter); } @@ -257,7 +255,7 @@ public static AreaDensity FromKilogramsPerSquareMeter(double value) /// /// Creates a from . /// - public static AreaDensity FromMilligramsPerSquareMeter(double value) + public static AreaDensity FromMilligramsPerSquareMeter(QuantityValue value) { return new AreaDensity(value, AreaDensityUnit.MilligramPerSquareMeter); } @@ -268,7 +266,7 @@ public static AreaDensity FromMilligramsPerSquareMeter(double value) /// Value to convert from. /// Unit to convert from. /// AreaDensity unit value. - public static AreaDensity From(double value, AreaDensityUnit fromUnit) + public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit) { return new AreaDensity(value, fromUnit); } @@ -440,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD } /// Get from multiplying value and . - public static AreaDensity operator *(double left, AreaDensity right) + public static AreaDensity operator *(QuantityValue left, AreaDensity right) { return new AreaDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaDensity operator *(AreaDensity left, double right) + public static AreaDensity operator *(AreaDensity left, QuantityValue right) { return new AreaDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaDensity operator /(AreaDensity left, double right) + public static AreaDensity operator /(AreaDensity left, QuantityValue right) { return new AreaDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AreaDensity left, AreaDensity right) + public static QuantityValue operator /(AreaDensity left, AreaDensity right) { return left.KilogramsPerSquareMeter / right.KilogramsPerSquareMeter; } @@ -501,27 +499,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(AreaDensity left, AreaDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaDensity other, AreaDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(AreaDensity left, AreaDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is AreaDensity otherQuantity)) @@ -531,15 +522,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(AreaDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -622,10 +610,10 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -642,7 +630,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AreaDensity other, AreaDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -655,7 +643,12 @@ public bool Equals(AreaDensity other, AreaDensity tolerance) /// A hash code for the current AreaDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -666,7 +659,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaDensityUnit unit) + public QuantityValue As(AreaDensityUnit unit) { if (Unit == unit) return Value; @@ -675,7 +668,7 @@ public double As(AreaDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -690,7 +683,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 840e9b6d03..d6c4c1b59c 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -90,7 +88,7 @@ static AreaMomentOfInertia() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) + public AreaMomentOfInertia(QuantityValue value, AreaMomentOfInertiaUnit unit) { _value = value; _unit = unit; @@ -104,7 +102,7 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaMomentOfInertia(double value, UnitSystem unitSystem) + public AreaMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -155,10 +153,10 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,32 +181,32 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); + public QuantityValue CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); /// /// Gets a value of this quantity converted into /// - public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); + public QuantityValue DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); /// /// Gets a value of this quantity converted into /// - public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); + public QuantityValue FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); /// /// Gets a value of this quantity converted into /// - public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); + public QuantityValue InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); /// /// Gets a value of this quantity converted into /// - public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); + public QuantityValue MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); /// /// Gets a value of this quantity converted into /// - public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); + public QuantityValue MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); #endregion @@ -266,7 +264,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvid /// /// Creates a from . /// - public static AreaMomentOfInertia FromCentimetersToTheFourth(double value) + public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth); } @@ -274,7 +272,7 @@ public static AreaMomentOfInertia FromCentimetersToTheFourth(double value) /// /// Creates a from . /// - public static AreaMomentOfInertia FromDecimetersToTheFourth(double value) + public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth); } @@ -282,7 +280,7 @@ public static AreaMomentOfInertia FromDecimetersToTheFourth(double value) /// /// Creates a from . /// - public static AreaMomentOfInertia FromFeetToTheFourth(double value) + public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth); } @@ -290,7 +288,7 @@ public static AreaMomentOfInertia FromFeetToTheFourth(double value) /// /// Creates a from . /// - public static AreaMomentOfInertia FromInchesToTheFourth(double value) + public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth); } @@ -298,7 +296,7 @@ public static AreaMomentOfInertia FromInchesToTheFourth(double value) /// /// Creates a from . /// - public static AreaMomentOfInertia FromMetersToTheFourth(double value) + public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth); } @@ -306,7 +304,7 @@ public static AreaMomentOfInertia FromMetersToTheFourth(double value) /// /// Creates a from . /// - public static AreaMomentOfInertia FromMillimetersToTheFourth(double value) + public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue value) { return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth); } @@ -317,7 +315,7 @@ public static AreaMomentOfInertia FromMillimetersToTheFourth(double value) /// Value to convert from. /// Unit to convert from. /// AreaMomentOfInertia unit value. - public static AreaMomentOfInertia From(double value, AreaMomentOfInertiaUnit fromUnit) + public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaUnit fromUnit) { return new AreaMomentOfInertia(value, fromUnit); } @@ -489,25 +487,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(double left, AreaMomentOfInertia right) + public static AreaMomentOfInertia operator *(QuantityValue left, AreaMomentOfInertia right) { return new AreaMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, double right) + public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, QuantityValue right) { return new AreaMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, double right) + public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, QuantityValue right) { return new AreaMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static QuantityValue operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.MetersToTheFourth / right.MetersToTheFourth; } @@ -556,27 +554,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is AreaMomentOfInertia otherQuantity)) @@ -586,15 +577,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(AreaMomentOfInertia other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -677,10 +665,10 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -697,7 +685,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -710,7 +698,12 @@ public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia tolerance) /// A hash code for the current AreaMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -721,7 +714,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaMomentOfInertiaUnit unit) + public QuantityValue As(AreaMomentOfInertiaUnit unit) { if (Unit == unit) return Value; @@ -730,7 +723,7 @@ public double As(AreaMomentOfInertiaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -745,7 +738,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); @@ -811,18 +804,18 @@ private bool TryToUnit(AreaMomentOfInertiaUnit unit, [NotNullWhen(true)] out Are AreaMomentOfInertia? convertedOrNull = (Unit, unit) switch { // AreaMomentOfInertiaUnit -> BaseUnit - (AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 1e8, AreaMomentOfInertiaUnit.MeterToTheFourth), - (AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 1e4, AreaMomentOfInertiaUnit.MeterToTheFourth), - (AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value * Math.Pow(0.3048, 4), AreaMomentOfInertiaUnit.MeterToTheFourth), - (AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value * Math.Pow(2.54e-2, 4), AreaMomentOfInertiaUnit.MeterToTheFourth), - (AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 1e12, AreaMomentOfInertiaUnit.MeterToTheFourth), + (AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 100000000, AreaMomentOfInertiaUnit.MeterToTheFourth), + (AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 10000, AreaMomentOfInertiaUnit.MeterToTheFourth), + (AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value * new QuantityValue(21071715921, 2441406250000, false), AreaMomentOfInertiaUnit.MeterToTheFourth), + (AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value * new QuantityValue(260144641, 625000000000000, false), AreaMomentOfInertiaUnit.MeterToTheFourth), + (AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth) => new AreaMomentOfInertia(_value / 1000000000000, AreaMomentOfInertiaUnit.MeterToTheFourth), // BaseUnit -> AreaMomentOfInertiaUnit - (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.CentimeterToTheFourth) => new AreaMomentOfInertia(_value * 1e8, AreaMomentOfInertiaUnit.CentimeterToTheFourth), - (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.DecimeterToTheFourth) => new AreaMomentOfInertia(_value * 1e4, AreaMomentOfInertiaUnit.DecimeterToTheFourth), - (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.FootToTheFourth) => new AreaMomentOfInertia(_value / Math.Pow(0.3048, 4), AreaMomentOfInertiaUnit.FootToTheFourth), - (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.InchToTheFourth) => new AreaMomentOfInertia(_value / Math.Pow(2.54e-2, 4), AreaMomentOfInertiaUnit.InchToTheFourth), - (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.MillimeterToTheFourth) => new AreaMomentOfInertia(_value * 1e12, AreaMomentOfInertiaUnit.MillimeterToTheFourth), + (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.CentimeterToTheFourth) => new AreaMomentOfInertia(_value * 100000000, AreaMomentOfInertiaUnit.CentimeterToTheFourth), + (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.DecimeterToTheFourth) => new AreaMomentOfInertia(_value * 10000, AreaMomentOfInertiaUnit.DecimeterToTheFourth), + (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.FootToTheFourth) => new AreaMomentOfInertia(_value * new QuantityValue(2441406250000, 21071715921, false), AreaMomentOfInertiaUnit.FootToTheFourth), + (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.InchToTheFourth) => new AreaMomentOfInertia(_value * new QuantityValue(625000000000000, 260144641, false), AreaMomentOfInertiaUnit.InchToTheFourth), + (AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.MillimeterToTheFourth) => new AreaMomentOfInertia(_value * 1000000000000, AreaMomentOfInertiaUnit.MillimeterToTheFourth), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 6103deeff0..f86d06a4f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -106,7 +107,7 @@ static BitRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public BitRate(double value, BitRateUnit unit) + public BitRate(QuantityValue value, BitRateUnit unit) { _value = value; _unit = unit; @@ -120,7 +121,7 @@ public BitRate(double value, BitRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BitRate(double value, UnitSystem unitSystem) + public BitRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -171,10 +172,10 @@ public BitRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -199,132 +200,132 @@ public BitRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); + public QuantityValue BitsPerSecond => As(BitRateUnit.BitPerSecond); /// /// Gets a value of this quantity converted into /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); + public QuantityValue BytesPerSecond => As(BitRateUnit.BytePerSecond); /// /// Gets a value of this quantity converted into /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public QuantityValue ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// /// Gets a value of this quantity converted into /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public QuantityValue ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// /// Gets a value of this quantity converted into /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public QuantityValue ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public QuantityValue ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public QuantityValue GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public QuantityValue GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public QuantityValue GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// /// Gets a value of this quantity converted into /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public QuantityValue GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// /// Gets a value of this quantity converted into /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public QuantityValue KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public QuantityValue KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public QuantityValue KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public QuantityValue KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// /// Gets a value of this quantity converted into /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public QuantityValue MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public QuantityValue MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public QuantityValue MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public QuantityValue MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// /// Gets a value of this quantity converted into /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public QuantityValue PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public QuantityValue PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public QuantityValue PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// /// Gets a value of this quantity converted into /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public QuantityValue PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// /// Gets a value of this quantity converted into /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public QuantityValue TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// /// Gets a value of this quantity converted into /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public QuantityValue TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// /// Gets a value of this quantity converted into /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public QuantityValue TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// /// Gets a value of this quantity converted into /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public QuantityValue TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -422,7 +423,7 @@ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider /// /// Creates a from . /// - public static BitRate FromBitsPerSecond(double value) + public static BitRate FromBitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.BitPerSecond); } @@ -430,7 +431,7 @@ public static BitRate FromBitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromBytesPerSecond(double value) + public static BitRate FromBytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.BytePerSecond); } @@ -438,7 +439,7 @@ public static BitRate FromBytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromExabitsPerSecond(double value) + public static BitRate FromExabitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.ExabitPerSecond); } @@ -446,7 +447,7 @@ public static BitRate FromExabitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromExabytesPerSecond(double value) + public static BitRate FromExabytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.ExabytePerSecond); } @@ -454,7 +455,7 @@ public static BitRate FromExabytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromExbibitsPerSecond(double value) + public static BitRate FromExbibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.ExbibitPerSecond); } @@ -462,7 +463,7 @@ public static BitRate FromExbibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromExbibytesPerSecond(double value) + public static BitRate FromExbibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.ExbibytePerSecond); } @@ -470,7 +471,7 @@ public static BitRate FromExbibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromGibibitsPerSecond(double value) + public static BitRate FromGibibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.GibibitPerSecond); } @@ -478,7 +479,7 @@ public static BitRate FromGibibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromGibibytesPerSecond(double value) + public static BitRate FromGibibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.GibibytePerSecond); } @@ -486,7 +487,7 @@ public static BitRate FromGibibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromGigabitsPerSecond(double value) + public static BitRate FromGigabitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.GigabitPerSecond); } @@ -494,7 +495,7 @@ public static BitRate FromGigabitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromGigabytesPerSecond(double value) + public static BitRate FromGigabytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.GigabytePerSecond); } @@ -502,7 +503,7 @@ public static BitRate FromGigabytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromKibibitsPerSecond(double value) + public static BitRate FromKibibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.KibibitPerSecond); } @@ -510,7 +511,7 @@ public static BitRate FromKibibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromKibibytesPerSecond(double value) + public static BitRate FromKibibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.KibibytePerSecond); } @@ -518,7 +519,7 @@ public static BitRate FromKibibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromKilobitsPerSecond(double value) + public static BitRate FromKilobitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.KilobitPerSecond); } @@ -526,7 +527,7 @@ public static BitRate FromKilobitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromKilobytesPerSecond(double value) + public static BitRate FromKilobytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.KilobytePerSecond); } @@ -534,7 +535,7 @@ public static BitRate FromKilobytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromMebibitsPerSecond(double value) + public static BitRate FromMebibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.MebibitPerSecond); } @@ -542,7 +543,7 @@ public static BitRate FromMebibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromMebibytesPerSecond(double value) + public static BitRate FromMebibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.MebibytePerSecond); } @@ -550,7 +551,7 @@ public static BitRate FromMebibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromMegabitsPerSecond(double value) + public static BitRate FromMegabitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.MegabitPerSecond); } @@ -558,7 +559,7 @@ public static BitRate FromMegabitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromMegabytesPerSecond(double value) + public static BitRate FromMegabytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.MegabytePerSecond); } @@ -566,7 +567,7 @@ public static BitRate FromMegabytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromPebibitsPerSecond(double value) + public static BitRate FromPebibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.PebibitPerSecond); } @@ -574,7 +575,7 @@ public static BitRate FromPebibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromPebibytesPerSecond(double value) + public static BitRate FromPebibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.PebibytePerSecond); } @@ -582,7 +583,7 @@ public static BitRate FromPebibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromPetabitsPerSecond(double value) + public static BitRate FromPetabitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.PetabitPerSecond); } @@ -590,7 +591,7 @@ public static BitRate FromPetabitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromPetabytesPerSecond(double value) + public static BitRate FromPetabytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.PetabytePerSecond); } @@ -598,7 +599,7 @@ public static BitRate FromPetabytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromTebibitsPerSecond(double value) + public static BitRate FromTebibitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.TebibitPerSecond); } @@ -606,7 +607,7 @@ public static BitRate FromTebibitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromTebibytesPerSecond(double value) + public static BitRate FromTebibytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.TebibytePerSecond); } @@ -614,7 +615,7 @@ public static BitRate FromTebibytesPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromTerabitsPerSecond(double value) + public static BitRate FromTerabitsPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.TerabitPerSecond); } @@ -622,7 +623,7 @@ public static BitRate FromTerabitsPerSecond(double value) /// /// Creates a from . /// - public static BitRate FromTerabytesPerSecond(double value) + public static BitRate FromTerabytesPerSecond(QuantityValue value) { return new BitRate(value, BitRateUnit.TerabytePerSecond); } @@ -633,7 +634,7 @@ public static BitRate FromTerabytesPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// BitRate unit value. - public static BitRate From(double value, BitRateUnit fromUnit) + public static BitRate From(QuantityValue value, BitRateUnit fromUnit) { return new BitRate(value, fromUnit); } @@ -805,25 +806,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa } /// Get from multiplying value and . - public static BitRate operator *(double left, BitRate right) + public static BitRate operator *(QuantityValue left, BitRate right) { return new BitRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BitRate operator *(BitRate left, double right) + public static BitRate operator *(BitRate left, QuantityValue right) { return new BitRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BitRate operator /(BitRate left, double right) + public static BitRate operator /(BitRate left, QuantityValue right) { return new BitRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(BitRate left, BitRate right) + public static QuantityValue operator /(BitRate left, BitRate right) { return left.BitsPerSecond / right.BitsPerSecond; } @@ -856,27 +857,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(BitRate left, BitRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BitRate other, BitRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(BitRate left, BitRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is BitRate otherQuantity)) @@ -886,15 +880,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(BitRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -977,10 +968,10 @@ public bool Equals(BitRate other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -997,7 +988,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(BitRate other, BitRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1010,7 +1001,12 @@ public bool Equals(BitRate other, BitRate tolerance) /// A hash code for the current BitRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1021,7 +1017,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) + public QuantityValue As(BitRateUnit unit) { if (Unit == unit) return Value; @@ -1030,7 +1026,7 @@ public double As(BitRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1045,7 +1041,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); @@ -1112,57 +1108,57 @@ private bool TryToUnit(BitRateUnit unit, [NotNullWhen(true)] out BitRate? conver { // BitRateUnit -> BaseUnit (BitRateUnit.BytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8, BitRateUnit.BitPerSecond), - (BitRateUnit.ExabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e18d, BitRateUnit.BitPerSecond), - (BitRateUnit.ExabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e18d, BitRateUnit.BitPerSecond), - (BitRateUnit.ExbibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.ExbibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.GibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.GibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.GigabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e9d, BitRateUnit.BitPerSecond), - (BitRateUnit.GigabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e9d, BitRateUnit.BitPerSecond), - (BitRateUnit.KibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1024d, BitRateUnit.BitPerSecond), - (BitRateUnit.KibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1024d, BitRateUnit.BitPerSecond), - (BitRateUnit.KilobitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e3d, BitRateUnit.BitPerSecond), - (BitRateUnit.KilobytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e3d, BitRateUnit.BitPerSecond), - (BitRateUnit.MebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.MebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.MegabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e6d, BitRateUnit.BitPerSecond), - (BitRateUnit.MegabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e6d, BitRateUnit.BitPerSecond), - (BitRateUnit.PebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.PebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.PetabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e15d, BitRateUnit.BitPerSecond), - (BitRateUnit.PetabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e15d, BitRateUnit.BitPerSecond), - (BitRateUnit.TebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * (1024d * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.TebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * (1024d * 1024 * 1024 * 1024), BitRateUnit.BitPerSecond), - (BitRateUnit.TerabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value) * 1e12d, BitRateUnit.BitPerSecond), - (BitRateUnit.TerabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate((_value * 8) * 1e12d, BitRateUnit.BitPerSecond), + (BitRateUnit.ExabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000000000000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.ExabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000000000000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.ExbibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1152921504606846976, BitRateUnit.BitPerSecond), + (BitRateUnit.ExbibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * BigInteger.Pow(2, 63), BitRateUnit.BitPerSecond), + (BitRateUnit.GibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1073741824, BitRateUnit.BitPerSecond), + (BitRateUnit.GibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8589934592, BitRateUnit.BitPerSecond), + (BitRateUnit.GigabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.GigabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.KibibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1024, BitRateUnit.BitPerSecond), + (BitRateUnit.KibibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8192, BitRateUnit.BitPerSecond), + (BitRateUnit.KilobitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000, BitRateUnit.BitPerSecond), + (BitRateUnit.KilobytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000, BitRateUnit.BitPerSecond), + (BitRateUnit.MebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1048576, BitRateUnit.BitPerSecond), + (BitRateUnit.MebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8388608, BitRateUnit.BitPerSecond), + (BitRateUnit.MegabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000000, BitRateUnit.BitPerSecond), + (BitRateUnit.MegabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000000, BitRateUnit.BitPerSecond), + (BitRateUnit.PebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1125899906842624, BitRateUnit.BitPerSecond), + (BitRateUnit.PebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 9007199254740992, BitRateUnit.BitPerSecond), + (BitRateUnit.PetabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000000000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.PetabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000000000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.TebibitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1099511627776, BitRateUnit.BitPerSecond), + (BitRateUnit.TebibytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8796093022208, BitRateUnit.BitPerSecond), + (BitRateUnit.TerabitPerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 1000000000000, BitRateUnit.BitPerSecond), + (BitRateUnit.TerabytePerSecond, BitRateUnit.BitPerSecond) => new BitRate(_value * 8000000000000, BitRateUnit.BitPerSecond), // BaseUnit -> BitRateUnit (BitRateUnit.BitPerSecond, BitRateUnit.BytePerSecond) => new BitRate(_value / 8, BitRateUnit.BytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.ExabitPerSecond) => new BitRate((_value) / 1e18d, BitRateUnit.ExabitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.ExabytePerSecond) => new BitRate((_value / 8) / 1e18d, BitRateUnit.ExabytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.ExbibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.ExbibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), BitRateUnit.ExbibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.GibibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024), BitRateUnit.GibibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.GibibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024), BitRateUnit.GibibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.GigabitPerSecond) => new BitRate((_value) / 1e9d, BitRateUnit.GigabitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.GigabytePerSecond) => new BitRate((_value / 8) / 1e9d, BitRateUnit.GigabytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.KibibitPerSecond) => new BitRate((_value) / 1024d, BitRateUnit.KibibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.KibibytePerSecond) => new BitRate((_value / 8) / 1024d, BitRateUnit.KibibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.KilobitPerSecond) => new BitRate((_value) / 1e3d, BitRateUnit.KilobitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.KilobytePerSecond) => new BitRate((_value / 8) / 1e3d, BitRateUnit.KilobytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.MebibitPerSecond) => new BitRate((_value) / (1024d * 1024), BitRateUnit.MebibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.MebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024), BitRateUnit.MebibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.MegabitPerSecond) => new BitRate((_value) / 1e6d, BitRateUnit.MegabitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.MegabytePerSecond) => new BitRate((_value / 8) / 1e6d, BitRateUnit.MegabytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.PebibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.PebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024), BitRateUnit.PebibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.PetabitPerSecond) => new BitRate((_value) / 1e15d, BitRateUnit.PetabitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.PetabytePerSecond) => new BitRate((_value / 8) / 1e15d, BitRateUnit.PetabytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.TebibitPerSecond) => new BitRate((_value) / (1024d * 1024 * 1024 * 1024), BitRateUnit.TebibitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.TebibytePerSecond) => new BitRate((_value / 8) / (1024d * 1024 * 1024 * 1024), BitRateUnit.TebibytePerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.TerabitPerSecond) => new BitRate((_value) / 1e12d, BitRateUnit.TerabitPerSecond), - (BitRateUnit.BitPerSecond, BitRateUnit.TerabytePerSecond) => new BitRate((_value / 8) / 1e12d, BitRateUnit.TerabytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.ExabitPerSecond) => new BitRate(_value / 1000000000000000000, BitRateUnit.ExabitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.ExabytePerSecond) => new BitRate(_value / 8000000000000000000, BitRateUnit.ExabytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.ExbibitPerSecond) => new BitRate(_value / 1152921504606846976, BitRateUnit.ExbibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.ExbibytePerSecond) => new BitRate(_value / BigInteger.Pow(2, 63), BitRateUnit.ExbibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.GibibitPerSecond) => new BitRate(_value / 1073741824, BitRateUnit.GibibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.GibibytePerSecond) => new BitRate(_value / 8589934592, BitRateUnit.GibibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.GigabitPerSecond) => new BitRate(_value / 1000000000, BitRateUnit.GigabitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.GigabytePerSecond) => new BitRate(_value / 8000000000, BitRateUnit.GigabytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.KibibitPerSecond) => new BitRate(_value / 1024, BitRateUnit.KibibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.KibibytePerSecond) => new BitRate(_value / 8192, BitRateUnit.KibibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.KilobitPerSecond) => new BitRate(_value / 1000, BitRateUnit.KilobitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.KilobytePerSecond) => new BitRate(_value / 8000, BitRateUnit.KilobytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.MebibitPerSecond) => new BitRate(_value / 1048576, BitRateUnit.MebibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.MebibytePerSecond) => new BitRate(_value / 8388608, BitRateUnit.MebibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.MegabitPerSecond) => new BitRate(_value / 1000000, BitRateUnit.MegabitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.MegabytePerSecond) => new BitRate(_value / 8000000, BitRateUnit.MegabytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.PebibitPerSecond) => new BitRate(_value / 1125899906842624, BitRateUnit.PebibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.PebibytePerSecond) => new BitRate(_value / 9007199254740992, BitRateUnit.PebibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.PetabitPerSecond) => new BitRate(_value / 1000000000000000, BitRateUnit.PetabitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.PetabytePerSecond) => new BitRate(_value / 8000000000000000, BitRateUnit.PetabytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.TebibitPerSecond) => new BitRate(_value / 1099511627776, BitRateUnit.TebibitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.TebibytePerSecond) => new BitRate(_value / 8796093022208, BitRateUnit.TebibytePerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.TerabitPerSecond) => new BitRate(_value / 1000000000000, BitRateUnit.TerabitPerSecond), + (BitRateUnit.BitPerSecond, BitRateUnit.TerabytePerSecond) => new BitRate(_value / 8000000000000, BitRateUnit.TerabytePerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index e79fe994e7..6932b09e7c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -43,7 +41,7 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,7 +85,7 @@ static BrakeSpecificFuelConsumption() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) + public BrakeSpecificFuelConsumption(QuantityValue value, BrakeSpecificFuelConsumptionUnit unit) { _value = value; _unit = unit; @@ -101,7 +99,7 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) + public BrakeSpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -152,10 +150,10 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -180,17 +178,17 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + public QuantityValue GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + public QuantityValue KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); /// /// Gets a value of this quantity converted into /// - public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + public QuantityValue PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); #endregion @@ -242,7 +240,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFor /// /// Creates a from . /// - public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(double value) + public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValue value) { return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); } @@ -250,7 +248,7 @@ public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(double value /// /// Creates a from . /// - public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(double value) + public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue value) { return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); } @@ -258,7 +256,7 @@ public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(double value) /// /// Creates a from . /// - public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(double value) + public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(QuantityValue value) { return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); } @@ -269,7 +267,7 @@ public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour /// Value to convert from. /// Unit to convert from. /// BrakeSpecificFuelConsumption unit value. - public static BrakeSpecificFuelConsumption From(double value, BrakeSpecificFuelConsumptionUnit fromUnit) + public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecificFuelConsumptionUnit fromUnit) { return new BrakeSpecificFuelConsumption(value, fromUnit); } @@ -441,25 +439,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(double left, BrakeSpecificFuelConsumption right) + public static BrakeSpecificFuelConsumption operator *(QuantityValue left, BrakeSpecificFuelConsumption right) { return new BrakeSpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, double right) + public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, QuantityValue right) { return new BrakeSpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, double right) + public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, QuantityValue right) { return new BrakeSpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static QuantityValue operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.KilogramsPerJoule / right.KilogramsPerJoule; } @@ -474,14 +472,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return MassFlow.FromKilogramsPerSecond(brakeSpecificFuelConsumption.KilogramsPerJoule * power.Watts); } - /// Get from / . - public static SpecificEnergy operator /(double value, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + /// Get from / . + public static SpecificEnergy operator /(QuantityValue value, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) { return SpecificEnergy.FromJoulesPerKilogram(value / brakeSpecificFuelConsumption.KilogramsPerJoule); } - /// Get from * . - public static double operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, SpecificEnergy specificEnergy) + /// Get from * . + public static QuantityValue operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, SpecificEnergy specificEnergy) { return brakeSpecificFuelConsumption.KilogramsPerJoule * specificEnergy.JoulesPerKilogram; } @@ -514,27 +512,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is BrakeSpecificFuelConsumption otherQuantity)) @@ -544,15 +535,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(BrakeSpecificFuelConsumption other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -635,10 +623,10 @@ public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -655,7 +643,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumption tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -668,7 +656,12 @@ public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumpt /// A hash code for the current BrakeSpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -679,7 +672,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BrakeSpecificFuelConsumptionUnit unit) + public QuantityValue As(BrakeSpecificFuelConsumptionUnit unit) { if (Unit == unit) return Value; @@ -688,7 +681,7 @@ public double As(BrakeSpecificFuelConsumptionUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -703,7 +696,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); @@ -769,12 +762,12 @@ private bool TryToUnit(BrakeSpecificFuelConsumptionUnit unit, [NotNullWhen(true) BrakeSpecificFuelConsumption? convertedOrNull = (Unit, unit) switch { // BrakeSpecificFuelConsumptionUnit -> BaseUnit - (BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule) => new BrakeSpecificFuelConsumption(_value / 3.6e9, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), - (BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule) => new BrakeSpecificFuelConsumption(_value * 1.689659410672e-7, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), + (BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule) => new BrakeSpecificFuelConsumption(_value / 3600000000, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), + (BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule) => new BrakeSpecificFuelConsumption(_value * new QuantityValue(105603713167, 625000000000000000, false), BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), // BaseUnit -> BrakeSpecificFuelConsumptionUnit - (BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour) => new BrakeSpecificFuelConsumption(_value * 3.6e9, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour), - (BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour) => new BrakeSpecificFuelConsumption(_value / 1.689659410672e-7, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), + (BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour) => new BrakeSpecificFuelConsumption(_value * 3600000000, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour), + (BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour) => new BrakeSpecificFuelConsumption(_value * new QuantityValue(625000000000000000, 105603713167, false), BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 4ec6d4629e..22cb27f98d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,7 +88,7 @@ static Capacitance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Capacitance(double value, CapacitanceUnit unit) + public Capacitance(QuantityValue value, CapacitanceUnit unit) { _value = value; _unit = unit; @@ -101,7 +102,7 @@ public Capacitance(double value, CapacitanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Capacitance(double value, UnitSystem unitSystem) + public Capacitance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -152,10 +153,10 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -180,37 +181,37 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Farads => As(CapacitanceUnit.Farad); + public QuantityValue Farads => As(CapacitanceUnit.Farad); /// /// Gets a value of this quantity converted into /// - public double Kilofarads => As(CapacitanceUnit.Kilofarad); + public QuantityValue Kilofarads => As(CapacitanceUnit.Kilofarad); /// /// Gets a value of this quantity converted into /// - public double Megafarads => As(CapacitanceUnit.Megafarad); + public QuantityValue Megafarads => As(CapacitanceUnit.Megafarad); /// /// Gets a value of this quantity converted into /// - public double Microfarads => As(CapacitanceUnit.Microfarad); + public QuantityValue Microfarads => As(CapacitanceUnit.Microfarad); /// /// Gets a value of this quantity converted into /// - public double Millifarads => As(CapacitanceUnit.Millifarad); + public QuantityValue Millifarads => As(CapacitanceUnit.Millifarad); /// /// Gets a value of this quantity converted into /// - public double Nanofarads => As(CapacitanceUnit.Nanofarad); + public QuantityValue Nanofarads => As(CapacitanceUnit.Nanofarad); /// /// Gets a value of this quantity converted into /// - public double Picofarads => As(CapacitanceUnit.Picofarad); + public QuantityValue Picofarads => As(CapacitanceUnit.Picofarad); #endregion @@ -270,7 +271,7 @@ public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static Capacitance FromFarads(double value) + public static Capacitance FromFarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Farad); } @@ -278,7 +279,7 @@ public static Capacitance FromFarads(double value) /// /// Creates a from . /// - public static Capacitance FromKilofarads(double value) + public static Capacitance FromKilofarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Kilofarad); } @@ -286,7 +287,7 @@ public static Capacitance FromKilofarads(double value) /// /// Creates a from . /// - public static Capacitance FromMegafarads(double value) + public static Capacitance FromMegafarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Megafarad); } @@ -294,7 +295,7 @@ public static Capacitance FromMegafarads(double value) /// /// Creates a from . /// - public static Capacitance FromMicrofarads(double value) + public static Capacitance FromMicrofarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Microfarad); } @@ -302,7 +303,7 @@ public static Capacitance FromMicrofarads(double value) /// /// Creates a from . /// - public static Capacitance FromMillifarads(double value) + public static Capacitance FromMillifarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Millifarad); } @@ -310,7 +311,7 @@ public static Capacitance FromMillifarads(double value) /// /// Creates a from . /// - public static Capacitance FromNanofarads(double value) + public static Capacitance FromNanofarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Nanofarad); } @@ -318,7 +319,7 @@ public static Capacitance FromNanofarads(double value) /// /// Creates a from . /// - public static Capacitance FromPicofarads(double value) + public static Capacitance FromPicofarads(QuantityValue value) { return new Capacitance(value, CapacitanceUnit.Picofarad); } @@ -329,7 +330,7 @@ public static Capacitance FromPicofarads(double value) /// Value to convert from. /// Unit to convert from. /// Capacitance unit value. - public static Capacitance From(double value, CapacitanceUnit fromUnit) + public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit) { return new Capacitance(value, fromUnit); } @@ -501,25 +502,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac } /// Get from multiplying value and . - public static Capacitance operator *(double left, Capacitance right) + public static Capacitance operator *(QuantityValue left, Capacitance right) { return new Capacitance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Capacitance operator *(Capacitance left, double right) + public static Capacitance operator *(Capacitance left, QuantityValue right) { return new Capacitance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Capacitance operator /(Capacitance left, double right) + public static Capacitance operator /(Capacitance left, QuantityValue right) { return new Capacitance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Capacitance left, Capacitance right) + public static QuantityValue operator /(Capacitance left, Capacitance right) { return left.Farads / right.Farads; } @@ -552,27 +553,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Capacitance left, Capacitance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Capacitance left, Capacitance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Capacitance otherQuantity)) @@ -582,15 +576,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(Capacitance other, Capacitance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(Capacitance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -673,10 +664,10 @@ public bool Equals(Capacitance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -693,7 +684,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Capacitance other, Capacitance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -706,7 +697,12 @@ public bool Equals(Capacitance other, Capacitance tolerance) /// A hash code for the current Capacitance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -717,7 +713,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CapacitanceUnit unit) + public QuantityValue As(CapacitanceUnit unit) { if (Unit == unit) return Value; @@ -726,7 +722,7 @@ public double As(CapacitanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -741,7 +737,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); @@ -807,20 +803,20 @@ private bool TryToUnit(CapacitanceUnit unit, [NotNullWhen(true)] out Capacitance Capacitance? convertedOrNull = (Unit, unit) switch { // CapacitanceUnit -> BaseUnit - (CapacitanceUnit.Kilofarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e3d, CapacitanceUnit.Farad), - (CapacitanceUnit.Megafarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e6d, CapacitanceUnit.Farad), - (CapacitanceUnit.Microfarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e-6d, CapacitanceUnit.Farad), - (CapacitanceUnit.Millifarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e-3d, CapacitanceUnit.Farad), - (CapacitanceUnit.Nanofarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e-9d, CapacitanceUnit.Farad), - (CapacitanceUnit.Picofarad, CapacitanceUnit.Farad) => new Capacitance((_value) * 1e-12d, CapacitanceUnit.Farad), + (CapacitanceUnit.Kilofarad, CapacitanceUnit.Farad) => new Capacitance(_value * 1000, CapacitanceUnit.Farad), + (CapacitanceUnit.Megafarad, CapacitanceUnit.Farad) => new Capacitance(_value * 1000000, CapacitanceUnit.Farad), + (CapacitanceUnit.Microfarad, CapacitanceUnit.Farad) => new Capacitance(_value / 1000000, CapacitanceUnit.Farad), + (CapacitanceUnit.Millifarad, CapacitanceUnit.Farad) => new Capacitance(_value / 1000, CapacitanceUnit.Farad), + (CapacitanceUnit.Nanofarad, CapacitanceUnit.Farad) => new Capacitance(_value / 1000000000, CapacitanceUnit.Farad), + (CapacitanceUnit.Picofarad, CapacitanceUnit.Farad) => new Capacitance(_value / 1000000000000, CapacitanceUnit.Farad), // BaseUnit -> CapacitanceUnit - (CapacitanceUnit.Farad, CapacitanceUnit.Kilofarad) => new Capacitance((_value) / 1e3d, CapacitanceUnit.Kilofarad), - (CapacitanceUnit.Farad, CapacitanceUnit.Megafarad) => new Capacitance((_value) / 1e6d, CapacitanceUnit.Megafarad), - (CapacitanceUnit.Farad, CapacitanceUnit.Microfarad) => new Capacitance((_value) / 1e-6d, CapacitanceUnit.Microfarad), - (CapacitanceUnit.Farad, CapacitanceUnit.Millifarad) => new Capacitance((_value) / 1e-3d, CapacitanceUnit.Millifarad), - (CapacitanceUnit.Farad, CapacitanceUnit.Nanofarad) => new Capacitance((_value) / 1e-9d, CapacitanceUnit.Nanofarad), - (CapacitanceUnit.Farad, CapacitanceUnit.Picofarad) => new Capacitance((_value) / 1e-12d, CapacitanceUnit.Picofarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Kilofarad) => new Capacitance(_value / 1000, CapacitanceUnit.Kilofarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Megafarad) => new Capacitance(_value / 1000000, CapacitanceUnit.Megafarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Microfarad) => new Capacitance(_value * 1000000, CapacitanceUnit.Microfarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Millifarad) => new Capacitance(_value * 1000, CapacitanceUnit.Millifarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Nanofarad) => new Capacitance(_value * 1000000000, CapacitanceUnit.Nanofarad), + (CapacitanceUnit.Farad, CapacitanceUnit.Picofarad) => new Capacitance(_value * 1000000000000, CapacitanceUnit.Picofarad), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 6985716cf0..3a4004df05 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -42,7 +40,7 @@ namespace UnitsNet public readonly partial struct CoefficientOfThermalExpansion : IArithmeticQuantity, #if NET7_0_OR_GREATER - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -89,7 +87,7 @@ static CoefficientOfThermalExpansion() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) + public CoefficientOfThermalExpansion(QuantityValue value, CoefficientOfThermalExpansionUnit unit) { _value = value; _unit = unit; @@ -103,7 +101,7 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) + public CoefficientOfThermalExpansion(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -154,10 +152,10 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -182,32 +180,32 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double PerDegreeCelsius => As(CoefficientOfThermalExpansionUnit.PerDegreeCelsius); + public QuantityValue PerDegreeCelsius => As(CoefficientOfThermalExpansionUnit.PerDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double PerDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit); + public QuantityValue PerDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double PerKelvin => As(CoefficientOfThermalExpansionUnit.PerKelvin); + public QuantityValue PerKelvin => As(CoefficientOfThermalExpansionUnit.PerKelvin); /// /// Gets a value of this quantity converted into /// - public double PpmPerDegreeCelsius => As(CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius); + public QuantityValue PpmPerDegreeCelsius => As(CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double PpmPerDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit); + public QuantityValue PpmPerDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double PpmPerKelvin => As(CoefficientOfThermalExpansionUnit.PpmPerKelvin); + public QuantityValue PpmPerKelvin => As(CoefficientOfThermalExpansionUnit.PpmPerKelvin); #endregion @@ -265,7 +263,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFo /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPerDegreeCelsius(double value) + public static CoefficientOfThermalExpansion FromPerDegreeCelsius(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PerDegreeCelsius); } @@ -273,7 +271,7 @@ public static CoefficientOfThermalExpansion FromPerDegreeCelsius(double value) /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPerDegreeFahrenheit(double value) + public static CoefficientOfThermalExpansion FromPerDegreeFahrenheit(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit); } @@ -281,7 +279,7 @@ public static CoefficientOfThermalExpansion FromPerDegreeFahrenheit(double value /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPerKelvin(double value) + public static CoefficientOfThermalExpansion FromPerKelvin(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PerKelvin); } @@ -289,7 +287,7 @@ public static CoefficientOfThermalExpansion FromPerKelvin(double value) /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPpmPerDegreeCelsius(double value) + public static CoefficientOfThermalExpansion FromPpmPerDegreeCelsius(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius); } @@ -297,7 +295,7 @@ public static CoefficientOfThermalExpansion FromPpmPerDegreeCelsius(double value /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPpmPerDegreeFahrenheit(double value) + public static CoefficientOfThermalExpansion FromPpmPerDegreeFahrenheit(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit); } @@ -305,7 +303,7 @@ public static CoefficientOfThermalExpansion FromPpmPerDegreeFahrenheit(double va /// /// Creates a from . /// - public static CoefficientOfThermalExpansion FromPpmPerKelvin(double value) + public static CoefficientOfThermalExpansion FromPpmPerKelvin(QuantityValue value) { return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.PpmPerKelvin); } @@ -316,7 +314,7 @@ public static CoefficientOfThermalExpansion FromPpmPerKelvin(double value) /// Value to convert from. /// Unit to convert from. /// CoefficientOfThermalExpansion unit value. - public static CoefficientOfThermalExpansion From(double value, CoefficientOfThermalExpansionUnit fromUnit) + public static CoefficientOfThermalExpansion From(QuantityValue value, CoefficientOfThermalExpansionUnit fromUnit) { return new CoefficientOfThermalExpansion(value, fromUnit); } @@ -488,25 +486,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(double left, CoefficientOfThermalExpansion right) + public static CoefficientOfThermalExpansion operator *(QuantityValue left, CoefficientOfThermalExpansion right) { return new CoefficientOfThermalExpansion(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, double right) + public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, QuantityValue right) { return new CoefficientOfThermalExpansion(left.Value * right, left.Unit); } /// Get from dividing by value. - public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, double right) + public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, QuantityValue right) { return new CoefficientOfThermalExpansion(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static QuantityValue operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.PerKelvin / right.PerKelvin; } @@ -515,14 +513,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff #region Relational Operators - /// Get from / . - public static TemperatureDelta operator /(double value, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + /// Get from / . + public static TemperatureDelta operator /(QuantityValue value, CoefficientOfThermalExpansion coefficientOfThermalExpansion) { return TemperatureDelta.FromKelvins(value / coefficientOfThermalExpansion.PerKelvin); } - /// Get from * . - public static double operator *(CoefficientOfThermalExpansion coefficientOfThermalExpansion, TemperatureDelta temperatureDelta) + /// Get from * . + public static QuantityValue operator *(CoefficientOfThermalExpansion coefficientOfThermalExpansion, TemperatureDelta temperatureDelta) { return coefficientOfThermalExpansion.PerKelvin * temperatureDelta.Kelvins; } @@ -555,27 +553,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is CoefficientOfThermalExpansion otherQuantity)) @@ -585,15 +576,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(CoefficientOfThermalExpansion other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -676,10 +664,10 @@ public bool Equals(CoefficientOfThermalExpansion other, double tolerance, Compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -696,7 +684,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpansion tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -709,7 +697,12 @@ public bool Equals(CoefficientOfThermalExpansion other, CoefficientOfThermalExpa /// A hash code for the current CoefficientOfThermalExpansion. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -720,7 +713,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CoefficientOfThermalExpansionUnit unit) + public QuantityValue As(CoefficientOfThermalExpansionUnit unit) { if (Unit == unit) return Value; @@ -729,7 +722,7 @@ public double As(CoefficientOfThermalExpansionUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -744,7 +737,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); @@ -811,17 +804,17 @@ private bool TryToUnit(CoefficientOfThermalExpansionUnit unit, [NotNullWhen(true { // CoefficientOfThermalExpansionUnit -> BaseUnit (CoefficientOfThermalExpansionUnit.PerDegreeCelsius, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value, CoefficientOfThermalExpansionUnit.PerKelvin), - (CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value * 9 / 5, CoefficientOfThermalExpansionUnit.PerKelvin), - (CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value / 1e6, CoefficientOfThermalExpansionUnit.PerKelvin), - (CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value * 9 / 5e6, CoefficientOfThermalExpansionUnit.PerKelvin), - (CoefficientOfThermalExpansionUnit.PpmPerKelvin, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value / 1e6, CoefficientOfThermalExpansionUnit.PerKelvin), + (CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value * new QuantityValue(9, 5, false), CoefficientOfThermalExpansionUnit.PerKelvin), + (CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value / 1000000, CoefficientOfThermalExpansionUnit.PerKelvin), + (CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value * new QuantityValue(9, 5000000, false), CoefficientOfThermalExpansionUnit.PerKelvin), + (CoefficientOfThermalExpansionUnit.PpmPerKelvin, CoefficientOfThermalExpansionUnit.PerKelvin) => new CoefficientOfThermalExpansion(_value / 1000000, CoefficientOfThermalExpansionUnit.PerKelvin), // BaseUnit -> CoefficientOfThermalExpansionUnit (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PerDegreeCelsius) => new CoefficientOfThermalExpansion(_value, CoefficientOfThermalExpansionUnit.PerDegreeCelsius), - (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit) => new CoefficientOfThermalExpansion(_value * 5 / 9, CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit), - (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius) => new CoefficientOfThermalExpansion(_value * 1e6, CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius), - (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit) => new CoefficientOfThermalExpansion(_value * 5e6 / 9, CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit), - (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerKelvin) => new CoefficientOfThermalExpansion(_value * 1e6, CoefficientOfThermalExpansionUnit.PpmPerKelvin), + (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit) => new CoefficientOfThermalExpansion(_value * new QuantityValue(5, 9, false), CoefficientOfThermalExpansionUnit.PerDegreeFahrenheit), + (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius) => new CoefficientOfThermalExpansion(_value * 1000000, CoefficientOfThermalExpansionUnit.PpmPerDegreeCelsius), + (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit) => new CoefficientOfThermalExpansion(_value * new QuantityValue(5000000, 9, false), CoefficientOfThermalExpansionUnit.PpmPerDegreeFahrenheit), + (CoefficientOfThermalExpansionUnit.PerKelvin, CoefficientOfThermalExpansionUnit.PpmPerKelvin) => new CoefficientOfThermalExpansion(_value * 1000000, CoefficientOfThermalExpansionUnit.PpmPerKelvin), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 6bf2b5c575..cf44f6be47 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,7 +85,7 @@ static Compressibility() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Compressibility(double value, CompressibilityUnit unit) + public Compressibility(QuantityValue value, CompressibilityUnit unit) { _value = value; _unit = unit; @@ -98,7 +99,7 @@ public Compressibility(double value, CompressibilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Compressibility(double value, UnitSystem unitSystem) + public Compressibility(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -149,10 +150,10 @@ public Compressibility(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,37 +178,37 @@ public Compressibility(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); + public QuantityValue InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); /// /// Gets a value of this quantity converted into /// - public double InverseBars => As(CompressibilityUnit.InverseBar); + public QuantityValue InverseBars => As(CompressibilityUnit.InverseBar); /// /// Gets a value of this quantity converted into /// - public double InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); + public QuantityValue InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); /// /// Gets a value of this quantity converted into /// - public double InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); + public QuantityValue InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); /// /// Gets a value of this quantity converted into /// - public double InverseMillibars => As(CompressibilityUnit.InverseMillibar); + public QuantityValue InverseMillibars => As(CompressibilityUnit.InverseMillibar); /// /// Gets a value of this quantity converted into /// - public double InversePascals => As(CompressibilityUnit.InversePascal); + public QuantityValue InversePascals => As(CompressibilityUnit.InversePascal); /// /// Gets a value of this quantity converted into /// - public double InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); + public QuantityValue InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); #endregion @@ -267,7 +268,7 @@ public static string GetAbbreviation(CompressibilityUnit unit, IFormatProvider? /// /// Creates a from . /// - public static Compressibility FromInverseAtmospheres(double value) + public static Compressibility FromInverseAtmospheres(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InverseAtmosphere); } @@ -275,7 +276,7 @@ public static Compressibility FromInverseAtmospheres(double value) /// /// Creates a from . /// - public static Compressibility FromInverseBars(double value) + public static Compressibility FromInverseBars(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InverseBar); } @@ -283,7 +284,7 @@ public static Compressibility FromInverseBars(double value) /// /// Creates a from . /// - public static Compressibility FromInverseKilopascals(double value) + public static Compressibility FromInverseKilopascals(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InverseKilopascal); } @@ -291,7 +292,7 @@ public static Compressibility FromInverseKilopascals(double value) /// /// Creates a from . /// - public static Compressibility FromInverseMegapascals(double value) + public static Compressibility FromInverseMegapascals(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InverseMegapascal); } @@ -299,7 +300,7 @@ public static Compressibility FromInverseMegapascals(double value) /// /// Creates a from . /// - public static Compressibility FromInverseMillibars(double value) + public static Compressibility FromInverseMillibars(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InverseMillibar); } @@ -307,7 +308,7 @@ public static Compressibility FromInverseMillibars(double value) /// /// Creates a from . /// - public static Compressibility FromInversePascals(double value) + public static Compressibility FromInversePascals(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InversePascal); } @@ -315,7 +316,7 @@ public static Compressibility FromInversePascals(double value) /// /// Creates a from . /// - public static Compressibility FromInversePoundsForcePerSquareInch(double value) + public static Compressibility FromInversePoundsForcePerSquareInch(QuantityValue value) { return new Compressibility(value, CompressibilityUnit.InversePoundForcePerSquareInch); } @@ -326,7 +327,7 @@ public static Compressibility FromInversePoundsForcePerSquareInch(double value) /// Value to convert from. /// Unit to convert from. /// Compressibility unit value. - public static Compressibility From(double value, CompressibilityUnit fromUnit) + public static Compressibility From(QuantityValue value, CompressibilityUnit fromUnit) { return new Compressibility(value, fromUnit); } @@ -498,25 +499,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr } /// Get from multiplying value and . - public static Compressibility operator *(double left, Compressibility right) + public static Compressibility operator *(QuantityValue left, Compressibility right) { return new Compressibility(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Compressibility operator *(Compressibility left, double right) + public static Compressibility operator *(Compressibility left, QuantityValue right) { return new Compressibility(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Compressibility operator /(Compressibility left, double right) + public static Compressibility operator /(Compressibility left, QuantityValue right) { return new Compressibility(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Compressibility left, Compressibility right) + public static QuantityValue operator /(Compressibility left, Compressibility right) { return left.InversePascals / right.InversePascals; } @@ -549,27 +550,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Compressibility left, Compressibility right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Compressibility other, Compressibility tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Compressibility left, Compressibility right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Compressibility otherQuantity)) @@ -579,15 +573,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Compressibility other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -670,10 +661,10 @@ public bool Equals(Compressibility other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -690,7 +681,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Compressibility other, Compressibility tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -703,7 +694,12 @@ public bool Equals(Compressibility other, Compressibility tolerance) /// A hash code for the current Compressibility. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -714,7 +710,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CompressibilityUnit unit) + public QuantityValue As(CompressibilityUnit unit) { if (Unit == unit) return Value; @@ -723,7 +719,7 @@ public double As(CompressibilityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -738,7 +734,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); @@ -805,19 +801,19 @@ private bool TryToUnit(CompressibilityUnit unit, [NotNullWhen(true)] out Compres { // CompressibilityUnit -> BaseUnit (CompressibilityUnit.InverseAtmosphere, CompressibilityUnit.InversePascal) => new Compressibility(_value * 101325, CompressibilityUnit.InversePascal), - (CompressibilityUnit.InverseBar, CompressibilityUnit.InversePascal) => new Compressibility(_value * 1e5, CompressibilityUnit.InversePascal), - (CompressibilityUnit.InverseKilopascal, CompressibilityUnit.InversePascal) => new Compressibility(_value * 1e3, CompressibilityUnit.InversePascal), - (CompressibilityUnit.InverseMegapascal, CompressibilityUnit.InversePascal) => new Compressibility(_value * 1e6, CompressibilityUnit.InversePascal), + (CompressibilityUnit.InverseBar, CompressibilityUnit.InversePascal) => new Compressibility(_value * 100000, CompressibilityUnit.InversePascal), + (CompressibilityUnit.InverseKilopascal, CompressibilityUnit.InversePascal) => new Compressibility(_value * 1000, CompressibilityUnit.InversePascal), + (CompressibilityUnit.InverseMegapascal, CompressibilityUnit.InversePascal) => new Compressibility(_value * 1000000, CompressibilityUnit.InversePascal), (CompressibilityUnit.InverseMillibar, CompressibilityUnit.InversePascal) => new Compressibility(_value * 100, CompressibilityUnit.InversePascal), - (CompressibilityUnit.InversePoundForcePerSquareInch, CompressibilityUnit.InversePascal) => new Compressibility(_value * 6.894757293168361e3, CompressibilityUnit.InversePascal), + (CompressibilityUnit.InversePoundForcePerSquareInch, CompressibilityUnit.InversePascal) => new Compressibility(_value * new QuantityValue(6894757293168361, 1000000000000, false), CompressibilityUnit.InversePascal), // BaseUnit -> CompressibilityUnit (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseAtmosphere) => new Compressibility(_value / 101325, CompressibilityUnit.InverseAtmosphere), - (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseBar) => new Compressibility(_value / 1e5, CompressibilityUnit.InverseBar), - (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseKilopascal) => new Compressibility(_value / 1e3, CompressibilityUnit.InverseKilopascal), - (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseMegapascal) => new Compressibility(_value / 1e6, CompressibilityUnit.InverseMegapascal), + (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseBar) => new Compressibility(_value / 100000, CompressibilityUnit.InverseBar), + (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseKilopascal) => new Compressibility(_value / 1000, CompressibilityUnit.InverseKilopascal), + (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseMegapascal) => new Compressibility(_value / 1000000, CompressibilityUnit.InverseMegapascal), (CompressibilityUnit.InversePascal, CompressibilityUnit.InverseMillibar) => new Compressibility(_value / 100, CompressibilityUnit.InverseMillibar), - (CompressibilityUnit.InversePascal, CompressibilityUnit.InversePoundForcePerSquareInch) => new Compressibility(_value / 6.894757293168361e3, CompressibilityUnit.InversePoundForcePerSquareInch), + (CompressibilityUnit.InversePascal, CompressibilityUnit.InversePoundForcePerSquareInch) => new Compressibility(_value * new QuantityValue(1000000000000, 6894757293168361, false), CompressibilityUnit.InversePoundForcePerSquareInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 54634fe5d0..d538c263e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -52,7 +50,7 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -64,7 +62,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -149,7 +147,7 @@ static Density() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Density(double value, DensityUnit unit) + public Density(QuantityValue value, DensityUnit unit) { _value = value; _unit = unit; @@ -163,7 +161,7 @@ public Density(double value, DensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Density(double value, UnitSystem unitSystem) + public Density(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -214,10 +212,10 @@ public Density(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -242,282 +240,282 @@ public Density(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentigramsPerDeciliter => As(DensityUnit.CentigramPerDeciliter); + public QuantityValue CentigramsPerDeciliter => As(DensityUnit.CentigramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); + public QuantityValue CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); + public QuantityValue CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerDeciliter => As(DensityUnit.DecigramPerDeciliter); + public QuantityValue DecigramsPerDeciliter => As(DensityUnit.DecigramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); + public QuantityValue DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); + public QuantityValue DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double FemtogramsPerDeciliter => As(DensityUnit.FemtogramPerDeciliter); + public QuantityValue FemtogramsPerDeciliter => As(DensityUnit.FemtogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double FemtogramsPerLiter => As(DensityUnit.FemtogramPerLiter); + public QuantityValue FemtogramsPerLiter => As(DensityUnit.FemtogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double FemtogramsPerMilliliter => As(DensityUnit.FemtogramPerMilliliter); + public QuantityValue FemtogramsPerMilliliter => As(DensityUnit.FemtogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); + public QuantityValue GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); + public QuantityValue GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); + public QuantityValue GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); + public QuantityValue GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); + public QuantityValue GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerDeciliter => As(DensityUnit.GramPerDeciliter); + public QuantityValue GramsPerDeciliter => As(DensityUnit.GramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double GramsPerLiter => As(DensityUnit.GramPerLiter); + public QuantityValue GramsPerLiter => As(DensityUnit.GramPerLiter); /// /// Gets a value of this quantity converted into /// - public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); + public QuantityValue GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); + public QuantityValue KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); + public QuantityValue KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); + public QuantityValue KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); + public QuantityValue KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); + public QuantityValue KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); + public QuantityValue KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerCubicYard => As(DensityUnit.KilopoundPerCubicYard); + public QuantityValue KilopoundsPerCubicYard => As(DensityUnit.KilopoundPerCubicYard); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); + public QuantityValue MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerDeciliter => As(DensityUnit.MicrogramPerDeciliter); + public QuantityValue MicrogramsPerDeciliter => As(DensityUnit.MicrogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); + public QuantityValue MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); + public QuantityValue MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); + public QuantityValue MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerDeciliter => As(DensityUnit.MilligramPerDeciliter); + public QuantityValue MilligramsPerDeciliter => As(DensityUnit.MilligramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); + public QuantityValue MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); + public QuantityValue MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerDeciliter => As(DensityUnit.NanogramPerDeciliter); + public QuantityValue NanogramsPerDeciliter => As(DensityUnit.NanogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); + public QuantityValue NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); + public QuantityValue NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerDeciliter => As(DensityUnit.PicogramPerDeciliter); + public QuantityValue PicogramsPerDeciliter => As(DensityUnit.PicogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); + public QuantityValue PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); + public QuantityValue PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); + public QuantityValue PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); + public QuantityValue PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); + public QuantityValue PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); + public QuantityValue PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); + public QuantityValue PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicYard => As(DensityUnit.PoundPerCubicYard); + public QuantityValue PoundsPerCubicYard => As(DensityUnit.PoundPerCubicYard); /// /// Gets a value of this quantity converted into /// - public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); + public QuantityValue PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); /// /// Gets a value of this quantity converted into /// - public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); + public QuantityValue PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); + public QuantityValue SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); + public QuantityValue SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); + public QuantityValue SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); + public QuantityValue SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); + public QuantityValue SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); + public QuantityValue TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); + public QuantityValue TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); + public QuantityValue TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); + public QuantityValue TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); + public QuantityValue TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); #endregion @@ -675,7 +673,7 @@ public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider /// /// Creates a from . /// - public static Density FromCentigramsPerDeciliter(double value) + public static Density FromCentigramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.CentigramPerDeciliter); } @@ -683,7 +681,7 @@ public static Density FromCentigramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromCentigramsPerLiter(double value) + public static Density FromCentigramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.CentigramPerLiter); } @@ -691,7 +689,7 @@ public static Density FromCentigramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromCentigramsPerMilliliter(double value) + public static Density FromCentigramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.CentigramPerMilliliter); } @@ -699,7 +697,7 @@ public static Density FromCentigramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromDecigramsPerDeciliter(double value) + public static Density FromDecigramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.DecigramPerDeciliter); } @@ -707,7 +705,7 @@ public static Density FromDecigramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromDecigramsPerLiter(double value) + public static Density FromDecigramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.DecigramPerLiter); } @@ -715,7 +713,7 @@ public static Density FromDecigramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromDecigramsPerMilliliter(double value) + public static Density FromDecigramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.DecigramPerMilliliter); } @@ -723,7 +721,7 @@ public static Density FromDecigramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromFemtogramsPerDeciliter(double value) + public static Density FromFemtogramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.FemtogramPerDeciliter); } @@ -731,7 +729,7 @@ public static Density FromFemtogramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromFemtogramsPerLiter(double value) + public static Density FromFemtogramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.FemtogramPerLiter); } @@ -739,7 +737,7 @@ public static Density FromFemtogramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromFemtogramsPerMilliliter(double value) + public static Density FromFemtogramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.FemtogramPerMilliliter); } @@ -747,7 +745,7 @@ public static Density FromFemtogramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromGramsPerCubicCentimeter(double value) + public static Density FromGramsPerCubicCentimeter(QuantityValue value) { return new Density(value, DensityUnit.GramPerCubicCentimeter); } @@ -755,7 +753,7 @@ public static Density FromGramsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static Density FromGramsPerCubicFoot(double value) + public static Density FromGramsPerCubicFoot(QuantityValue value) { return new Density(value, DensityUnit.GramPerCubicFoot); } @@ -763,7 +761,7 @@ public static Density FromGramsPerCubicFoot(double value) /// /// Creates a from . /// - public static Density FromGramsPerCubicInch(double value) + public static Density FromGramsPerCubicInch(QuantityValue value) { return new Density(value, DensityUnit.GramPerCubicInch); } @@ -771,7 +769,7 @@ public static Density FromGramsPerCubicInch(double value) /// /// Creates a from . /// - public static Density FromGramsPerCubicMeter(double value) + public static Density FromGramsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.GramPerCubicMeter); } @@ -779,7 +777,7 @@ public static Density FromGramsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromGramsPerCubicMillimeter(double value) + public static Density FromGramsPerCubicMillimeter(QuantityValue value) { return new Density(value, DensityUnit.GramPerCubicMillimeter); } @@ -787,7 +785,7 @@ public static Density FromGramsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static Density FromGramsPerDeciliter(double value) + public static Density FromGramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.GramPerDeciliter); } @@ -795,7 +793,7 @@ public static Density FromGramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromGramsPerLiter(double value) + public static Density FromGramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.GramPerLiter); } @@ -803,7 +801,7 @@ public static Density FromGramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromGramsPerMilliliter(double value) + public static Density FromGramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.GramPerMilliliter); } @@ -811,7 +809,7 @@ public static Density FromGramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromKilogramsPerCubicCentimeter(double value) + public static Density FromKilogramsPerCubicCentimeter(QuantityValue value) { return new Density(value, DensityUnit.KilogramPerCubicCentimeter); } @@ -819,7 +817,7 @@ public static Density FromKilogramsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static Density FromKilogramsPerCubicMeter(double value) + public static Density FromKilogramsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.KilogramPerCubicMeter); } @@ -827,7 +825,7 @@ public static Density FromKilogramsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromKilogramsPerCubicMillimeter(double value) + public static Density FromKilogramsPerCubicMillimeter(QuantityValue value) { return new Density(value, DensityUnit.KilogramPerCubicMillimeter); } @@ -835,7 +833,7 @@ public static Density FromKilogramsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static Density FromKilogramsPerLiter(double value) + public static Density FromKilogramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.KilogramPerLiter); } @@ -843,7 +841,7 @@ public static Density FromKilogramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromKilopoundsPerCubicFoot(double value) + public static Density FromKilopoundsPerCubicFoot(QuantityValue value) { return new Density(value, DensityUnit.KilopoundPerCubicFoot); } @@ -851,7 +849,7 @@ public static Density FromKilopoundsPerCubicFoot(double value) /// /// Creates a from . /// - public static Density FromKilopoundsPerCubicInch(double value) + public static Density FromKilopoundsPerCubicInch(QuantityValue value) { return new Density(value, DensityUnit.KilopoundPerCubicInch); } @@ -859,7 +857,7 @@ public static Density FromKilopoundsPerCubicInch(double value) /// /// Creates a from . /// - public static Density FromKilopoundsPerCubicYard(double value) + public static Density FromKilopoundsPerCubicYard(QuantityValue value) { return new Density(value, DensityUnit.KilopoundPerCubicYard); } @@ -867,7 +865,7 @@ public static Density FromKilopoundsPerCubicYard(double value) /// /// Creates a from . /// - public static Density FromMicrogramsPerCubicMeter(double value) + public static Density FromMicrogramsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.MicrogramPerCubicMeter); } @@ -875,7 +873,7 @@ public static Density FromMicrogramsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromMicrogramsPerDeciliter(double value) + public static Density FromMicrogramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.MicrogramPerDeciliter); } @@ -883,7 +881,7 @@ public static Density FromMicrogramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromMicrogramsPerLiter(double value) + public static Density FromMicrogramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.MicrogramPerLiter); } @@ -891,7 +889,7 @@ public static Density FromMicrogramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromMicrogramsPerMilliliter(double value) + public static Density FromMicrogramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.MicrogramPerMilliliter); } @@ -899,7 +897,7 @@ public static Density FromMicrogramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromMilligramsPerCubicMeter(double value) + public static Density FromMilligramsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.MilligramPerCubicMeter); } @@ -907,7 +905,7 @@ public static Density FromMilligramsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromMilligramsPerDeciliter(double value) + public static Density FromMilligramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.MilligramPerDeciliter); } @@ -915,7 +913,7 @@ public static Density FromMilligramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromMilligramsPerLiter(double value) + public static Density FromMilligramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.MilligramPerLiter); } @@ -923,7 +921,7 @@ public static Density FromMilligramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromMilligramsPerMilliliter(double value) + public static Density FromMilligramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.MilligramPerMilliliter); } @@ -931,7 +929,7 @@ public static Density FromMilligramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromNanogramsPerDeciliter(double value) + public static Density FromNanogramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.NanogramPerDeciliter); } @@ -939,7 +937,7 @@ public static Density FromNanogramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromNanogramsPerLiter(double value) + public static Density FromNanogramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.NanogramPerLiter); } @@ -947,7 +945,7 @@ public static Density FromNanogramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromNanogramsPerMilliliter(double value) + public static Density FromNanogramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.NanogramPerMilliliter); } @@ -955,7 +953,7 @@ public static Density FromNanogramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromPicogramsPerDeciliter(double value) + public static Density FromPicogramsPerDeciliter(QuantityValue value) { return new Density(value, DensityUnit.PicogramPerDeciliter); } @@ -963,7 +961,7 @@ public static Density FromPicogramsPerDeciliter(double value) /// /// Creates a from . /// - public static Density FromPicogramsPerLiter(double value) + public static Density FromPicogramsPerLiter(QuantityValue value) { return new Density(value, DensityUnit.PicogramPerLiter); } @@ -971,7 +969,7 @@ public static Density FromPicogramsPerLiter(double value) /// /// Creates a from . /// - public static Density FromPicogramsPerMilliliter(double value) + public static Density FromPicogramsPerMilliliter(QuantityValue value) { return new Density(value, DensityUnit.PicogramPerMilliliter); } @@ -979,7 +977,7 @@ public static Density FromPicogramsPerMilliliter(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicCentimeter(double value) + public static Density FromPoundsPerCubicCentimeter(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicCentimeter); } @@ -987,7 +985,7 @@ public static Density FromPoundsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicFoot(double value) + public static Density FromPoundsPerCubicFoot(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicFoot); } @@ -995,7 +993,7 @@ public static Density FromPoundsPerCubicFoot(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicInch(double value) + public static Density FromPoundsPerCubicInch(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicInch); } @@ -1003,7 +1001,7 @@ public static Density FromPoundsPerCubicInch(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicMeter(double value) + public static Density FromPoundsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicMeter); } @@ -1011,7 +1009,7 @@ public static Density FromPoundsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicMillimeter(double value) + public static Density FromPoundsPerCubicMillimeter(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicMillimeter); } @@ -1019,7 +1017,7 @@ public static Density FromPoundsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static Density FromPoundsPerCubicYard(double value) + public static Density FromPoundsPerCubicYard(QuantityValue value) { return new Density(value, DensityUnit.PoundPerCubicYard); } @@ -1027,7 +1025,7 @@ public static Density FromPoundsPerCubicYard(double value) /// /// Creates a from . /// - public static Density FromPoundsPerImperialGallon(double value) + public static Density FromPoundsPerImperialGallon(QuantityValue value) { return new Density(value, DensityUnit.PoundPerImperialGallon); } @@ -1035,7 +1033,7 @@ public static Density FromPoundsPerImperialGallon(double value) /// /// Creates a from . /// - public static Density FromPoundsPerUSGallon(double value) + public static Density FromPoundsPerUSGallon(QuantityValue value) { return new Density(value, DensityUnit.PoundPerUSGallon); } @@ -1043,7 +1041,7 @@ public static Density FromPoundsPerUSGallon(double value) /// /// Creates a from . /// - public static Density FromSlugsPerCubicCentimeter(double value) + public static Density FromSlugsPerCubicCentimeter(QuantityValue value) { return new Density(value, DensityUnit.SlugPerCubicCentimeter); } @@ -1051,7 +1049,7 @@ public static Density FromSlugsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static Density FromSlugsPerCubicFoot(double value) + public static Density FromSlugsPerCubicFoot(QuantityValue value) { return new Density(value, DensityUnit.SlugPerCubicFoot); } @@ -1059,7 +1057,7 @@ public static Density FromSlugsPerCubicFoot(double value) /// /// Creates a from . /// - public static Density FromSlugsPerCubicInch(double value) + public static Density FromSlugsPerCubicInch(QuantityValue value) { return new Density(value, DensityUnit.SlugPerCubicInch); } @@ -1067,7 +1065,7 @@ public static Density FromSlugsPerCubicInch(double value) /// /// Creates a from . /// - public static Density FromSlugsPerCubicMeter(double value) + public static Density FromSlugsPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.SlugPerCubicMeter); } @@ -1075,7 +1073,7 @@ public static Density FromSlugsPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromSlugsPerCubicMillimeter(double value) + public static Density FromSlugsPerCubicMillimeter(QuantityValue value) { return new Density(value, DensityUnit.SlugPerCubicMillimeter); } @@ -1083,7 +1081,7 @@ public static Density FromSlugsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static Density FromTonnesPerCubicCentimeter(double value) + public static Density FromTonnesPerCubicCentimeter(QuantityValue value) { return new Density(value, DensityUnit.TonnePerCubicCentimeter); } @@ -1091,7 +1089,7 @@ public static Density FromTonnesPerCubicCentimeter(double value) /// /// Creates a from . /// - public static Density FromTonnesPerCubicFoot(double value) + public static Density FromTonnesPerCubicFoot(QuantityValue value) { return new Density(value, DensityUnit.TonnePerCubicFoot); } @@ -1099,7 +1097,7 @@ public static Density FromTonnesPerCubicFoot(double value) /// /// Creates a from . /// - public static Density FromTonnesPerCubicInch(double value) + public static Density FromTonnesPerCubicInch(QuantityValue value) { return new Density(value, DensityUnit.TonnePerCubicInch); } @@ -1107,7 +1105,7 @@ public static Density FromTonnesPerCubicInch(double value) /// /// Creates a from . /// - public static Density FromTonnesPerCubicMeter(double value) + public static Density FromTonnesPerCubicMeter(QuantityValue value) { return new Density(value, DensityUnit.TonnePerCubicMeter); } @@ -1115,7 +1113,7 @@ public static Density FromTonnesPerCubicMeter(double value) /// /// Creates a from . /// - public static Density FromTonnesPerCubicMillimeter(double value) + public static Density FromTonnesPerCubicMillimeter(QuantityValue value) { return new Density(value, DensityUnit.TonnePerCubicMillimeter); } @@ -1126,7 +1124,7 @@ public static Density FromTonnesPerCubicMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// Density unit value. - public static Density From(double value, DensityUnit fromUnit) + public static Density From(QuantityValue value, DensityUnit fromUnit) { return new Density(value, fromUnit); } @@ -1298,25 +1296,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi } /// Get from multiplying value and . - public static Density operator *(double left, Density right) + public static Density operator *(QuantityValue left, Density right) { return new Density(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Density operator *(Density left, double right) + public static Density operator *(Density left, QuantityValue right) { return new Density(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Density operator /(Density left, double right) + public static Density operator /(Density left, QuantityValue right) { return new Density(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Density left, Density right) + public static QuantityValue operator /(Density left, Density right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1361,8 +1359,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); } - /// Get from / . - public static SpecificVolume operator /(double value, Density density) + /// Get from / . + public static SpecificVolume operator /(QuantityValue value, Density density) { return SpecificVolume.FromCubicMetersPerKilogram(value / density.KilogramsPerCubicMeter); } @@ -1373,8 +1371,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return SpecificWeight.FromNewtonsPerCubicMeter(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared); } - /// Get from * . - public static double operator *(Density density, SpecificVolume specificVolume) + /// Get from * . + public static QuantityValue operator *(Density density, SpecificVolume specificVolume) { return density.KilogramsPerCubicMeter * specificVolume.CubicMetersPerKilogram; } @@ -1407,27 +1405,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Density left, Density right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Density other, Density tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Density left, Density right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Density otherQuantity)) @@ -1437,15 +1428,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Density other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1528,10 +1516,10 @@ public bool Equals(Density other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1548,7 +1536,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Density other, Density tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1561,7 +1549,12 @@ public bool Equals(Density other, Density tolerance) /// A hash code for the current Density. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1572,7 +1565,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DensityUnit unit) + public QuantityValue As(DensityUnit unit) { if (Unit == unit) return Value; @@ -1581,7 +1574,7 @@ public double As(DensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1596,7 +1589,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); @@ -1662,118 +1655,118 @@ private bool TryToUnit(DensityUnit unit, [NotNullWhen(true)] out Density? conver Density? convertedOrNull = (Unit, unit) switch { // DensityUnit -> BaseUnit - (DensityUnit.CentigramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-2d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.CentigramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-2d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.CentigramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-2d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.DecigramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-1d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.DecigramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-1d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.DecigramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-1d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.FemtogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-15d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.FemtogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-15d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.FemtogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-15d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-3, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 0.0353146667214886, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 61.0237440947323, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e3, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-6, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-1, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.GramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-3, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilogramPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilogramPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-6) * 1e3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1e3, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilopoundPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 0.062427961) * 1e3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilopoundPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 3.6127298147753e-5) * 1e3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.KilopoundPerCubicYard, DensityUnit.KilogramPerCubicMeter) => new Density((_value * (0.45359237 / 0.9144 / 0.9144 / 0.9144)) * 1e3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MicrogramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e3) * 1e-6d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MicrogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-6d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MicrogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-6d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MicrogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-6d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MilligramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e3) * 1e-3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MilligramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MilligramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.MilligramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-3d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.NanogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-9d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.NanogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-9d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.NanogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-9d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PicogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-1) * 1e-12d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PicogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1) * 1e-12d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PicogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density((_value / 1e-3) * 1e-12d, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 2.204622621848775e-6, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 0.062427961, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 3.6127298147753e-5, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 2.204622621848775, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 2.204622621848775e-9, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerCubicYard, DensityUnit.KilogramPerCubicMeter) => new Density(_value * (0.45359237 / 0.9144 / 0.9144 / 0.9144), DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerImperialGallon, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 9.9776398e1, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.PoundPerUSGallon, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1.19826427e2, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.CentigramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 10, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.CentigramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.CentigramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 10, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.DecigramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.DecigramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 10, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.DecigramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 100, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.FemtogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100000000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.FemtogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.FemtogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(176573333607443, 5000000000000000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(610237440947323, 10000000000000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 10, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.GramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilogramPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilogramPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilopoundPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(1000000000000, 62427961, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilopoundPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(100, 36127298147753, false) * BigInteger.Pow(10, 19), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.KilopoundPerCubicYard, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(3543690390625, 5973084828, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MicrogramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MicrogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MicrogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MicrogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MilligramPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MilligramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MilligramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.MilligramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.NanogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.NanogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.NanogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PicogramPerDeciliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 100000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PicogramPerLiter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PicogramPerMilliliter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(4, 88184904873951, false) * BigInteger.Pow(10, 19), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(1000000000, 62427961, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(1000000000000000000, 36127298147753, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(40000000000000, 88184904873951, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(4000, 88184904873951, false) * BigInteger.Pow(10, 19), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerCubicYard, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(28349523125, 47784678624, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerImperialGallon, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(49888199, 500000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.PoundPerUSGallon, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(119826427, 1000000, false), DensityUnit.KilogramPerCubicMeter), (DensityUnit.SlugPerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 14593903, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.SlugPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 515.378818, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.SlugPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 890574.60201535, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.SlugPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 14.5939, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.SlugPerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(257689409, 500000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.SlugPerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(17811492040307, 20000000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.SlugPerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(145939, 10000, false), DensityUnit.KilogramPerCubicMeter), (DensityUnit.SlugPerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 14593903000, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.TonnePerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-9, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.TonnePerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 3.53146667214886e4, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.TonnePerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 6.10237440947323e7, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.TonnePerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 0.001, DensityUnit.KilogramPerCubicMeter), - (DensityUnit.TonnePerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value / 1e-12, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.TonnePerCubicCentimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000000000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.TonnePerCubicFoot, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(176573333607443, 5000000000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.TonnePerCubicInch, DensityUnit.KilogramPerCubicMeter) => new Density(_value * new QuantityValue(610237440947323, 10000000, false), DensityUnit.KilogramPerCubicMeter), + (DensityUnit.TonnePerCubicMeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000, DensityUnit.KilogramPerCubicMeter), + (DensityUnit.TonnePerCubicMillimeter, DensityUnit.KilogramPerCubicMeter) => new Density(_value * 1000000000000, DensityUnit.KilogramPerCubicMeter), // BaseUnit -> DensityUnit - (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerDeciliter) => new Density((_value * 1e-1) / 1e-2d, DensityUnit.CentigramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerLiter) => new Density((_value * 1) / 1e-2d, DensityUnit.CentigramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerMilliliter) => new Density((_value * 1e-3) / 1e-2d, DensityUnit.CentigramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerDeciliter) => new Density((_value * 1e-1) / 1e-1d, DensityUnit.DecigramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerLiter) => new Density((_value * 1) / 1e-1d, DensityUnit.DecigramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerMilliliter) => new Density((_value * 1e-3) / 1e-1d, DensityUnit.DecigramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerDeciliter) => new Density((_value * 1e-1) / 1e-15d, DensityUnit.FemtogramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerLiter) => new Density((_value * 1) / 1e-15d, DensityUnit.FemtogramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerMilliliter) => new Density((_value * 1e-3) / 1e-15d, DensityUnit.FemtogramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicCentimeter) => new Density(_value * 1e-3, DensityUnit.GramPerCubicCentimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicFoot) => new Density(_value / 0.0353146667214886, DensityUnit.GramPerCubicFoot), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicInch) => new Density(_value / 61.0237440947323, DensityUnit.GramPerCubicInch), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicMeter) => new Density(_value * 1e3, DensityUnit.GramPerCubicMeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicMillimeter) => new Density(_value * 1e-6, DensityUnit.GramPerCubicMillimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerDeciliter) => new Density(_value * 1e-1, DensityUnit.GramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerLiter) => new Density(_value * 1, DensityUnit.GramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerMilliliter) => new Density(_value * 1e-3, DensityUnit.GramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerCubicCentimeter) => new Density((_value * 1e-3) / 1e3d, DensityUnit.KilogramPerCubicCentimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerCubicMillimeter) => new Density((_value * 1e-6) / 1e3d, DensityUnit.KilogramPerCubicMillimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerLiter) => new Density(_value / 1e3, DensityUnit.KilogramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicFoot) => new Density((_value * 0.062427961) / 1e3d, DensityUnit.KilopoundPerCubicFoot), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicInch) => new Density((_value * 3.6127298147753e-5) / 1e3d, DensityUnit.KilopoundPerCubicInch), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicYard) => new Density((_value / (0.45359237 / 0.9144 / 0.9144 / 0.9144)) / 1e3d, DensityUnit.KilopoundPerCubicYard), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerCubicMeter) => new Density((_value * 1e3) / 1e-6d, DensityUnit.MicrogramPerCubicMeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerDeciliter) => new Density((_value * 1e-1) / 1e-6d, DensityUnit.MicrogramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerLiter) => new Density((_value * 1) / 1e-6d, DensityUnit.MicrogramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerMilliliter) => new Density((_value * 1e-3) / 1e-6d, DensityUnit.MicrogramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerCubicMeter) => new Density((_value * 1e3) / 1e-3d, DensityUnit.MilligramPerCubicMeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerDeciliter) => new Density((_value * 1e-1) / 1e-3d, DensityUnit.MilligramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerLiter) => new Density((_value * 1) / 1e-3d, DensityUnit.MilligramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerMilliliter) => new Density((_value * 1e-3) / 1e-3d, DensityUnit.MilligramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerDeciliter) => new Density((_value * 1e-1) / 1e-9d, DensityUnit.NanogramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerLiter) => new Density((_value * 1) / 1e-9d, DensityUnit.NanogramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerMilliliter) => new Density((_value * 1e-3) / 1e-9d, DensityUnit.NanogramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerDeciliter) => new Density((_value * 1e-1) / 1e-12d, DensityUnit.PicogramPerDeciliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerLiter) => new Density((_value * 1) / 1e-12d, DensityUnit.PicogramPerLiter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerMilliliter) => new Density((_value * 1e-3) / 1e-12d, DensityUnit.PicogramPerMilliliter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicCentimeter) => new Density(_value * 2.204622621848775e-6, DensityUnit.PoundPerCubicCentimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicFoot) => new Density(_value * 0.062427961, DensityUnit.PoundPerCubicFoot), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicInch) => new Density(_value * 3.6127298147753e-5, DensityUnit.PoundPerCubicInch), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicMeter) => new Density(_value * 2.204622621848775, DensityUnit.PoundPerCubicMeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicMillimeter) => new Density(_value * 2.204622621848775e-9, DensityUnit.PoundPerCubicMillimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicYard) => new Density(_value / (0.45359237 / 0.9144 / 0.9144 / 0.9144), DensityUnit.PoundPerCubicYard), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerImperialGallon) => new Density(_value / 9.9776398e1, DensityUnit.PoundPerImperialGallon), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerUSGallon) => new Density(_value / 1.19826427e2, DensityUnit.PoundPerUSGallon), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerDeciliter) => new Density(_value * 10, DensityUnit.CentigramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerLiter) => new Density(_value * 100, DensityUnit.CentigramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.CentigramPerMilliliter) => new Density(_value / 10, DensityUnit.CentigramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerDeciliter) => new Density(_value, DensityUnit.DecigramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerLiter) => new Density(_value * 10, DensityUnit.DecigramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.DecigramPerMilliliter) => new Density(_value / 100, DensityUnit.DecigramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerDeciliter) => new Density(_value * 100000000000000, DensityUnit.FemtogramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerLiter) => new Density(_value * 1000000000000000, DensityUnit.FemtogramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.FemtogramPerMilliliter) => new Density(_value * 1000000000000, DensityUnit.FemtogramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicCentimeter) => new Density(_value / 1000, DensityUnit.GramPerCubicCentimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicFoot) => new Density(_value * new QuantityValue(5000000000000000, 176573333607443, false), DensityUnit.GramPerCubicFoot), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicInch) => new Density(_value * new QuantityValue(10000000000000, 610237440947323, false), DensityUnit.GramPerCubicInch), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicMeter) => new Density(_value * 1000, DensityUnit.GramPerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerCubicMillimeter) => new Density(_value / 1000000, DensityUnit.GramPerCubicMillimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerDeciliter) => new Density(_value / 10, DensityUnit.GramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerLiter) => new Density(_value, DensityUnit.GramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.GramPerMilliliter) => new Density(_value / 1000, DensityUnit.GramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerCubicCentimeter) => new Density(_value / 1000000, DensityUnit.KilogramPerCubicCentimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerCubicMillimeter) => new Density(_value / 1000000000, DensityUnit.KilogramPerCubicMillimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerLiter) => new Density(_value / 1000, DensityUnit.KilogramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicFoot) => new Density(_value * new QuantityValue(62427961, 1000000000000, false), DensityUnit.KilopoundPerCubicFoot), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicInch) => new Density(_value * new QuantityValue(36127298147753, 100, false) / BigInteger.Pow(10, 19), DensityUnit.KilopoundPerCubicInch), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.KilopoundPerCubicYard) => new Density(_value * new QuantityValue(5973084828, 3543690390625, false), DensityUnit.KilopoundPerCubicYard), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerCubicMeter) => new Density(_value * 1000000000, DensityUnit.MicrogramPerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerDeciliter) => new Density(_value * 100000, DensityUnit.MicrogramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerLiter) => new Density(_value * 1000000, DensityUnit.MicrogramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MicrogramPerMilliliter) => new Density(_value * 1000, DensityUnit.MicrogramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerCubicMeter) => new Density(_value * 1000000, DensityUnit.MilligramPerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerDeciliter) => new Density(_value * 100, DensityUnit.MilligramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerLiter) => new Density(_value * 1000, DensityUnit.MilligramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.MilligramPerMilliliter) => new Density(_value, DensityUnit.MilligramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerDeciliter) => new Density(_value * 100000000, DensityUnit.NanogramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerLiter) => new Density(_value * 1000000000, DensityUnit.NanogramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.NanogramPerMilliliter) => new Density(_value * 1000000, DensityUnit.NanogramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerDeciliter) => new Density(_value * 100000000000, DensityUnit.PicogramPerDeciliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerLiter) => new Density(_value * 1000000000000, DensityUnit.PicogramPerLiter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PicogramPerMilliliter) => new Density(_value * 1000000000, DensityUnit.PicogramPerMilliliter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicCentimeter) => new Density(_value * new QuantityValue(88184904873951, 4, false) / BigInteger.Pow(10, 19), DensityUnit.PoundPerCubicCentimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicFoot) => new Density(_value * new QuantityValue(62427961, 1000000000, false), DensityUnit.PoundPerCubicFoot), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicInch) => new Density(_value * new QuantityValue(36127298147753, 1000000000000000000, false), DensityUnit.PoundPerCubicInch), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicMeter) => new Density(_value * new QuantityValue(88184904873951, 40000000000000, false), DensityUnit.PoundPerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicMillimeter) => new Density(_value * new QuantityValue(88184904873951, 4000, false) / BigInteger.Pow(10, 19), DensityUnit.PoundPerCubicMillimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerCubicYard) => new Density(_value * new QuantityValue(47784678624, 28349523125, false), DensityUnit.PoundPerCubicYard), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerImperialGallon) => new Density(_value * new QuantityValue(500000, 49888199, false), DensityUnit.PoundPerImperialGallon), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.PoundPerUSGallon) => new Density(_value * new QuantityValue(1000000, 119826427, false), DensityUnit.PoundPerUSGallon), (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicCentimeter) => new Density(_value / 14593903, DensityUnit.SlugPerCubicCentimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicFoot) => new Density(_value * 0.00194032033, DensityUnit.SlugPerCubicFoot), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicInch) => new Density(_value / 890574.60201535, DensityUnit.SlugPerCubicInch), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicMeter) => new Density(_value / 14.5939, DensityUnit.SlugPerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicFoot) => new Density(_value * new QuantityValue(194032033, 100000000000, false), DensityUnit.SlugPerCubicFoot), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicInch) => new Density(_value * new QuantityValue(20000000, 17811492040307, false), DensityUnit.SlugPerCubicInch), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicMeter) => new Density(_value * new QuantityValue(10000, 145939, false), DensityUnit.SlugPerCubicMeter), (DensityUnit.KilogramPerCubicMeter, DensityUnit.SlugPerCubicMillimeter) => new Density(_value / 14593903000, DensityUnit.SlugPerCubicMillimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicCentimeter) => new Density(_value * 1e-9, DensityUnit.TonnePerCubicCentimeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicFoot) => new Density(_value / 3.53146667214886e4, DensityUnit.TonnePerCubicFoot), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicInch) => new Density(_value / 6.10237440947323e7, DensityUnit.TonnePerCubicInch), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMeter) => new Density(_value * 0.001, DensityUnit.TonnePerCubicMeter), - (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMillimeter) => new Density(_value * 1e-12, DensityUnit.TonnePerCubicMillimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicCentimeter) => new Density(_value / 1000000000, DensityUnit.TonnePerCubicCentimeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicFoot) => new Density(_value * new QuantityValue(5000000000, 176573333607443, false), DensityUnit.TonnePerCubicFoot), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicInch) => new Density(_value * new QuantityValue(10000000, 610237440947323, false), DensityUnit.TonnePerCubicInch), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMeter) => new Density(_value / 1000, DensityUnit.TonnePerCubicMeter), + (DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMillimeter) => new Density(_value / 1000000000000, DensityUnit.TonnePerCubicMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 188f396f88..d0a696af08 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -67,7 +65,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -107,7 +105,7 @@ static Duration() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Duration(double value, DurationUnit unit) + public Duration(QuantityValue value, DurationUnit unit) { _value = value; _unit = unit; @@ -121,7 +119,7 @@ public Duration(double value, DurationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Duration(double value, UnitSystem unitSystem) + public Duration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -172,10 +170,10 @@ public Duration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -200,57 +198,57 @@ public Duration(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Days => As(DurationUnit.Day); + public QuantityValue Days => As(DurationUnit.Day); /// /// Gets a value of this quantity converted into /// - public double Hours => As(DurationUnit.Hour); + public QuantityValue Hours => As(DurationUnit.Hour); /// /// Gets a value of this quantity converted into /// - public double JulianYears => As(DurationUnit.JulianYear); + public QuantityValue JulianYears => As(DurationUnit.JulianYear); /// /// Gets a value of this quantity converted into /// - public double Microseconds => As(DurationUnit.Microsecond); + public QuantityValue Microseconds => As(DurationUnit.Microsecond); /// /// Gets a value of this quantity converted into /// - public double Milliseconds => As(DurationUnit.Millisecond); + public QuantityValue Milliseconds => As(DurationUnit.Millisecond); /// /// Gets a value of this quantity converted into /// - public double Minutes => As(DurationUnit.Minute); + public QuantityValue Minutes => As(DurationUnit.Minute); /// /// Gets a value of this quantity converted into /// - public double Months30 => As(DurationUnit.Month30); + public QuantityValue Months30 => As(DurationUnit.Month30); /// /// Gets a value of this quantity converted into /// - public double Nanoseconds => As(DurationUnit.Nanosecond); + public QuantityValue Nanoseconds => As(DurationUnit.Nanosecond); /// /// Gets a value of this quantity converted into /// - public double Seconds => As(DurationUnit.Second); + public QuantityValue Seconds => As(DurationUnit.Second); /// /// Gets a value of this quantity converted into /// - public double Weeks => As(DurationUnit.Week); + public QuantityValue Weeks => As(DurationUnit.Week); /// /// Gets a value of this quantity converted into /// - public double Years365 => As(DurationUnit.Year365); + public QuantityValue Years365 => As(DurationUnit.Year365); #endregion @@ -318,7 +316,7 @@ public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static Duration FromDays(double value) + public static Duration FromDays(QuantityValue value) { return new Duration(value, DurationUnit.Day); } @@ -326,7 +324,7 @@ public static Duration FromDays(double value) /// /// Creates a from . /// - public static Duration FromHours(double value) + public static Duration FromHours(QuantityValue value) { return new Duration(value, DurationUnit.Hour); } @@ -334,7 +332,7 @@ public static Duration FromHours(double value) /// /// Creates a from . /// - public static Duration FromJulianYears(double value) + public static Duration FromJulianYears(QuantityValue value) { return new Duration(value, DurationUnit.JulianYear); } @@ -342,7 +340,7 @@ public static Duration FromJulianYears(double value) /// /// Creates a from . /// - public static Duration FromMicroseconds(double value) + public static Duration FromMicroseconds(QuantityValue value) { return new Duration(value, DurationUnit.Microsecond); } @@ -350,7 +348,7 @@ public static Duration FromMicroseconds(double value) /// /// Creates a from . /// - public static Duration FromMilliseconds(double value) + public static Duration FromMilliseconds(QuantityValue value) { return new Duration(value, DurationUnit.Millisecond); } @@ -358,7 +356,7 @@ public static Duration FromMilliseconds(double value) /// /// Creates a from . /// - public static Duration FromMinutes(double value) + public static Duration FromMinutes(QuantityValue value) { return new Duration(value, DurationUnit.Minute); } @@ -366,7 +364,7 @@ public static Duration FromMinutes(double value) /// /// Creates a from . /// - public static Duration FromMonths30(double value) + public static Duration FromMonths30(QuantityValue value) { return new Duration(value, DurationUnit.Month30); } @@ -374,7 +372,7 @@ public static Duration FromMonths30(double value) /// /// Creates a from . /// - public static Duration FromNanoseconds(double value) + public static Duration FromNanoseconds(QuantityValue value) { return new Duration(value, DurationUnit.Nanosecond); } @@ -382,7 +380,7 @@ public static Duration FromNanoseconds(double value) /// /// Creates a from . /// - public static Duration FromSeconds(double value) + public static Duration FromSeconds(QuantityValue value) { return new Duration(value, DurationUnit.Second); } @@ -390,7 +388,7 @@ public static Duration FromSeconds(double value) /// /// Creates a from . /// - public static Duration FromWeeks(double value) + public static Duration FromWeeks(QuantityValue value) { return new Duration(value, DurationUnit.Week); } @@ -398,7 +396,7 @@ public static Duration FromWeeks(double value) /// /// Creates a from . /// - public static Duration FromYears365(double value) + public static Duration FromYears365(QuantityValue value) { return new Duration(value, DurationUnit.Year365); } @@ -409,7 +407,7 @@ public static Duration FromYears365(double value) /// Value to convert from. /// Unit to convert from. /// Duration unit value. - public static Duration From(double value, DurationUnit fromUnit) + public static Duration From(QuantityValue value, DurationUnit fromUnit) { return new Duration(value, fromUnit); } @@ -581,25 +579,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat } /// Get from multiplying value and . - public static Duration operator *(double left, Duration right) + public static Duration operator *(QuantityValue left, Duration right) { return new Duration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Duration operator *(Duration left, double right) + public static Duration operator *(Duration left, QuantityValue right) { return new Duration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Duration operator /(Duration left, double right) + public static Duration operator /(Duration left, QuantityValue right) { return new Duration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Duration left, Duration right) + public static QuantityValue operator /(Duration left, Duration right) { return left.Seconds / right.Seconds; } @@ -720,27 +718,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Duration left, Duration right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Duration other, Duration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Duration left, Duration right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Duration otherQuantity)) @@ -750,15 +741,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Duration other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -841,10 +829,10 @@ public bool Equals(Duration other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -861,7 +849,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Duration other, Duration tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -874,7 +862,12 @@ public bool Equals(Duration other, Duration tolerance) /// A hash code for the current Duration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -885,7 +878,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DurationUnit unit) + public QuantityValue As(DurationUnit unit) { if (Unit == unit) return Value; @@ -894,7 +887,7 @@ public double As(DurationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -909,7 +902,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); @@ -975,28 +968,28 @@ private bool TryToUnit(DurationUnit unit, [NotNullWhen(true)] out Duration? conv Duration? convertedOrNull = (Unit, unit) switch { // DurationUnit -> BaseUnit - (DurationUnit.Day, DurationUnit.Second) => new Duration(_value * 24 * 3600, DurationUnit.Second), + (DurationUnit.Day, DurationUnit.Second) => new Duration(_value * 86400, DurationUnit.Second), (DurationUnit.Hour, DurationUnit.Second) => new Duration(_value * 3600, DurationUnit.Second), - (DurationUnit.JulianYear, DurationUnit.Second) => new Duration(_value * 365.25 * 24 * 3600, DurationUnit.Second), - (DurationUnit.Microsecond, DurationUnit.Second) => new Duration((_value) * 1e-6d, DurationUnit.Second), - (DurationUnit.Millisecond, DurationUnit.Second) => new Duration((_value) * 1e-3d, DurationUnit.Second), + (DurationUnit.JulianYear, DurationUnit.Second) => new Duration(_value * 31557600, DurationUnit.Second), + (DurationUnit.Microsecond, DurationUnit.Second) => new Duration(_value / 1000000, DurationUnit.Second), + (DurationUnit.Millisecond, DurationUnit.Second) => new Duration(_value / 1000, DurationUnit.Second), (DurationUnit.Minute, DurationUnit.Second) => new Duration(_value * 60, DurationUnit.Second), - (DurationUnit.Month30, DurationUnit.Second) => new Duration(_value * 30 * 24 * 3600, DurationUnit.Second), - (DurationUnit.Nanosecond, DurationUnit.Second) => new Duration((_value) * 1e-9d, DurationUnit.Second), - (DurationUnit.Week, DurationUnit.Second) => new Duration(_value * 7 * 24 * 3600, DurationUnit.Second), - (DurationUnit.Year365, DurationUnit.Second) => new Duration(_value * 365 * 24 * 3600, DurationUnit.Second), + (DurationUnit.Month30, DurationUnit.Second) => new Duration(_value * 2592000, DurationUnit.Second), + (DurationUnit.Nanosecond, DurationUnit.Second) => new Duration(_value / 1000000000, DurationUnit.Second), + (DurationUnit.Week, DurationUnit.Second) => new Duration(_value * 604800, DurationUnit.Second), + (DurationUnit.Year365, DurationUnit.Second) => new Duration(_value * 31536000, DurationUnit.Second), // BaseUnit -> DurationUnit - (DurationUnit.Second, DurationUnit.Day) => new Duration(_value / (24 * 3600), DurationUnit.Day), + (DurationUnit.Second, DurationUnit.Day) => new Duration(_value / 86400, DurationUnit.Day), (DurationUnit.Second, DurationUnit.Hour) => new Duration(_value / 3600, DurationUnit.Hour), - (DurationUnit.Second, DurationUnit.JulianYear) => new Duration(_value / (365.25 * 24 * 3600), DurationUnit.JulianYear), - (DurationUnit.Second, DurationUnit.Microsecond) => new Duration((_value) / 1e-6d, DurationUnit.Microsecond), - (DurationUnit.Second, DurationUnit.Millisecond) => new Duration((_value) / 1e-3d, DurationUnit.Millisecond), + (DurationUnit.Second, DurationUnit.JulianYear) => new Duration(_value / 31557600, DurationUnit.JulianYear), + (DurationUnit.Second, DurationUnit.Microsecond) => new Duration(_value * 1000000, DurationUnit.Microsecond), + (DurationUnit.Second, DurationUnit.Millisecond) => new Duration(_value * 1000, DurationUnit.Millisecond), (DurationUnit.Second, DurationUnit.Minute) => new Duration(_value / 60, DurationUnit.Minute), - (DurationUnit.Second, DurationUnit.Month30) => new Duration(_value / (30 * 24 * 3600), DurationUnit.Month30), - (DurationUnit.Second, DurationUnit.Nanosecond) => new Duration((_value) / 1e-9d, DurationUnit.Nanosecond), - (DurationUnit.Second, DurationUnit.Week) => new Duration(_value / (7 * 24 * 3600), DurationUnit.Week), - (DurationUnit.Second, DurationUnit.Year365) => new Duration(_value / (365 * 24 * 3600), DurationUnit.Year365), + (DurationUnit.Second, DurationUnit.Month30) => new Duration(_value / 2592000, DurationUnit.Month30), + (DurationUnit.Second, DurationUnit.Nanosecond) => new Duration(_value * 1000000000, DurationUnit.Nanosecond), + (DurationUnit.Second, DurationUnit.Week) => new Duration(_value / 604800, DurationUnit.Week), + (DurationUnit.Second, DurationUnit.Year365) => new Duration(_value / 31536000, DurationUnit.Year365), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index b38c05ab62..5d15075e9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +95,7 @@ static DynamicViscosity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public DynamicViscosity(double value, DynamicViscosityUnit unit) + public DynamicViscosity(QuantityValue value, DynamicViscosityUnit unit) { _value = value; _unit = unit; @@ -111,7 +109,7 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public DynamicViscosity(double value, UnitSystem unitSystem) + public DynamicViscosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,10 +160,10 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -190,52 +188,52 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Centipoise => As(DynamicViscosityUnit.Centipoise); + public QuantityValue Centipoise => As(DynamicViscosityUnit.Centipoise); /// /// Gets a value of this quantity converted into /// - public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); + public QuantityValue MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); /// /// Gets a value of this quantity converted into /// - public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); + public QuantityValue MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); /// /// Gets a value of this quantity converted into /// - public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); + public QuantityValue NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); /// /// Gets a value of this quantity converted into /// - public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond); + public QuantityValue PascalSeconds => As(DynamicViscosityUnit.PascalSecond); /// /// Gets a value of this quantity converted into /// - public double Poise => As(DynamicViscosityUnit.Poise); + public QuantityValue Poise => As(DynamicViscosityUnit.Poise); /// /// Gets a value of this quantity converted into /// - public double PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + public QuantityValue PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); + public QuantityValue PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); /// /// Gets a value of this quantity converted into /// - public double PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); + public QuantityValue PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); /// /// Gets a value of this quantity converted into /// - public double Reyns => As(DynamicViscosityUnit.Reyn); + public QuantityValue Reyns => As(DynamicViscosityUnit.Reyn); #endregion @@ -301,7 +299,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? /// /// Creates a from . /// - public static DynamicViscosity FromCentipoise(double value) + public static DynamicViscosity FromCentipoise(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise); } @@ -309,7 +307,7 @@ public static DynamicViscosity FromCentipoise(double value) /// /// Creates a from . /// - public static DynamicViscosity FromMicropascalSeconds(double value) + public static DynamicViscosity FromMicropascalSeconds(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond); } @@ -317,7 +315,7 @@ public static DynamicViscosity FromMicropascalSeconds(double value) /// /// Creates a from . /// - public static DynamicViscosity FromMillipascalSeconds(double value) + public static DynamicViscosity FromMillipascalSeconds(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond); } @@ -325,7 +323,7 @@ public static DynamicViscosity FromMillipascalSeconds(double value) /// /// Creates a from . /// - public static DynamicViscosity FromNewtonSecondsPerMeterSquared(double value) + public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared); } @@ -333,7 +331,7 @@ public static DynamicViscosity FromNewtonSecondsPerMeterSquared(double value) /// /// Creates a from . /// - public static DynamicViscosity FromPascalSeconds(double value) + public static DynamicViscosity FromPascalSeconds(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond); } @@ -341,7 +339,7 @@ public static DynamicViscosity FromPascalSeconds(double value) /// /// Creates a from . /// - public static DynamicViscosity FromPoise(double value) + public static DynamicViscosity FromPoise(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.Poise); } @@ -349,7 +347,7 @@ public static DynamicViscosity FromPoise(double value) /// /// Creates a from . /// - public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(double value) + public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); } @@ -357,7 +355,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(double value) /// /// Creates a from . /// - public static DynamicViscosity FromPoundsForceSecondPerSquareInch(double value) + public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareInch); } @@ -365,7 +363,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareInch(double value) /// /// Creates a from . /// - public static DynamicViscosity FromPoundsPerFootSecond(double value) + public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.PoundPerFootSecond); } @@ -373,7 +371,7 @@ public static DynamicViscosity FromPoundsPerFootSecond(double value) /// /// Creates a from . /// - public static DynamicViscosity FromReyns(double value) + public static DynamicViscosity FromReyns(QuantityValue value) { return new DynamicViscosity(value, DynamicViscosityUnit.Reyn); } @@ -384,7 +382,7 @@ public static DynamicViscosity FromReyns(double value) /// Value to convert from. /// Unit to convert from. /// DynamicViscosity unit value. - public static DynamicViscosity From(double value, DynamicViscosityUnit fromUnit) + public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fromUnit) { return new DynamicViscosity(value, fromUnit); } @@ -556,25 +554,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam } /// Get from multiplying value and . - public static DynamicViscosity operator *(double left, DynamicViscosity right) + public static DynamicViscosity operator *(QuantityValue left, DynamicViscosity right) { return new DynamicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static DynamicViscosity operator *(DynamicViscosity left, double right) + public static DynamicViscosity operator *(DynamicViscosity left, QuantityValue right) { return new DynamicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static DynamicViscosity operator /(DynamicViscosity left, double right) + public static DynamicViscosity operator /(DynamicViscosity left, QuantityValue right) { return new DynamicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(DynamicViscosity left, DynamicViscosity right) + public static QuantityValue operator /(DynamicViscosity left, DynamicViscosity right) { return left.NewtonSecondsPerMeterSquared / right.NewtonSecondsPerMeterSquared; } @@ -623,27 +621,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(DynamicViscosity left, DynamicViscosity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(DynamicViscosity other, DynamicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(DynamicViscosity left, DynamicViscosity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is DynamicViscosity otherQuantity)) @@ -653,15 +644,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(DynamicViscosity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -744,10 +732,10 @@ public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -764,7 +752,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(DynamicViscosity other, DynamicViscosity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -777,7 +765,12 @@ public bool Equals(DynamicViscosity other, DynamicViscosity tolerance) /// A hash code for the current DynamicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -788,7 +781,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DynamicViscosityUnit unit) + public QuantityValue As(DynamicViscosityUnit unit) { if (Unit == unit) return Value; @@ -797,7 +790,7 @@ public double As(DynamicViscosityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -812,7 +805,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); @@ -878,26 +871,26 @@ private bool TryToUnit(DynamicViscosityUnit unit, [NotNullWhen(true)] out Dynami DynamicViscosity? convertedOrNull = (Unit, unit) switch { // DynamicViscosityUnit -> BaseUnit - (DynamicViscosityUnit.Centipoise, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity((_value / 10) * 1e-2d, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.MicropascalSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity((_value) * 1e-6d, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.MillipascalSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity((_value) * 1e-3d, DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.Centipoise, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value / 1000, DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.MicropascalSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value / 1000000, DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.MillipascalSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value / 1000, DynamicViscosityUnit.NewtonSecondPerMeterSquared), (DynamicViscosityUnit.PascalSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value, DynamicViscosityUnit.NewtonSecondPerMeterSquared), (DynamicViscosityUnit.Poise, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value / 10, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * 4.7880258980335843e1, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * 6.8947572931683613e3, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * 1.4881639, DynamicViscosityUnit.NewtonSecondPerMeterSquared), - (DynamicViscosityUnit.Reyn, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * 6.8947572931683613e3, DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * new QuantityValue(47880258980335843, 1000000000000000, false), DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * new QuantityValue(68947572931683613, 10000000000000, false), DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * new QuantityValue(14881639, 10000000, false), DynamicViscosityUnit.NewtonSecondPerMeterSquared), + (DynamicViscosityUnit.Reyn, DynamicViscosityUnit.NewtonSecondPerMeterSquared) => new DynamicViscosity(_value * new QuantityValue(68947572931683613, 10000000000000, false), DynamicViscosityUnit.NewtonSecondPerMeterSquared), // BaseUnit -> DynamicViscosityUnit - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Centipoise) => new DynamicViscosity((_value * 10) / 1e-2d, DynamicViscosityUnit.Centipoise), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.MicropascalSecond) => new DynamicViscosity((_value) / 1e-6d, DynamicViscosityUnit.MicropascalSecond), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.MillipascalSecond) => new DynamicViscosity((_value) / 1e-3d, DynamicViscosityUnit.MillipascalSecond), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Centipoise) => new DynamicViscosity(_value * 1000, DynamicViscosityUnit.Centipoise), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.MicropascalSecond) => new DynamicViscosity(_value * 1000000, DynamicViscosityUnit.MicropascalSecond), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.MillipascalSecond) => new DynamicViscosity(_value * 1000, DynamicViscosityUnit.MillipascalSecond), (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PascalSecond) => new DynamicViscosity(_value, DynamicViscosityUnit.PascalSecond), (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Poise) => new DynamicViscosity(_value * 10, DynamicViscosityUnit.Poise), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundForceSecondPerSquareFoot) => new DynamicViscosity(_value / 4.7880258980335843e1, DynamicViscosityUnit.PoundForceSecondPerSquareFoot), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundForceSecondPerSquareInch) => new DynamicViscosity(_value / 6.8947572931683613e3, DynamicViscosityUnit.PoundForceSecondPerSquareInch), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundPerFootSecond) => new DynamicViscosity(_value / 1.4881639, DynamicViscosityUnit.PoundPerFootSecond), - (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Reyn) => new DynamicViscosity(_value / 6.8947572931683613e3, DynamicViscosityUnit.Reyn), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundForceSecondPerSquareFoot) => new DynamicViscosity(_value * new QuantityValue(1000000000000000, 47880258980335843, false), DynamicViscosityUnit.PoundForceSecondPerSquareFoot), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundForceSecondPerSquareInch) => new DynamicViscosity(_value * new QuantityValue(10000000000000, 68947572931683613, false), DynamicViscosityUnit.PoundForceSecondPerSquareInch), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundPerFootSecond) => new DynamicViscosity(_value * new QuantityValue(10000000, 14881639, false), DynamicViscosityUnit.PoundPerFootSecond), + (DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Reyn) => new DynamicViscosity(_value * new QuantityValue(10000000000000, 68947572931683613, false), DynamicViscosityUnit.Reyn), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 8dbe6b0d73..760efb5279 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static ElectricAdmittance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) + public ElectricAdmittance(QuantityValue value, ElectricAdmittanceUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricAdmittance(double value, UnitSystem unitSystem) + public ElectricAdmittance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,22 +175,22 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); + public QuantityValue Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); /// /// Gets a value of this quantity converted into /// - public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); + public QuantityValue Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); /// /// Gets a value of this quantity converted into /// - public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); + public QuantityValue Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); /// /// Gets a value of this quantity converted into /// - public double Siemens => As(ElectricAdmittanceUnit.Siemens); + public QuantityValue Siemens => As(ElectricAdmittanceUnit.Siemens); #endregion @@ -243,7 +244,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvide /// /// Creates a from . /// - public static ElectricAdmittance FromMicrosiemens(double value) + public static ElectricAdmittance FromMicrosiemens(QuantityValue value) { return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens); } @@ -251,7 +252,7 @@ public static ElectricAdmittance FromMicrosiemens(double value) /// /// Creates a from . /// - public static ElectricAdmittance FromMillisiemens(double value) + public static ElectricAdmittance FromMillisiemens(QuantityValue value) { return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens); } @@ -259,7 +260,7 @@ public static ElectricAdmittance FromMillisiemens(double value) /// /// Creates a from . /// - public static ElectricAdmittance FromNanosiemens(double value) + public static ElectricAdmittance FromNanosiemens(QuantityValue value) { return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens); } @@ -267,7 +268,7 @@ public static ElectricAdmittance FromNanosiemens(double value) /// /// Creates a from . /// - public static ElectricAdmittance FromSiemens(double value) + public static ElectricAdmittance FromSiemens(QuantityValue value) { return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens); } @@ -278,7 +279,7 @@ public static ElectricAdmittance FromSiemens(double value) /// Value to convert from. /// Unit to convert from. /// ElectricAdmittance unit value. - public static ElectricAdmittance From(double value, ElectricAdmittanceUnit fromUnit) + public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUnit fromUnit) { return new ElectricAdmittance(value, fromUnit); } @@ -450,25 +451,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricAdmittance operator *(double left, ElectricAdmittance right) + public static ElectricAdmittance operator *(QuantityValue left, ElectricAdmittance right) { return new ElectricAdmittance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricAdmittance operator *(ElectricAdmittance left, double right) + public static ElectricAdmittance operator *(ElectricAdmittance left, QuantityValue right) { return new ElectricAdmittance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricAdmittance operator /(ElectricAdmittance left, double right) + public static ElectricAdmittance operator /(ElectricAdmittance left, QuantityValue right) { return new ElectricAdmittance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricAdmittance left, ElectricAdmittance right) + public static QuantityValue operator /(ElectricAdmittance left, ElectricAdmittance right) { return left.Siemens / right.Siemens; } @@ -501,27 +502,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricAdmittance other, ElectricAdmittance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricAdmittance otherQuantity)) @@ -531,15 +525,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricAdmittance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -622,10 +613,10 @@ public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -642,7 +633,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricAdmittance other, ElectricAdmittance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -655,7 +646,12 @@ public bool Equals(ElectricAdmittance other, ElectricAdmittance tolerance) /// A hash code for the current ElectricAdmittance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -666,7 +662,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricAdmittanceUnit unit) + public QuantityValue As(ElectricAdmittanceUnit unit) { if (Unit == unit) return Value; @@ -675,7 +671,7 @@ public double As(ElectricAdmittanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -690,7 +686,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); @@ -756,14 +752,14 @@ private bool TryToUnit(ElectricAdmittanceUnit unit, [NotNullWhen(true)] out Elec ElectricAdmittance? convertedOrNull = (Unit, unit) switch { // ElectricAdmittanceUnit -> BaseUnit - (ElectricAdmittanceUnit.Microsiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance((_value) * 1e-6d, ElectricAdmittanceUnit.Siemens), - (ElectricAdmittanceUnit.Millisiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance((_value) * 1e-3d, ElectricAdmittanceUnit.Siemens), - (ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance((_value) * 1e-9d, ElectricAdmittanceUnit.Siemens), + (ElectricAdmittanceUnit.Microsiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance(_value / 1000000, ElectricAdmittanceUnit.Siemens), + (ElectricAdmittanceUnit.Millisiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance(_value / 1000, ElectricAdmittanceUnit.Siemens), + (ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittanceUnit.Siemens) => new ElectricAdmittance(_value / 1000000000, ElectricAdmittanceUnit.Siemens), // BaseUnit -> ElectricAdmittanceUnit - (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Microsiemens) => new ElectricAdmittance((_value) / 1e-6d, ElectricAdmittanceUnit.Microsiemens), - (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Millisiemens) => new ElectricAdmittance((_value) / 1e-3d, ElectricAdmittanceUnit.Millisiemens), - (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Nanosiemens) => new ElectricAdmittance((_value) / 1e-9d, ElectricAdmittanceUnit.Nanosiemens), + (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Microsiemens) => new ElectricAdmittance(_value * 1000000, ElectricAdmittanceUnit.Microsiemens), + (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Millisiemens) => new ElectricAdmittance(_value * 1000, ElectricAdmittanceUnit.Millisiemens), + (ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Nanosiemens) => new ElectricAdmittance(_value * 1000000000, ElectricAdmittanceUnit.Nanosiemens), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 5042285279..1b845a7a34 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -59,7 +57,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -99,7 +97,7 @@ static ElectricCharge() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricCharge(double value, ElectricChargeUnit unit) + public ElectricCharge(QuantityValue value, ElectricChargeUnit unit) { _value = value; _unit = unit; @@ -113,7 +111,7 @@ public ElectricCharge(double value, ElectricChargeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCharge(double value, UnitSystem unitSystem) + public ElectricCharge(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -164,10 +162,10 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -192,57 +190,57 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AmpereHours => As(ElectricChargeUnit.AmpereHour); + public QuantityValue AmpereHours => As(ElectricChargeUnit.AmpereHour); /// /// Gets a value of this quantity converted into /// - public double Coulombs => As(ElectricChargeUnit.Coulomb); + public QuantityValue Coulombs => As(ElectricChargeUnit.Coulomb); /// /// Gets a value of this quantity converted into /// - public double KiloampereHours => As(ElectricChargeUnit.KiloampereHour); + public QuantityValue KiloampereHours => As(ElectricChargeUnit.KiloampereHour); /// /// Gets a value of this quantity converted into /// - public double Kilocoulombs => As(ElectricChargeUnit.Kilocoulomb); + public QuantityValue Kilocoulombs => As(ElectricChargeUnit.Kilocoulomb); /// /// Gets a value of this quantity converted into /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public QuantityValue MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// /// Gets a value of this quantity converted into /// - public double Megacoulombs => As(ElectricChargeUnit.Megacoulomb); + public QuantityValue Megacoulombs => As(ElectricChargeUnit.Megacoulomb); /// /// Gets a value of this quantity converted into /// - public double Microcoulombs => As(ElectricChargeUnit.Microcoulomb); + public QuantityValue Microcoulombs => As(ElectricChargeUnit.Microcoulomb); /// /// Gets a value of this quantity converted into /// - public double MilliampereHours => As(ElectricChargeUnit.MilliampereHour); + public QuantityValue MilliampereHours => As(ElectricChargeUnit.MilliampereHour); /// /// Gets a value of this quantity converted into /// - public double Millicoulombs => As(ElectricChargeUnit.Millicoulomb); + public QuantityValue Millicoulombs => As(ElectricChargeUnit.Millicoulomb); /// /// Gets a value of this quantity converted into /// - public double Nanocoulombs => As(ElectricChargeUnit.Nanocoulomb); + public QuantityValue Nanocoulombs => As(ElectricChargeUnit.Nanocoulomb); /// /// Gets a value of this quantity converted into /// - public double Picocoulombs => As(ElectricChargeUnit.Picocoulomb); + public QuantityValue Picocoulombs => As(ElectricChargeUnit.Picocoulomb); #endregion @@ -310,7 +308,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static ElectricCharge FromAmpereHours(double value) + public static ElectricCharge FromAmpereHours(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.AmpereHour); } @@ -318,7 +316,7 @@ public static ElectricCharge FromAmpereHours(double value) /// /// Creates a from . /// - public static ElectricCharge FromCoulombs(double value) + public static ElectricCharge FromCoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Coulomb); } @@ -326,7 +324,7 @@ public static ElectricCharge FromCoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromKiloampereHours(double value) + public static ElectricCharge FromKiloampereHours(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.KiloampereHour); } @@ -334,7 +332,7 @@ public static ElectricCharge FromKiloampereHours(double value) /// /// Creates a from . /// - public static ElectricCharge FromKilocoulombs(double value) + public static ElectricCharge FromKilocoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Kilocoulomb); } @@ -342,7 +340,7 @@ public static ElectricCharge FromKilocoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromMegaampereHours(double value) + public static ElectricCharge FromMegaampereHours(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); } @@ -350,7 +348,7 @@ public static ElectricCharge FromMegaampereHours(double value) /// /// Creates a from . /// - public static ElectricCharge FromMegacoulombs(double value) + public static ElectricCharge FromMegacoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Megacoulomb); } @@ -358,7 +356,7 @@ public static ElectricCharge FromMegacoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromMicrocoulombs(double value) + public static ElectricCharge FromMicrocoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Microcoulomb); } @@ -366,7 +364,7 @@ public static ElectricCharge FromMicrocoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromMilliampereHours(double value) + public static ElectricCharge FromMilliampereHours(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.MilliampereHour); } @@ -374,7 +372,7 @@ public static ElectricCharge FromMilliampereHours(double value) /// /// Creates a from . /// - public static ElectricCharge FromMillicoulombs(double value) + public static ElectricCharge FromMillicoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Millicoulomb); } @@ -382,7 +380,7 @@ public static ElectricCharge FromMillicoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromNanocoulombs(double value) + public static ElectricCharge FromNanocoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Nanocoulomb); } @@ -390,7 +388,7 @@ public static ElectricCharge FromNanocoulombs(double value) /// /// Creates a from . /// - public static ElectricCharge FromPicocoulombs(double value) + public static ElectricCharge FromPicocoulombs(QuantityValue value) { return new ElectricCharge(value, ElectricChargeUnit.Picocoulomb); } @@ -401,7 +399,7 @@ public static ElectricCharge FromPicocoulombs(double value) /// Value to convert from. /// Unit to convert from. /// ElectricCharge unit value. - public static ElectricCharge From(double value, ElectricChargeUnit fromUnit) + public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUnit) { return new ElectricCharge(value, fromUnit); } @@ -573,25 +571,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCharge operator *(double left, ElectricCharge right) + public static ElectricCharge operator *(QuantityValue left, ElectricCharge right) { return new ElectricCharge(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCharge operator *(ElectricCharge left, double right) + public static ElectricCharge operator *(ElectricCharge left, QuantityValue right) { return new ElectricCharge(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCharge operator /(ElectricCharge left, double right) + public static ElectricCharge operator /(ElectricCharge left, QuantityValue right) { return new ElectricCharge(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCharge left, ElectricCharge right) + public static QuantityValue operator /(ElectricCharge left, ElectricCharge right) { return left.Coulombs / right.Coulombs; } @@ -646,27 +644,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricCharge left, ElectricCharge right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCharge other, ElectricCharge tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricCharge left, ElectricCharge right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCharge otherQuantity)) @@ -676,15 +667,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricCharge other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -767,10 +755,10 @@ public bool Equals(ElectricCharge other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -787,7 +775,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCharge other, ElectricCharge tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -800,7 +788,12 @@ public bool Equals(ElectricCharge other, ElectricCharge tolerance) /// A hash code for the current ElectricCharge. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -811,7 +804,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeUnit unit) + public QuantityValue As(ElectricChargeUnit unit) { if (Unit == unit) return Value; @@ -820,7 +813,7 @@ public double As(ElectricChargeUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -835,7 +828,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); @@ -901,28 +894,28 @@ private bool TryToUnit(ElectricChargeUnit unit, [NotNullWhen(true)] out Electric ElectricCharge? convertedOrNull = (Unit, unit) switch { // ElectricChargeUnit -> BaseUnit - (ElectricChargeUnit.AmpereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 2.77777777777e-4, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.KiloampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e3d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Kilocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e3d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.MegaampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e6d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e6d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Microcoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-6d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.MilliampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value / 2.77777777777e-4) * 1e-3d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Millicoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-3d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Nanocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-9d, ElectricChargeUnit.Coulomb), - (ElectricChargeUnit.Picocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge((_value) * 1e-12d, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.AmpereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * new QuantityValue(1000000000000000, 277777777777, false), ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.KiloampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * new QuantityValue(1000000000000000000, 277777777777, false), ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Kilocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * 1000, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.MegaampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * new QuantityValue(100, 277777777777, false) * BigInteger.Pow(10, 19), ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Megacoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * 1000000, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Microcoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 1000000, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.MilliampereHour, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value * new QuantityValue(1000000000000, 277777777777, false), ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Millicoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 1000, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Nanocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 1000000000, ElectricChargeUnit.Coulomb), + (ElectricChargeUnit.Picocoulomb, ElectricChargeUnit.Coulomb) => new ElectricCharge(_value / 1000000000000, ElectricChargeUnit.Coulomb), // BaseUnit -> ElectricChargeUnit - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.AmpereHour) => new ElectricCharge(_value * 2.77777777777e-4, ElectricChargeUnit.AmpereHour), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.KiloampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e3d, ElectricChargeUnit.KiloampereHour), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Kilocoulomb) => new ElectricCharge((_value) / 1e3d, ElectricChargeUnit.Kilocoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MegaampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e6d, ElectricChargeUnit.MegaampereHour), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb) => new ElectricCharge((_value) / 1e6d, ElectricChargeUnit.Megacoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Microcoulomb) => new ElectricCharge((_value) / 1e-6d, ElectricChargeUnit.Microcoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MilliampereHour) => new ElectricCharge((_value * 2.77777777777e-4) / 1e-3d, ElectricChargeUnit.MilliampereHour), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Millicoulomb) => new ElectricCharge((_value) / 1e-3d, ElectricChargeUnit.Millicoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Nanocoulomb) => new ElectricCharge((_value) / 1e-9d, ElectricChargeUnit.Nanocoulomb), - (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Picocoulomb) => new ElectricCharge((_value) / 1e-12d, ElectricChargeUnit.Picocoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.AmpereHour) => new ElectricCharge(_value * new QuantityValue(277777777777, 1000000000000000, false), ElectricChargeUnit.AmpereHour), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.KiloampereHour) => new ElectricCharge(_value * new QuantityValue(277777777777, 1000000000000000000, false), ElectricChargeUnit.KiloampereHour), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Kilocoulomb) => new ElectricCharge(_value / 1000, ElectricChargeUnit.Kilocoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MegaampereHour) => new ElectricCharge(_value * new QuantityValue(277777777777, 100, false) / BigInteger.Pow(10, 19), ElectricChargeUnit.MegaampereHour), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Megacoulomb) => new ElectricCharge(_value / 1000000, ElectricChargeUnit.Megacoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Microcoulomb) => new ElectricCharge(_value * 1000000, ElectricChargeUnit.Microcoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.MilliampereHour) => new ElectricCharge(_value * new QuantityValue(277777777777, 1000000000000, false), ElectricChargeUnit.MilliampereHour), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Millicoulomb) => new ElectricCharge(_value * 1000, ElectricChargeUnit.Millicoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Nanocoulomb) => new ElectricCharge(_value * 1000000000, ElectricChargeUnit.Nanocoulomb), + (ElectricChargeUnit.Coulomb, ElectricChargeUnit.Picocoulomb) => new ElectricCharge(_value * 1000000000000, ElectricChargeUnit.Picocoulomb), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index fb18f005f6..8f311e26b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static ElectricChargeDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) + public ElectricChargeDensity(QuantityValue value, ElectricChargeDensityUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricChargeDensity(double value, UnitSystem unitSystem) + public ElectricChargeDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); + public QuantityValue CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProv /// /// Creates a from . /// - public static ElectricChargeDensity FromCoulombsPerCubicMeter(double value) + public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue value) { return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter); } @@ -233,7 +234,7 @@ public static ElectricChargeDensity FromCoulombsPerCubicMeter(double value) /// Value to convert from. /// Unit to convert from. /// ElectricChargeDensity unit value. - public static ElectricChargeDensity From(double value, ElectricChargeDensityUnit fromUnit) + public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDensityUnit fromUnit) { return new ElectricChargeDensity(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(double left, ElectricChargeDensity right) + public static ElectricChargeDensity operator *(QuantityValue left, ElectricChargeDensity right) { return new ElectricChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(ElectricChargeDensity left, double right) + public static ElectricChargeDensity operator *(ElectricChargeDensity left, QuantityValue right) { return new ElectricChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricChargeDensity operator /(ElectricChargeDensity left, double right) + public static ElectricChargeDensity operator /(ElectricChargeDensity left, QuantityValue right) { return new ElectricChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricChargeDensity left, ElectricChargeDensity right) + public static QuantityValue operator /(ElectricChargeDensity left, ElectricChargeDensity right) { return left.CoulombsPerCubicMeter / right.CoulombsPerCubicMeter; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricChargeDensity otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricChargeDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(ElectricChargeDensity other, ElectricChargeDensity tolerance) /// A hash code for the current ElectricChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeDensityUnit unit) + public QuantityValue As(ElectricChargeDensityUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(ElectricChargeDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index d550359c1e..9c86a850ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,7 +86,7 @@ static ElectricConductance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricConductance(double value, ElectricConductanceUnit unit) + public ElectricConductance(QuantityValue value, ElectricConductanceUnit unit) { _value = value; _unit = unit; @@ -99,7 +100,7 @@ public ElectricConductance(double value, ElectricConductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductance(double value, UnitSystem unitSystem) + public ElectricConductance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -150,10 +151,10 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -178,27 +179,27 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Kilosiemens => As(ElectricConductanceUnit.Kilosiemens); + public QuantityValue Kilosiemens => As(ElectricConductanceUnit.Kilosiemens); /// /// Gets a value of this quantity converted into /// - public double Microsiemens => As(ElectricConductanceUnit.Microsiemens); + public QuantityValue Microsiemens => As(ElectricConductanceUnit.Microsiemens); /// /// Gets a value of this quantity converted into /// - public double Millisiemens => As(ElectricConductanceUnit.Millisiemens); + public QuantityValue Millisiemens => As(ElectricConductanceUnit.Millisiemens); /// /// Gets a value of this quantity converted into /// - public double Nanosiemens => As(ElectricConductanceUnit.Nanosiemens); + public QuantityValue Nanosiemens => As(ElectricConductanceUnit.Nanosiemens); /// /// Gets a value of this quantity converted into /// - public double Siemens => As(ElectricConductanceUnit.Siemens); + public QuantityValue Siemens => As(ElectricConductanceUnit.Siemens); #endregion @@ -254,7 +255,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvid /// /// Creates a from . /// - public static ElectricConductance FromKilosiemens(double value) + public static ElectricConductance FromKilosiemens(QuantityValue value) { return new ElectricConductance(value, ElectricConductanceUnit.Kilosiemens); } @@ -262,7 +263,7 @@ public static ElectricConductance FromKilosiemens(double value) /// /// Creates a from . /// - public static ElectricConductance FromMicrosiemens(double value) + public static ElectricConductance FromMicrosiemens(QuantityValue value) { return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens); } @@ -270,7 +271,7 @@ public static ElectricConductance FromMicrosiemens(double value) /// /// Creates a from . /// - public static ElectricConductance FromMillisiemens(double value) + public static ElectricConductance FromMillisiemens(QuantityValue value) { return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens); } @@ -278,7 +279,7 @@ public static ElectricConductance FromMillisiemens(double value) /// /// Creates a from . /// - public static ElectricConductance FromNanosiemens(double value) + public static ElectricConductance FromNanosiemens(QuantityValue value) { return new ElectricConductance(value, ElectricConductanceUnit.Nanosiemens); } @@ -286,7 +287,7 @@ public static ElectricConductance FromNanosiemens(double value) /// /// Creates a from . /// - public static ElectricConductance FromSiemens(double value) + public static ElectricConductance FromSiemens(QuantityValue value) { return new ElectricConductance(value, ElectricConductanceUnit.Siemens); } @@ -297,7 +298,7 @@ public static ElectricConductance FromSiemens(double value) /// Value to convert from. /// Unit to convert from. /// ElectricConductance unit value. - public static ElectricConductance From(double value, ElectricConductanceUnit fromUnit) + public static ElectricConductance From(QuantityValue value, ElectricConductanceUnit fromUnit) { return new ElectricConductance(value, fromUnit); } @@ -469,25 +470,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductance operator *(double left, ElectricConductance right) + public static ElectricConductance operator *(QuantityValue left, ElectricConductance right) { return new ElectricConductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductance operator *(ElectricConductance left, double right) + public static ElectricConductance operator *(ElectricConductance left, QuantityValue right) { return new ElectricConductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductance operator /(ElectricConductance left, double right) + public static ElectricConductance operator /(ElectricConductance left, QuantityValue right) { return new ElectricConductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricConductance left, ElectricConductance right) + public static QuantityValue operator /(ElectricConductance left, ElectricConductance right) { return left.Siemens / right.Siemens; } @@ -520,27 +521,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricConductance left, ElectricConductance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductance other, ElectricConductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricConductance left, ElectricConductance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricConductance otherQuantity)) @@ -550,15 +544,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricConductance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -641,10 +632,10 @@ public bool Equals(ElectricConductance other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -661,7 +652,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricConductance other, ElectricConductance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -674,7 +665,12 @@ public bool Equals(ElectricConductance other, ElectricConductance tolerance) /// A hash code for the current ElectricConductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -685,7 +681,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductanceUnit unit) + public QuantityValue As(ElectricConductanceUnit unit) { if (Unit == unit) return Value; @@ -694,7 +690,7 @@ public double As(ElectricConductanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -709,7 +705,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); @@ -775,16 +771,16 @@ private bool TryToUnit(ElectricConductanceUnit unit, [NotNullWhen(true)] out Ele ElectricConductance? convertedOrNull = (Unit, unit) switch { // ElectricConductanceUnit -> BaseUnit - (ElectricConductanceUnit.Kilosiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance((_value) * 1e3d, ElectricConductanceUnit.Siemens), - (ElectricConductanceUnit.Microsiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance((_value) * 1e-6d, ElectricConductanceUnit.Siemens), - (ElectricConductanceUnit.Millisiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance((_value) * 1e-3d, ElectricConductanceUnit.Siemens), - (ElectricConductanceUnit.Nanosiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance((_value) * 1e-9d, ElectricConductanceUnit.Siemens), + (ElectricConductanceUnit.Kilosiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance(_value * 1000, ElectricConductanceUnit.Siemens), + (ElectricConductanceUnit.Microsiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance(_value / 1000000, ElectricConductanceUnit.Siemens), + (ElectricConductanceUnit.Millisiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance(_value / 1000, ElectricConductanceUnit.Siemens), + (ElectricConductanceUnit.Nanosiemens, ElectricConductanceUnit.Siemens) => new ElectricConductance(_value / 1000000000, ElectricConductanceUnit.Siemens), // BaseUnit -> ElectricConductanceUnit - (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Kilosiemens) => new ElectricConductance((_value) / 1e3d, ElectricConductanceUnit.Kilosiemens), - (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Microsiemens) => new ElectricConductance((_value) / 1e-6d, ElectricConductanceUnit.Microsiemens), - (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Millisiemens) => new ElectricConductance((_value) / 1e-3d, ElectricConductanceUnit.Millisiemens), - (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Nanosiemens) => new ElectricConductance((_value) / 1e-9d, ElectricConductanceUnit.Nanosiemens), + (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Kilosiemens) => new ElectricConductance(_value / 1000, ElectricConductanceUnit.Kilosiemens), + (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Microsiemens) => new ElectricConductance(_value * 1000000, ElectricConductanceUnit.Microsiemens), + (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Millisiemens) => new ElectricConductance(_value * 1000, ElectricConductanceUnit.Millisiemens), + (ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Nanosiemens) => new ElectricConductance(_value * 1000000000, ElectricConductanceUnit.Nanosiemens), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 0dee82fc07..31f625764a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,7 +87,7 @@ static ElectricConductivity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricConductivity(double value, ElectricConductivityUnit unit) + public ElectricConductivity(QuantityValue value, ElectricConductivityUnit unit) { _value = value; _unit = unit; @@ -100,7 +101,7 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductivity(double value, UnitSystem unitSystem) + public ElectricConductivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -151,10 +152,10 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,32 +180,32 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double MicrosiemensPerCentimeter => As(ElectricConductivityUnit.MicrosiemensPerCentimeter); + public QuantityValue MicrosiemensPerCentimeter => As(ElectricConductivityUnit.MicrosiemensPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MillisiemensPerCentimeter => As(ElectricConductivityUnit.MillisiemensPerCentimeter); + public QuantityValue MillisiemensPerCentimeter => As(ElectricConductivityUnit.MillisiemensPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double SiemensPerCentimeter => As(ElectricConductivityUnit.SiemensPerCentimeter); + public QuantityValue SiemensPerCentimeter => As(ElectricConductivityUnit.SiemensPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); + public QuantityValue SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); /// /// Gets a value of this quantity converted into /// - public double SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); + public QuantityValue SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); /// /// Gets a value of this quantity converted into /// - public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); + public QuantityValue SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); #endregion @@ -262,7 +263,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvi /// /// Creates a from . /// - public static ElectricConductivity FromMicrosiemensPerCentimeter(double value) + public static ElectricConductivity FromMicrosiemensPerCentimeter(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.MicrosiemensPerCentimeter); } @@ -270,7 +271,7 @@ public static ElectricConductivity FromMicrosiemensPerCentimeter(double value) /// /// Creates a from . /// - public static ElectricConductivity FromMillisiemensPerCentimeter(double value) + public static ElectricConductivity FromMillisiemensPerCentimeter(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.MillisiemensPerCentimeter); } @@ -278,7 +279,7 @@ public static ElectricConductivity FromMillisiemensPerCentimeter(double value) /// /// Creates a from . /// - public static ElectricConductivity FromSiemensPerCentimeter(double value) + public static ElectricConductivity FromSiemensPerCentimeter(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerCentimeter); } @@ -286,7 +287,7 @@ public static ElectricConductivity FromSiemensPerCentimeter(double value) /// /// Creates a from . /// - public static ElectricConductivity FromSiemensPerFoot(double value) + public static ElectricConductivity FromSiemensPerFoot(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerFoot); } @@ -294,7 +295,7 @@ public static ElectricConductivity FromSiemensPerFoot(double value) /// /// Creates a from . /// - public static ElectricConductivity FromSiemensPerInch(double value) + public static ElectricConductivity FromSiemensPerInch(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerInch); } @@ -302,7 +303,7 @@ public static ElectricConductivity FromSiemensPerInch(double value) /// /// Creates a from . /// - public static ElectricConductivity FromSiemensPerMeter(double value) + public static ElectricConductivity FromSiemensPerMeter(QuantityValue value) { return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter); } @@ -313,7 +314,7 @@ public static ElectricConductivity FromSiemensPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// ElectricConductivity unit value. - public static ElectricConductivity From(double value, ElectricConductivityUnit fromUnit) + public static ElectricConductivity From(QuantityValue value, ElectricConductivityUnit fromUnit) { return new ElectricConductivity(value, fromUnit); } @@ -485,25 +486,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductivity operator *(double left, ElectricConductivity right) + public static ElectricConductivity operator *(QuantityValue left, ElectricConductivity right) { return new ElectricConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductivity operator *(ElectricConductivity left, double right) + public static ElectricConductivity operator *(ElectricConductivity left, QuantityValue right) { return new ElectricConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductivity operator /(ElectricConductivity left, double right) + public static ElectricConductivity operator /(ElectricConductivity left, QuantityValue right) { return new ElectricConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricConductivity left, ElectricConductivity right) + public static QuantityValue operator /(ElectricConductivity left, ElectricConductivity right) { return left.SiemensPerMeter / right.SiemensPerMeter; } @@ -516,7 +517,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// The corresponding inverse quantity, . public ElectricResistivity Inverse() { - return SiemensPerMeter == 0.0 ? ElectricResistivity.Zero : ElectricResistivity.FromOhmMeters(1 / SiemensPerMeter); + return ElectricResistivity.FromOhmMeters(QuantityValue.Inverse(SiemensPerMeter)); } #endregion @@ -547,27 +548,20 @@ public ElectricResistivity Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricConductivity left, ElectricConductivity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricConductivity other, ElectricConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricConductivity left, ElectricConductivity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricConductivity otherQuantity)) @@ -577,15 +571,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricConductivity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +659,10 @@ public bool Equals(ElectricConductivity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -688,7 +679,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricConductivity other, ElectricConductivity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -701,7 +692,12 @@ public bool Equals(ElectricConductivity other, ElectricConductivity tolerance) /// A hash code for the current ElectricConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -712,7 +708,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductivityUnit unit) + public QuantityValue As(ElectricConductivityUnit unit) { if (Unit == unit) return Value; @@ -721,7 +717,7 @@ public double As(ElectricConductivityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -736,7 +732,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); @@ -802,18 +798,18 @@ private bool TryToUnit(ElectricConductivityUnit unit, [NotNullWhen(true)] out El ElectricConductivity? convertedOrNull = (Unit, unit) switch { // ElectricConductivityUnit -> BaseUnit - (ElectricConductivityUnit.MicrosiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity((_value * 1e2) * 1e-6d, ElectricConductivityUnit.SiemensPerMeter), - (ElectricConductivityUnit.MillisiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity((_value * 1e2) * 1e-3d, ElectricConductivityUnit.SiemensPerMeter), - (ElectricConductivityUnit.SiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * 1e2, ElectricConductivityUnit.SiemensPerMeter), - (ElectricConductivityUnit.SiemensPerFoot, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * 3.2808398950131234, ElectricConductivityUnit.SiemensPerMeter), - (ElectricConductivityUnit.SiemensPerInch, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * 3.937007874015748e1, ElectricConductivityUnit.SiemensPerMeter), + (ElectricConductivityUnit.MicrosiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value / 10000, ElectricConductivityUnit.SiemensPerMeter), + (ElectricConductivityUnit.MillisiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value / 10, ElectricConductivityUnit.SiemensPerMeter), + (ElectricConductivityUnit.SiemensPerCentimeter, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * 100, ElectricConductivityUnit.SiemensPerMeter), + (ElectricConductivityUnit.SiemensPerFoot, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * new QuantityValue(16404199475065617, 5000000000000000, false), ElectricConductivityUnit.SiemensPerMeter), + (ElectricConductivityUnit.SiemensPerInch, ElectricConductivityUnit.SiemensPerMeter) => new ElectricConductivity(_value * new QuantityValue(984251968503937, 25000000000000, false), ElectricConductivityUnit.SiemensPerMeter), // BaseUnit -> ElectricConductivityUnit - (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.MicrosiemensPerCentimeter) => new ElectricConductivity((_value / 1e2) / 1e-6d, ElectricConductivityUnit.MicrosiemensPerCentimeter), - (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.MillisiemensPerCentimeter) => new ElectricConductivity((_value / 1e2) / 1e-3d, ElectricConductivityUnit.MillisiemensPerCentimeter), - (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerCentimeter) => new ElectricConductivity(_value / 1e2, ElectricConductivityUnit.SiemensPerCentimeter), - (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerFoot) => new ElectricConductivity(_value / 3.2808398950131234, ElectricConductivityUnit.SiemensPerFoot), - (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerInch) => new ElectricConductivity(_value / 3.937007874015748e1, ElectricConductivityUnit.SiemensPerInch), + (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.MicrosiemensPerCentimeter) => new ElectricConductivity(_value * 10000, ElectricConductivityUnit.MicrosiemensPerCentimeter), + (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.MillisiemensPerCentimeter) => new ElectricConductivity(_value * 10, ElectricConductivityUnit.MillisiemensPerCentimeter), + (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerCentimeter) => new ElectricConductivity(_value / 100, ElectricConductivityUnit.SiemensPerCentimeter), + (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerFoot) => new ElectricConductivity(_value * new QuantityValue(5000000000000000, 16404199475065617, false), ElectricConductivityUnit.SiemensPerFoot), + (ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerInch) => new ElectricConductivity(_value * new QuantityValue(25000000000000, 984251968503937, false), ElectricConductivityUnit.SiemensPerInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index d0ea9143fa..cea16b6f28 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,7 +94,7 @@ static ElectricCurrent() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricCurrent(double value, ElectricCurrentUnit unit) + public ElectricCurrent(QuantityValue value, ElectricCurrentUnit unit) { _value = value; _unit = unit; @@ -110,7 +108,7 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrent(double value, UnitSystem unitSystem) + public ElectricCurrent(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -161,10 +159,10 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,47 +187,47 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Amperes => As(ElectricCurrentUnit.Ampere); + public QuantityValue Amperes => As(ElectricCurrentUnit.Ampere); /// /// Gets a value of this quantity converted into /// - public double Centiamperes => As(ElectricCurrentUnit.Centiampere); + public QuantityValue Centiamperes => As(ElectricCurrentUnit.Centiampere); /// /// Gets a value of this quantity converted into /// - public double Femtoamperes => As(ElectricCurrentUnit.Femtoampere); + public QuantityValue Femtoamperes => As(ElectricCurrentUnit.Femtoampere); /// /// Gets a value of this quantity converted into /// - public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere); + public QuantityValue Kiloamperes => As(ElectricCurrentUnit.Kiloampere); /// /// Gets a value of this quantity converted into /// - public double Megaamperes => As(ElectricCurrentUnit.Megaampere); + public QuantityValue Megaamperes => As(ElectricCurrentUnit.Megaampere); /// /// Gets a value of this quantity converted into /// - public double Microamperes => As(ElectricCurrentUnit.Microampere); + public QuantityValue Microamperes => As(ElectricCurrentUnit.Microampere); /// /// Gets a value of this quantity converted into /// - public double Milliamperes => As(ElectricCurrentUnit.Milliampere); + public QuantityValue Milliamperes => As(ElectricCurrentUnit.Milliampere); /// /// Gets a value of this quantity converted into /// - public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere); + public QuantityValue Nanoamperes => As(ElectricCurrentUnit.Nanoampere); /// /// Gets a value of this quantity converted into /// - public double Picoamperes => As(ElectricCurrentUnit.Picoampere); + public QuantityValue Picoamperes => As(ElectricCurrentUnit.Picoampere); #endregion @@ -293,7 +291,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? /// /// Creates a from . /// - public static ElectricCurrent FromAmperes(double value) + public static ElectricCurrent FromAmperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Ampere); } @@ -301,7 +299,7 @@ public static ElectricCurrent FromAmperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromCentiamperes(double value) + public static ElectricCurrent FromCentiamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere); } @@ -309,7 +307,7 @@ public static ElectricCurrent FromCentiamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromFemtoamperes(double value) + public static ElectricCurrent FromFemtoamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Femtoampere); } @@ -317,7 +315,7 @@ public static ElectricCurrent FromFemtoamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromKiloamperes(double value) + public static ElectricCurrent FromKiloamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere); } @@ -325,7 +323,7 @@ public static ElectricCurrent FromKiloamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromMegaamperes(double value) + public static ElectricCurrent FromMegaamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere); } @@ -333,7 +331,7 @@ public static ElectricCurrent FromMegaamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromMicroamperes(double value) + public static ElectricCurrent FromMicroamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Microampere); } @@ -341,7 +339,7 @@ public static ElectricCurrent FromMicroamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromMilliamperes(double value) + public static ElectricCurrent FromMilliamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere); } @@ -349,7 +347,7 @@ public static ElectricCurrent FromMilliamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromNanoamperes(double value) + public static ElectricCurrent FromNanoamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere); } @@ -357,7 +355,7 @@ public static ElectricCurrent FromNanoamperes(double value) /// /// Creates a from . /// - public static ElectricCurrent FromPicoamperes(double value) + public static ElectricCurrent FromPicoamperes(QuantityValue value) { return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere); } @@ -368,7 +366,7 @@ public static ElectricCurrent FromPicoamperes(double value) /// Value to convert from. /// Unit to convert from. /// ElectricCurrent unit value. - public static ElectricCurrent From(double value, ElectricCurrentUnit fromUnit) + public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit fromUnit) { return new ElectricCurrent(value, fromUnit); } @@ -540,25 +538,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrent operator *(double left, ElectricCurrent right) + public static ElectricCurrent operator *(QuantityValue left, ElectricCurrent right) { return new ElectricCurrent(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrent operator *(ElectricCurrent left, double right) + public static ElectricCurrent operator *(ElectricCurrent left, QuantityValue right) { return new ElectricCurrent(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrent operator /(ElectricCurrent left, double right) + public static ElectricCurrent operator /(ElectricCurrent left, QuantityValue right) { return new ElectricCurrent(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrent left, ElectricCurrent right) + public static QuantityValue operator /(ElectricCurrent left, ElectricCurrent right) { return left.Amperes / right.Amperes; } @@ -625,27 +623,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricCurrent left, ElectricCurrent right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrent other, ElectricCurrent tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricCurrent left, ElectricCurrent right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrent otherQuantity)) @@ -655,15 +646,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricCurrent other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -746,10 +734,10 @@ public bool Equals(ElectricCurrent other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -766,7 +754,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrent other, ElectricCurrent tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -779,7 +767,12 @@ public bool Equals(ElectricCurrent other, ElectricCurrent tolerance) /// A hash code for the current ElectricCurrent. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -790,7 +783,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentUnit unit) + public QuantityValue As(ElectricCurrentUnit unit) { if (Unit == unit) return Value; @@ -799,7 +792,7 @@ public double As(ElectricCurrentUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -814,7 +807,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); @@ -880,24 +873,24 @@ private bool TryToUnit(ElectricCurrentUnit unit, [NotNullWhen(true)] out Electri ElectricCurrent? convertedOrNull = (Unit, unit) switch { // ElectricCurrentUnit -> BaseUnit - (ElectricCurrentUnit.Centiampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-2d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Femtoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-15d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Kiloampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e3d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Megaampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e6d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Microampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-6d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Milliampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-3d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Nanoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-9d, ElectricCurrentUnit.Ampere), - (ElectricCurrentUnit.Picoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent((_value) * 1e-12d, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Centiampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 100, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Femtoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 1000000000000000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Kiloampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value * 1000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Megaampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value * 1000000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Microampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 1000000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Milliampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 1000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Nanoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 1000000000, ElectricCurrentUnit.Ampere), + (ElectricCurrentUnit.Picoampere, ElectricCurrentUnit.Ampere) => new ElectricCurrent(_value / 1000000000000, ElectricCurrentUnit.Ampere), // BaseUnit -> ElectricCurrentUnit - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Centiampere) => new ElectricCurrent((_value) / 1e-2d, ElectricCurrentUnit.Centiampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Femtoampere) => new ElectricCurrent((_value) / 1e-15d, ElectricCurrentUnit.Femtoampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Kiloampere) => new ElectricCurrent((_value) / 1e3d, ElectricCurrentUnit.Kiloampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Megaampere) => new ElectricCurrent((_value) / 1e6d, ElectricCurrentUnit.Megaampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Microampere) => new ElectricCurrent((_value) / 1e-6d, ElectricCurrentUnit.Microampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Milliampere) => new ElectricCurrent((_value) / 1e-3d, ElectricCurrentUnit.Milliampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Nanoampere) => new ElectricCurrent((_value) / 1e-9d, ElectricCurrentUnit.Nanoampere), - (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Picoampere) => new ElectricCurrent((_value) / 1e-12d, ElectricCurrentUnit.Picoampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Centiampere) => new ElectricCurrent(_value * 100, ElectricCurrentUnit.Centiampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Femtoampere) => new ElectricCurrent(_value * 1000000000000000, ElectricCurrentUnit.Femtoampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Kiloampere) => new ElectricCurrent(_value / 1000, ElectricCurrentUnit.Kiloampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Megaampere) => new ElectricCurrent(_value / 1000000, ElectricCurrentUnit.Megaampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Microampere) => new ElectricCurrent(_value * 1000000, ElectricCurrentUnit.Microampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Milliampere) => new ElectricCurrent(_value * 1000, ElectricCurrentUnit.Milliampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Nanoampere) => new ElectricCurrent(_value * 1000000000, ElectricCurrentUnit.Nanoampere), + (ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Picoampere) => new ElectricCurrent(_value * 1000000000000, ElectricCurrentUnit.Picoampere), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 8f164a5890..0f6718c639 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static ElectricCurrentDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) + public ElectricCurrentDensity(QuantityValue value, ElectricCurrentDensityUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentDensity(double value, UnitSystem unitSystem) + public ElectricCurrentDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,17 +177,17 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); + public QuantityValue AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); + public QuantityValue AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); /// /// Gets a value of this quantity converted into /// - public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); + public QuantityValue AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); #endregion @@ -238,7 +239,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatPro /// /// Creates a from . /// - public static ElectricCurrentDensity FromAmperesPerSquareFoot(double value) + public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue value) { return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareFoot); } @@ -246,7 +247,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareFoot(double value) /// /// Creates a from . /// - public static ElectricCurrentDensity FromAmperesPerSquareInch(double value) + public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue value) { return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareInch); } @@ -254,7 +255,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareInch(double value) /// /// Creates a from . /// - public static ElectricCurrentDensity FromAmperesPerSquareMeter(double value) + public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue value) { return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter); } @@ -265,7 +266,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareMeter(double value) /// Value to convert from. /// Unit to convert from. /// ElectricCurrentDensity unit value. - public static ElectricCurrentDensity From(double value, ElectricCurrentDensityUnit fromUnit) + public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDensityUnit fromUnit) { return new ElectricCurrentDensity(value, fromUnit); } @@ -437,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(double left, ElectricCurrentDensity right) + public static ElectricCurrentDensity operator *(QuantityValue left, ElectricCurrentDensity right) { return new ElectricCurrentDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, double right) + public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, QuantityValue right) { return new ElectricCurrentDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, double right) + public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, QuantityValue right) { return new ElectricCurrentDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static QuantityValue operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.AmperesPerSquareMeter / right.AmperesPerSquareMeter; } @@ -488,27 +489,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrentDensity otherQuantity)) @@ -518,15 +512,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricCurrentDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -609,10 +600,10 @@ public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -629,7 +620,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -642,7 +633,12 @@ public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity toleranc /// A hash code for the current ElectricCurrentDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -653,7 +649,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentDensityUnit unit) + public QuantityValue As(ElectricCurrentDensityUnit unit) { if (Unit == unit) return Value; @@ -662,7 +658,7 @@ public double As(ElectricCurrentDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -677,7 +673,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); @@ -743,12 +739,12 @@ private bool TryToUnit(ElectricCurrentDensityUnit unit, [NotNullWhen(true)] out ElectricCurrentDensity? convertedOrNull = (Unit, unit) switch { // ElectricCurrentDensityUnit -> BaseUnit - (ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensityUnit.AmperePerSquareMeter) => new ElectricCurrentDensity(_value * 1.0763910416709722e1, ElectricCurrentDensityUnit.AmperePerSquareMeter), - (ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensityUnit.AmperePerSquareMeter) => new ElectricCurrentDensity(_value * 1.5500031000062000e3, ElectricCurrentDensityUnit.AmperePerSquareMeter), + (ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensityUnit.AmperePerSquareMeter) => new ElectricCurrentDensity(_value * new QuantityValue(5381955208354861, 500000000000000, false), ElectricCurrentDensityUnit.AmperePerSquareMeter), + (ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensityUnit.AmperePerSquareMeter) => new ElectricCurrentDensity(_value * new QuantityValue(7750015500031, 5000000000, false), ElectricCurrentDensityUnit.AmperePerSquareMeter), // BaseUnit -> ElectricCurrentDensityUnit - (ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareFoot) => new ElectricCurrentDensity(_value / 1.0763910416709722e1, ElectricCurrentDensityUnit.AmperePerSquareFoot), - (ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareInch) => new ElectricCurrentDensity(_value / 1.5500031000062000e3, ElectricCurrentDensityUnit.AmperePerSquareInch), + (ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareFoot) => new ElectricCurrentDensity(_value * new QuantityValue(500000000000000, 5381955208354861, false), ElectricCurrentDensityUnit.AmperePerSquareFoot), + (ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareInch) => new ElectricCurrentDensity(_value * new QuantityValue(5000000000, 7750015500031, false), ElectricCurrentDensityUnit.AmperePerSquareInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 9e4a93f316..21f7809c96 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -90,7 +88,7 @@ static ElectricCurrentGradient() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) + public ElectricCurrentGradient(QuantityValue value, ElectricCurrentGradientUnit unit) { _value = value; _unit = unit; @@ -104,7 +102,7 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentGradient(double value, UnitSystem unitSystem) + public ElectricCurrentGradient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -155,10 +153,10 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,37 +181,37 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); + public QuantityValue AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); + public QuantityValue AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); /// /// Gets a value of this quantity converted into /// - public double AmperesPerMinute => As(ElectricCurrentGradientUnit.AmperePerMinute); + public QuantityValue AmperesPerMinute => As(ElectricCurrentGradientUnit.AmperePerMinute); /// /// Gets a value of this quantity converted into /// - public double AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); + public QuantityValue AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); /// /// Gets a value of this quantity converted into /// - public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); + public QuantityValue AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); /// /// Gets a value of this quantity converted into /// - public double MilliamperesPerMinute => As(ElectricCurrentGradientUnit.MilliamperePerMinute); + public QuantityValue MilliamperesPerMinute => As(ElectricCurrentGradientUnit.MilliamperePerMinute); /// /// Gets a value of this quantity converted into /// - public double MilliamperesPerSecond => As(ElectricCurrentGradientUnit.MilliamperePerSecond); + public QuantityValue MilliamperesPerSecond => As(ElectricCurrentGradientUnit.MilliamperePerSecond); #endregion @@ -273,7 +271,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatPr /// /// Creates a from . /// - public static ElectricCurrentGradient FromAmperesPerMicrosecond(double value) + public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMicrosecond); } @@ -281,7 +279,7 @@ public static ElectricCurrentGradient FromAmperesPerMicrosecond(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromAmperesPerMillisecond(double value) + public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMillisecond); } @@ -289,7 +287,7 @@ public static ElectricCurrentGradient FromAmperesPerMillisecond(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromAmperesPerMinute(double value) + public static ElectricCurrentGradient FromAmperesPerMinute(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMinute); } @@ -297,7 +295,7 @@ public static ElectricCurrentGradient FromAmperesPerMinute(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromAmperesPerNanosecond(double value) + public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerNanosecond); } @@ -305,7 +303,7 @@ public static ElectricCurrentGradient FromAmperesPerNanosecond(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromAmperesPerSecond(double value) + public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond); } @@ -313,7 +311,7 @@ public static ElectricCurrentGradient FromAmperesPerSecond(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromMilliamperesPerMinute(double value) + public static ElectricCurrentGradient FromMilliamperesPerMinute(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.MilliamperePerMinute); } @@ -321,7 +319,7 @@ public static ElectricCurrentGradient FromMilliamperesPerMinute(double value) /// /// Creates a from . /// - public static ElectricCurrentGradient FromMilliamperesPerSecond(double value) + public static ElectricCurrentGradient FromMilliamperesPerSecond(QuantityValue value) { return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.MilliamperePerSecond); } @@ -332,7 +330,7 @@ public static ElectricCurrentGradient FromMilliamperesPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// ElectricCurrentGradient unit value. - public static ElectricCurrentGradient From(double value, ElectricCurrentGradientUnit fromUnit) + public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentGradientUnit fromUnit) { return new ElectricCurrentGradient(value, fromUnit); } @@ -504,25 +502,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(double left, ElectricCurrentGradient right) + public static ElectricCurrentGradient operator *(QuantityValue left, ElectricCurrentGradient right) { return new ElectricCurrentGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, double right) + public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, QuantityValue right) { return new ElectricCurrentGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, double right) + public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, QuantityValue right) { return new ElectricCurrentGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static QuantityValue operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.AmperesPerSecond / right.AmperesPerSecond; } @@ -565,27 +563,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricCurrentGradient otherQuantity)) @@ -595,15 +586,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricCurrentGradient other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -686,10 +674,10 @@ public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -706,7 +694,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -719,7 +707,12 @@ public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient tolera /// A hash code for the current ElectricCurrentGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -730,7 +723,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentGradientUnit unit) + public QuantityValue As(ElectricCurrentGradientUnit unit) { if (Unit == unit) return Value; @@ -739,7 +732,7 @@ public double As(ElectricCurrentGradientUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -754,7 +747,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); @@ -820,20 +813,20 @@ private bool TryToUnit(ElectricCurrentGradientUnit unit, [NotNullWhen(true)] out ElectricCurrentGradient? convertedOrNull = (Unit, unit) switch { // ElectricCurrentGradientUnit -> BaseUnit - (ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1E6, ElectricCurrentGradientUnit.AmperePerSecond), - (ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1E3, ElectricCurrentGradientUnit.AmperePerSecond), + (ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1000000, ElectricCurrentGradientUnit.AmperePerSecond), + (ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1000, ElectricCurrentGradientUnit.AmperePerSecond), (ElectricCurrentGradientUnit.AmperePerMinute, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value / 60, ElectricCurrentGradientUnit.AmperePerSecond), - (ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1E9, ElectricCurrentGradientUnit.AmperePerSecond), - (ElectricCurrentGradientUnit.MilliamperePerMinute, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient((_value / 60) * 1e-3d, ElectricCurrentGradientUnit.AmperePerSecond), - (ElectricCurrentGradientUnit.MilliamperePerSecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient((_value) * 1e-3d, ElectricCurrentGradientUnit.AmperePerSecond), + (ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value * 1000000000, ElectricCurrentGradientUnit.AmperePerSecond), + (ElectricCurrentGradientUnit.MilliamperePerMinute, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value / 60000, ElectricCurrentGradientUnit.AmperePerSecond), + (ElectricCurrentGradientUnit.MilliamperePerSecond, ElectricCurrentGradientUnit.AmperePerSecond) => new ElectricCurrentGradient(_value / 1000, ElectricCurrentGradientUnit.AmperePerSecond), // BaseUnit -> ElectricCurrentGradientUnit - (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMicrosecond) => new ElectricCurrentGradient(_value / 1E6, ElectricCurrentGradientUnit.AmperePerMicrosecond), - (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMillisecond) => new ElectricCurrentGradient(_value / 1E3, ElectricCurrentGradientUnit.AmperePerMillisecond), + (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMicrosecond) => new ElectricCurrentGradient(_value / 1000000, ElectricCurrentGradientUnit.AmperePerMicrosecond), + (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMillisecond) => new ElectricCurrentGradient(_value / 1000, ElectricCurrentGradientUnit.AmperePerMillisecond), (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMinute) => new ElectricCurrentGradient(_value * 60, ElectricCurrentGradientUnit.AmperePerMinute), - (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerNanosecond) => new ElectricCurrentGradient(_value / 1E9, ElectricCurrentGradientUnit.AmperePerNanosecond), - (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.MilliamperePerMinute) => new ElectricCurrentGradient((_value * 60) / 1e-3d, ElectricCurrentGradientUnit.MilliamperePerMinute), - (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.MilliamperePerSecond) => new ElectricCurrentGradient((_value) / 1e-3d, ElectricCurrentGradientUnit.MilliamperePerSecond), + (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerNanosecond) => new ElectricCurrentGradient(_value / 1000000000, ElectricCurrentGradientUnit.AmperePerNanosecond), + (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.MilliamperePerMinute) => new ElectricCurrentGradient(_value * 60000, ElectricCurrentGradientUnit.MilliamperePerMinute), + (ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.MilliamperePerSecond) => new ElectricCurrentGradient(_value * 1000, ElectricCurrentGradientUnit.MilliamperePerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index bbbdc7d99a..2d541b5f88 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static ElectricField() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricField(double value, ElectricFieldUnit unit) + public ElectricField(QuantityValue value, ElectricFieldUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public ElectricField(double value, ElectricFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricField(double value, UnitSystem unitSystem) + public ElectricField(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); + public QuantityValue VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static ElectricField FromVoltsPerMeter(double value) + public static ElectricField FromVoltsPerMeter(QuantityValue value) { return new ElectricField(value, ElectricFieldUnit.VoltPerMeter); } @@ -233,7 +234,7 @@ public static ElectricField FromVoltsPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// ElectricField unit value. - public static ElectricField From(double value, ElectricFieldUnit fromUnit) + public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit) { return new ElectricField(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricField operator *(double left, ElectricField right) + public static ElectricField operator *(QuantityValue left, ElectricField right) { return new ElectricField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricField operator *(ElectricField left, double right) + public static ElectricField operator *(ElectricField left, QuantityValue right) { return new ElectricField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricField operator /(ElectricField left, double right) + public static ElectricField operator /(ElectricField left, QuantityValue right) { return new ElectricField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricField left, ElectricField right) + public static QuantityValue operator /(ElectricField left, ElectricField right) { return left.VoltsPerMeter / right.VoltsPerMeter; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricField left, ElectricField right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricField other, ElectricField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricField left, ElectricField right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricField otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricField other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(ElectricField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricField other, ElectricField tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(ElectricField other, ElectricField tolerance) /// A hash code for the current ElectricField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricFieldUnit unit) + public QuantityValue As(ElectricFieldUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(ElectricFieldUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 238cc49560..b2aa8c9066 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,7 +86,7 @@ static ElectricInductance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricInductance(double value, ElectricInductanceUnit unit) + public ElectricInductance(QuantityValue value, ElectricInductanceUnit unit) { _value = value; _unit = unit; @@ -99,7 +100,7 @@ public ElectricInductance(double value, ElectricInductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricInductance(double value, UnitSystem unitSystem) + public ElectricInductance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -150,10 +151,10 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -178,27 +179,27 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Henries => As(ElectricInductanceUnit.Henry); + public QuantityValue Henries => As(ElectricInductanceUnit.Henry); /// /// Gets a value of this quantity converted into /// - public double Microhenries => As(ElectricInductanceUnit.Microhenry); + public QuantityValue Microhenries => As(ElectricInductanceUnit.Microhenry); /// /// Gets a value of this quantity converted into /// - public double Millihenries => As(ElectricInductanceUnit.Millihenry); + public QuantityValue Millihenries => As(ElectricInductanceUnit.Millihenry); /// /// Gets a value of this quantity converted into /// - public double Nanohenries => As(ElectricInductanceUnit.Nanohenry); + public QuantityValue Nanohenries => As(ElectricInductanceUnit.Nanohenry); /// /// Gets a value of this quantity converted into /// - public double Picohenries => As(ElectricInductanceUnit.Picohenry); + public QuantityValue Picohenries => As(ElectricInductanceUnit.Picohenry); #endregion @@ -254,7 +255,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvide /// /// Creates a from . /// - public static ElectricInductance FromHenries(double value) + public static ElectricInductance FromHenries(QuantityValue value) { return new ElectricInductance(value, ElectricInductanceUnit.Henry); } @@ -262,7 +263,7 @@ public static ElectricInductance FromHenries(double value) /// /// Creates a from . /// - public static ElectricInductance FromMicrohenries(double value) + public static ElectricInductance FromMicrohenries(QuantityValue value) { return new ElectricInductance(value, ElectricInductanceUnit.Microhenry); } @@ -270,7 +271,7 @@ public static ElectricInductance FromMicrohenries(double value) /// /// Creates a from . /// - public static ElectricInductance FromMillihenries(double value) + public static ElectricInductance FromMillihenries(QuantityValue value) { return new ElectricInductance(value, ElectricInductanceUnit.Millihenry); } @@ -278,7 +279,7 @@ public static ElectricInductance FromMillihenries(double value) /// /// Creates a from . /// - public static ElectricInductance FromNanohenries(double value) + public static ElectricInductance FromNanohenries(QuantityValue value) { return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry); } @@ -286,7 +287,7 @@ public static ElectricInductance FromNanohenries(double value) /// /// Creates a from . /// - public static ElectricInductance FromPicohenries(double value) + public static ElectricInductance FromPicohenries(QuantityValue value) { return new ElectricInductance(value, ElectricInductanceUnit.Picohenry); } @@ -297,7 +298,7 @@ public static ElectricInductance FromPicohenries(double value) /// Value to convert from. /// Unit to convert from. /// ElectricInductance unit value. - public static ElectricInductance From(double value, ElectricInductanceUnit fromUnit) + public static ElectricInductance From(QuantityValue value, ElectricInductanceUnit fromUnit) { return new ElectricInductance(value, fromUnit); } @@ -469,25 +470,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricInductance operator *(double left, ElectricInductance right) + public static ElectricInductance operator *(QuantityValue left, ElectricInductance right) { return new ElectricInductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricInductance operator *(ElectricInductance left, double right) + public static ElectricInductance operator *(ElectricInductance left, QuantityValue right) { return new ElectricInductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricInductance operator /(ElectricInductance left, double right) + public static ElectricInductance operator /(ElectricInductance left, QuantityValue right) { return new ElectricInductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricInductance left, ElectricInductance right) + public static QuantityValue operator /(ElectricInductance left, ElectricInductance right) { return left.Henries / right.Henries; } @@ -520,27 +521,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricInductance left, ElectricInductance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricInductance other, ElectricInductance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricInductance left, ElectricInductance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricInductance otherQuantity)) @@ -550,15 +544,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricInductance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -641,10 +632,10 @@ public bool Equals(ElectricInductance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -661,7 +652,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricInductance other, ElectricInductance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -674,7 +665,12 @@ public bool Equals(ElectricInductance other, ElectricInductance tolerance) /// A hash code for the current ElectricInductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -685,7 +681,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricInductanceUnit unit) + public QuantityValue As(ElectricInductanceUnit unit) { if (Unit == unit) return Value; @@ -694,7 +690,7 @@ public double As(ElectricInductanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -709,7 +705,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); @@ -775,16 +771,16 @@ private bool TryToUnit(ElectricInductanceUnit unit, [NotNullWhen(true)] out Elec ElectricInductance? convertedOrNull = (Unit, unit) switch { // ElectricInductanceUnit -> BaseUnit - (ElectricInductanceUnit.Microhenry, ElectricInductanceUnit.Henry) => new ElectricInductance((_value) * 1e-6d, ElectricInductanceUnit.Henry), - (ElectricInductanceUnit.Millihenry, ElectricInductanceUnit.Henry) => new ElectricInductance((_value) * 1e-3d, ElectricInductanceUnit.Henry), - (ElectricInductanceUnit.Nanohenry, ElectricInductanceUnit.Henry) => new ElectricInductance((_value) * 1e-9d, ElectricInductanceUnit.Henry), - (ElectricInductanceUnit.Picohenry, ElectricInductanceUnit.Henry) => new ElectricInductance((_value) * 1e-12d, ElectricInductanceUnit.Henry), + (ElectricInductanceUnit.Microhenry, ElectricInductanceUnit.Henry) => new ElectricInductance(_value / 1000000, ElectricInductanceUnit.Henry), + (ElectricInductanceUnit.Millihenry, ElectricInductanceUnit.Henry) => new ElectricInductance(_value / 1000, ElectricInductanceUnit.Henry), + (ElectricInductanceUnit.Nanohenry, ElectricInductanceUnit.Henry) => new ElectricInductance(_value / 1000000000, ElectricInductanceUnit.Henry), + (ElectricInductanceUnit.Picohenry, ElectricInductanceUnit.Henry) => new ElectricInductance(_value / 1000000000000, ElectricInductanceUnit.Henry), // BaseUnit -> ElectricInductanceUnit - (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Microhenry) => new ElectricInductance((_value) / 1e-6d, ElectricInductanceUnit.Microhenry), - (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Millihenry) => new ElectricInductance((_value) / 1e-3d, ElectricInductanceUnit.Millihenry), - (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Nanohenry) => new ElectricInductance((_value) / 1e-9d, ElectricInductanceUnit.Nanohenry), - (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Picohenry) => new ElectricInductance((_value) / 1e-12d, ElectricInductanceUnit.Picohenry), + (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Microhenry) => new ElectricInductance(_value * 1000000, ElectricInductanceUnit.Microhenry), + (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Millihenry) => new ElectricInductance(_value * 1000, ElectricInductanceUnit.Millihenry), + (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Nanohenry) => new ElectricInductance(_value * 1000000000, ElectricInductanceUnit.Nanohenry), + (ElectricInductanceUnit.Henry, ElectricInductanceUnit.Picohenry) => new ElectricInductance(_value * 1000000000000, ElectricInductanceUnit.Picohenry), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index adbea34a4d..e8b053a569 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -57,7 +55,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -92,7 +90,7 @@ static ElectricPotential() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricPotential(double value, ElectricPotentialUnit unit) + public ElectricPotential(QuantityValue value, ElectricPotentialUnit unit) { _value = value; _unit = unit; @@ -106,7 +104,7 @@ public ElectricPotential(double value, ElectricPotentialUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotential(double value, UnitSystem unitSystem) + public ElectricPotential(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -157,10 +155,10 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -185,32 +183,32 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Kilovolts => As(ElectricPotentialUnit.Kilovolt); + public QuantityValue Kilovolts => As(ElectricPotentialUnit.Kilovolt); /// /// Gets a value of this quantity converted into /// - public double Megavolts => As(ElectricPotentialUnit.Megavolt); + public QuantityValue Megavolts => As(ElectricPotentialUnit.Megavolt); /// /// Gets a value of this quantity converted into /// - public double Microvolts => As(ElectricPotentialUnit.Microvolt); + public QuantityValue Microvolts => As(ElectricPotentialUnit.Microvolt); /// /// Gets a value of this quantity converted into /// - public double Millivolts => As(ElectricPotentialUnit.Millivolt); + public QuantityValue Millivolts => As(ElectricPotentialUnit.Millivolt); /// /// Gets a value of this quantity converted into /// - public double Nanovolts => As(ElectricPotentialUnit.Nanovolt); + public QuantityValue Nanovolts => As(ElectricPotentialUnit.Nanovolt); /// /// Gets a value of this quantity converted into /// - public double Volts => As(ElectricPotentialUnit.Volt); + public QuantityValue Volts => As(ElectricPotentialUnit.Volt); #endregion @@ -268,7 +266,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider /// /// Creates a from . /// - public static ElectricPotential FromKilovolts(double value) + public static ElectricPotential FromKilovolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt); } @@ -276,7 +274,7 @@ public static ElectricPotential FromKilovolts(double value) /// /// Creates a from . /// - public static ElectricPotential FromMegavolts(double value) + public static ElectricPotential FromMegavolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Megavolt); } @@ -284,7 +282,7 @@ public static ElectricPotential FromMegavolts(double value) /// /// Creates a from . /// - public static ElectricPotential FromMicrovolts(double value) + public static ElectricPotential FromMicrovolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Microvolt); } @@ -292,7 +290,7 @@ public static ElectricPotential FromMicrovolts(double value) /// /// Creates a from . /// - public static ElectricPotential FromMillivolts(double value) + public static ElectricPotential FromMillivolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Millivolt); } @@ -300,7 +298,7 @@ public static ElectricPotential FromMillivolts(double value) /// /// Creates a from . /// - public static ElectricPotential FromNanovolts(double value) + public static ElectricPotential FromNanovolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Nanovolt); } @@ -308,7 +306,7 @@ public static ElectricPotential FromNanovolts(double value) /// /// Creates a from . /// - public static ElectricPotential FromVolts(double value) + public static ElectricPotential FromVolts(QuantityValue value) { return new ElectricPotential(value, ElectricPotentialUnit.Volt); } @@ -319,7 +317,7 @@ public static ElectricPotential FromVolts(double value) /// Value to convert from. /// Unit to convert from. /// ElectricPotential unit value. - public static ElectricPotential From(double value, ElectricPotentialUnit fromUnit) + public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit fromUnit) { return new ElectricPotential(value, fromUnit); } @@ -491,25 +489,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotential operator *(double left, ElectricPotential right) + public static ElectricPotential operator *(QuantityValue left, ElectricPotential right) { return new ElectricPotential(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotential operator *(ElectricPotential left, double right) + public static ElectricPotential operator *(ElectricPotential left, QuantityValue right) { return new ElectricPotential(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotential operator /(ElectricPotential left, double right) + public static ElectricPotential operator /(ElectricPotential left, QuantityValue right) { return new ElectricPotential(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotential left, ElectricPotential right) + public static QuantityValue operator /(ElectricPotential left, ElectricPotential right) { return left.Volts / right.Volts; } @@ -570,27 +568,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricPotential left, ElectricPotential right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotential other, ElectricPotential tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricPotential left, ElectricPotential right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotential otherQuantity)) @@ -600,15 +591,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricPotential other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -691,10 +679,10 @@ public bool Equals(ElectricPotential other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -711,7 +699,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotential other, ElectricPotential tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -724,7 +712,12 @@ public bool Equals(ElectricPotential other, ElectricPotential tolerance) /// A hash code for the current ElectricPotential. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -735,7 +728,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialUnit unit) + public QuantityValue As(ElectricPotentialUnit unit) { if (Unit == unit) return Value; @@ -744,7 +737,7 @@ public double As(ElectricPotentialUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -759,7 +752,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); @@ -825,18 +818,18 @@ private bool TryToUnit(ElectricPotentialUnit unit, [NotNullWhen(true)] out Elect ElectricPotential? convertedOrNull = (Unit, unit) switch { // ElectricPotentialUnit -> BaseUnit - (ElectricPotentialUnit.Kilovolt, ElectricPotentialUnit.Volt) => new ElectricPotential((_value) * 1e3d, ElectricPotentialUnit.Volt), - (ElectricPotentialUnit.Megavolt, ElectricPotentialUnit.Volt) => new ElectricPotential((_value) * 1e6d, ElectricPotentialUnit.Volt), - (ElectricPotentialUnit.Microvolt, ElectricPotentialUnit.Volt) => new ElectricPotential((_value) * 1e-6d, ElectricPotentialUnit.Volt), - (ElectricPotentialUnit.Millivolt, ElectricPotentialUnit.Volt) => new ElectricPotential((_value) * 1e-3d, ElectricPotentialUnit.Volt), - (ElectricPotentialUnit.Nanovolt, ElectricPotentialUnit.Volt) => new ElectricPotential((_value) * 1e-9d, ElectricPotentialUnit.Volt), + (ElectricPotentialUnit.Kilovolt, ElectricPotentialUnit.Volt) => new ElectricPotential(_value * 1000, ElectricPotentialUnit.Volt), + (ElectricPotentialUnit.Megavolt, ElectricPotentialUnit.Volt) => new ElectricPotential(_value * 1000000, ElectricPotentialUnit.Volt), + (ElectricPotentialUnit.Microvolt, ElectricPotentialUnit.Volt) => new ElectricPotential(_value / 1000000, ElectricPotentialUnit.Volt), + (ElectricPotentialUnit.Millivolt, ElectricPotentialUnit.Volt) => new ElectricPotential(_value / 1000, ElectricPotentialUnit.Volt), + (ElectricPotentialUnit.Nanovolt, ElectricPotentialUnit.Volt) => new ElectricPotential(_value / 1000000000, ElectricPotentialUnit.Volt), // BaseUnit -> ElectricPotentialUnit - (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Kilovolt) => new ElectricPotential((_value) / 1e3d, ElectricPotentialUnit.Kilovolt), - (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Megavolt) => new ElectricPotential((_value) / 1e6d, ElectricPotentialUnit.Megavolt), - (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Microvolt) => new ElectricPotential((_value) / 1e-6d, ElectricPotentialUnit.Microvolt), - (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Millivolt) => new ElectricPotential((_value) / 1e-3d, ElectricPotentialUnit.Millivolt), - (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Nanovolt) => new ElectricPotential((_value) / 1e-9d, ElectricPotentialUnit.Nanovolt), + (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Kilovolt) => new ElectricPotential(_value / 1000, ElectricPotentialUnit.Kilovolt), + (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Megavolt) => new ElectricPotential(_value / 1000000, ElectricPotentialUnit.Megavolt), + (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Microvolt) => new ElectricPotential(_value * 1000000, ElectricPotentialUnit.Microvolt), + (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Millivolt) => new ElectricPotential(_value * 1000, ElectricPotentialUnit.Millivolt), + (ElectricPotentialUnit.Volt, ElectricPotentialUnit.Nanovolt) => new ElectricPotential(_value * 1000000000, ElectricPotentialUnit.Nanovolt), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index ded996bd64..fc24344cb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,7 +83,7 @@ static ElectricPotentialAc() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) + public ElectricPotentialAc(QuantityValue value, ElectricPotentialAcUnit unit) { _value = value; _unit = unit; @@ -96,7 +97,7 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialAc(double value, UnitSystem unitSystem) + public ElectricPotentialAc(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -147,10 +148,10 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -175,27 +176,27 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); + public QuantityValue KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); /// /// Gets a value of this quantity converted into /// - public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); + public QuantityValue MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); + public QuantityValue MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); /// /// Gets a value of this quantity converted into /// - public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); + public QuantityValue MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); /// /// Gets a value of this quantity converted into /// - public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc); + public QuantityValue VoltsAc => As(ElectricPotentialAcUnit.VoltAc); #endregion @@ -251,7 +252,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvid /// /// Creates a from . /// - public static ElectricPotentialAc FromKilovoltsAc(double value) + public static ElectricPotentialAc FromKilovoltsAc(QuantityValue value) { return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc); } @@ -259,7 +260,7 @@ public static ElectricPotentialAc FromKilovoltsAc(double value) /// /// Creates a from . /// - public static ElectricPotentialAc FromMegavoltsAc(double value) + public static ElectricPotentialAc FromMegavoltsAc(QuantityValue value) { return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc); } @@ -267,7 +268,7 @@ public static ElectricPotentialAc FromMegavoltsAc(double value) /// /// Creates a from . /// - public static ElectricPotentialAc FromMicrovoltsAc(double value) + public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue value) { return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc); } @@ -275,7 +276,7 @@ public static ElectricPotentialAc FromMicrovoltsAc(double value) /// /// Creates a from . /// - public static ElectricPotentialAc FromMillivoltsAc(double value) + public static ElectricPotentialAc FromMillivoltsAc(QuantityValue value) { return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc); } @@ -283,7 +284,7 @@ public static ElectricPotentialAc FromMillivoltsAc(double value) /// /// Creates a from . /// - public static ElectricPotentialAc FromVoltsAc(double value) + public static ElectricPotentialAc FromVoltsAc(QuantityValue value) { return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc); } @@ -294,7 +295,7 @@ public static ElectricPotentialAc FromVoltsAc(double value) /// Value to convert from. /// Unit to convert from. /// ElectricPotentialAc unit value. - public static ElectricPotentialAc From(double value, ElectricPotentialAcUnit fromUnit) + public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcUnit fromUnit) { return new ElectricPotentialAc(value, fromUnit); } @@ -466,25 +467,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(double left, ElectricPotentialAc right) + public static ElectricPotentialAc operator *(QuantityValue left, ElectricPotentialAc right) { return new ElectricPotentialAc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(ElectricPotentialAc left, double right) + public static ElectricPotentialAc operator *(ElectricPotentialAc left, QuantityValue right) { return new ElectricPotentialAc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialAc operator /(ElectricPotentialAc left, double right) + public static ElectricPotentialAc operator /(ElectricPotentialAc left, QuantityValue right) { return new ElectricPotentialAc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialAc left, ElectricPotentialAc right) + public static QuantityValue operator /(ElectricPotentialAc left, ElectricPotentialAc right) { return left.VoltsAc / right.VoltsAc; } @@ -517,27 +518,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialAc otherQuantity)) @@ -547,15 +541,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricPotentialAc other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -638,10 +629,10 @@ public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -658,7 +649,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -671,7 +662,12 @@ public bool Equals(ElectricPotentialAc other, ElectricPotentialAc tolerance) /// A hash code for the current ElectricPotentialAc. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -682,7 +678,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialAcUnit unit) + public QuantityValue As(ElectricPotentialAcUnit unit) { if (Unit == unit) return Value; @@ -691,7 +687,7 @@ public double As(ElectricPotentialAcUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -706,7 +702,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); @@ -772,16 +768,16 @@ private bool TryToUnit(ElectricPotentialAcUnit unit, [NotNullWhen(true)] out Ele ElectricPotentialAc? convertedOrNull = (Unit, unit) switch { // ElectricPotentialAcUnit -> BaseUnit - (ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc((_value) * 1e3d, ElectricPotentialAcUnit.VoltAc), - (ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc((_value) * 1e6d, ElectricPotentialAcUnit.VoltAc), - (ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc((_value) * 1e-6d, ElectricPotentialAcUnit.VoltAc), - (ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc((_value) * 1e-3d, ElectricPotentialAcUnit.VoltAc), + (ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc(_value * 1000, ElectricPotentialAcUnit.VoltAc), + (ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc(_value * 1000000, ElectricPotentialAcUnit.VoltAc), + (ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc(_value / 1000000, ElectricPotentialAcUnit.VoltAc), + (ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAcUnit.VoltAc) => new ElectricPotentialAc(_value / 1000, ElectricPotentialAcUnit.VoltAc), // BaseUnit -> ElectricPotentialAcUnit - (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.KilovoltAc) => new ElectricPotentialAc((_value) / 1e3d, ElectricPotentialAcUnit.KilovoltAc), - (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MegavoltAc) => new ElectricPotentialAc((_value) / 1e6d, ElectricPotentialAcUnit.MegavoltAc), - (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MicrovoltAc) => new ElectricPotentialAc((_value) / 1e-6d, ElectricPotentialAcUnit.MicrovoltAc), - (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MillivoltAc) => new ElectricPotentialAc((_value) / 1e-3d, ElectricPotentialAcUnit.MillivoltAc), + (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.KilovoltAc) => new ElectricPotentialAc(_value / 1000, ElectricPotentialAcUnit.KilovoltAc), + (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MegavoltAc) => new ElectricPotentialAc(_value / 1000000, ElectricPotentialAcUnit.MegavoltAc), + (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MicrovoltAc) => new ElectricPotentialAc(_value * 1000000, ElectricPotentialAcUnit.MicrovoltAc), + (ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MillivoltAc) => new ElectricPotentialAc(_value * 1000, ElectricPotentialAcUnit.MillivoltAc), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index ce5b94139f..668e755be0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +98,7 @@ static ElectricPotentialChangeRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) + public ElectricPotentialChangeRate(QuantityValue value, ElectricPotentialChangeRateUnit unit) { _value = value; _unit = unit; @@ -111,7 +112,7 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) + public ElectricPotentialChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,10 +163,10 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -190,102 +191,102 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilovoltsPerHour => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); + public QuantityValue KilovoltsPerHour => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); /// /// Gets a value of this quantity converted into /// - public double KilovoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + public QuantityValue KilovoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double KilovoltsPerMinute => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); + public QuantityValue KilovoltsPerMinute => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilovoltsPerSecond => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); + public QuantityValue KilovoltsPerSecond => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegavoltsPerHour => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); + public QuantityValue MegavoltsPerHour => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); /// /// Gets a value of this quantity converted into /// - public double MegavoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + public QuantityValue MegavoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double MegavoltsPerMinute => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); + public QuantityValue MegavoltsPerMinute => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); /// /// Gets a value of this quantity converted into /// - public double MegavoltsPerSecond => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); + public QuantityValue MegavoltsPerSecond => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsPerHour => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); + public QuantityValue MicrovoltsPerHour => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + public QuantityValue MicrovoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsPerMinute => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + public QuantityValue MicrovoltsPerMinute => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsPerSecond => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + public QuantityValue MicrovoltsPerSecond => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillivoltsPerHour => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); + public QuantityValue MillivoltsPerHour => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); /// /// Gets a value of this quantity converted into /// - public double MillivoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + public QuantityValue MillivoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double MillivoltsPerMinute => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); + public QuantityValue MillivoltsPerMinute => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); /// /// Gets a value of this quantity converted into /// - public double MillivoltsPerSecond => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); + public QuantityValue MillivoltsPerSecond => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); /// /// Gets a value of this quantity converted into /// - public double VoltsPerHour => As(ElectricPotentialChangeRateUnit.VoltPerHour); + public QuantityValue VoltsPerHour => As(ElectricPotentialChangeRateUnit.VoltPerHour); /// /// Gets a value of this quantity converted into /// - public double VoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + public QuantityValue VoltsPerMicrosecond => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); /// /// Gets a value of this quantity converted into /// - public double VoltsPerMinute => As(ElectricPotentialChangeRateUnit.VoltPerMinute); + public QuantityValue VoltsPerMinute => As(ElectricPotentialChangeRateUnit.VoltPerMinute); /// /// Gets a value of this quantity converted into /// - public double VoltsPerSecond => As(ElectricPotentialChangeRateUnit.VoltPerSecond); + public QuantityValue VoltsPerSecond => As(ElectricPotentialChangeRateUnit.VoltPerSecond); #endregion @@ -371,7 +372,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IForm /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromKilovoltsPerHour(double value) + public static ElectricPotentialChangeRate FromKilovoltsPerHour(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerHour); } @@ -379,7 +380,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerHour(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromKilovoltsPerMicrosecond(double value) + public static ElectricPotentialChangeRate FromKilovoltsPerMicrosecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); } @@ -387,7 +388,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMicrosecond(double val /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromKilovoltsPerMinute(double value) + public static ElectricPotentialChangeRate FromKilovoltsPerMinute(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMinute); } @@ -395,7 +396,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMinute(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromKilovoltsPerSecond(double value) + public static ElectricPotentialChangeRate FromKilovoltsPerSecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerSecond); } @@ -403,7 +404,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerSecond(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMegavoltsPerHour(double value) + public static ElectricPotentialChangeRate FromMegavoltsPerHour(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerHour); } @@ -411,7 +412,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerHour(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMegavoltsPerMicrosecond(double value) + public static ElectricPotentialChangeRate FromMegavoltsPerMicrosecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); } @@ -419,7 +420,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMicrosecond(double val /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMegavoltsPerMinute(double value) + public static ElectricPotentialChangeRate FromMegavoltsPerMinute(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMinute); } @@ -427,7 +428,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMinute(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMegavoltsPerSecond(double value) + public static ElectricPotentialChangeRate FromMegavoltsPerSecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerSecond); } @@ -435,7 +436,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerSecond(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMicrovoltsPerHour(double value) + public static ElectricPotentialChangeRate FromMicrovoltsPerHour(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerHour); } @@ -443,7 +444,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerHour(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMicrovoltsPerMicrosecond(double value) + public static ElectricPotentialChangeRate FromMicrovoltsPerMicrosecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); } @@ -451,7 +452,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMicrosecond(double va /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMicrovoltsPerMinute(double value) + public static ElectricPotentialChangeRate FromMicrovoltsPerMinute(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); } @@ -459,7 +460,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMinute(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMicrovoltsPerSecond(double value) + public static ElectricPotentialChangeRate FromMicrovoltsPerSecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); } @@ -467,7 +468,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerSecond(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMillivoltsPerHour(double value) + public static ElectricPotentialChangeRate FromMillivoltsPerHour(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerHour); } @@ -475,7 +476,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerHour(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMillivoltsPerMicrosecond(double value) + public static ElectricPotentialChangeRate FromMillivoltsPerMicrosecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); } @@ -483,7 +484,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMicrosecond(double va /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMillivoltsPerMinute(double value) + public static ElectricPotentialChangeRate FromMillivoltsPerMinute(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMinute); } @@ -491,7 +492,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMinute(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromMillivoltsPerSecond(double value) + public static ElectricPotentialChangeRate FromMillivoltsPerSecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerSecond); } @@ -499,7 +500,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerSecond(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromVoltsPerHour(double value) + public static ElectricPotentialChangeRate FromVoltsPerHour(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerHour); } @@ -507,7 +508,7 @@ public static ElectricPotentialChangeRate FromVoltsPerHour(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromVoltsPerMicrosecond(double value) + public static ElectricPotentialChangeRate FromVoltsPerMicrosecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); } @@ -515,7 +516,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMicrosecond(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromVoltsPerMinute(double value) + public static ElectricPotentialChangeRate FromVoltsPerMinute(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMinute); } @@ -523,7 +524,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMinute(double value) /// /// Creates a from . /// - public static ElectricPotentialChangeRate FromVoltsPerSecond(double value) + public static ElectricPotentialChangeRate FromVoltsPerSecond(QuantityValue value) { return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerSecond); } @@ -534,7 +535,7 @@ public static ElectricPotentialChangeRate FromVoltsPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// ElectricPotentialChangeRate unit value. - public static ElectricPotentialChangeRate From(double value, ElectricPotentialChangeRateUnit fromUnit) + public static ElectricPotentialChangeRate From(QuantityValue value, ElectricPotentialChangeRateUnit fromUnit) { return new ElectricPotentialChangeRate(value, fromUnit); } @@ -706,25 +707,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(double left, ElectricPotentialChangeRate right) + public static ElectricPotentialChangeRate operator *(QuantityValue left, ElectricPotentialChangeRate right) { return new ElectricPotentialChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, double right) + public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, QuantityValue right) { return new ElectricPotentialChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, double right) + public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, QuantityValue right) { return new ElectricPotentialChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static QuantityValue operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.VoltsPerSecond / right.VoltsPerSecond; } @@ -757,27 +758,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialChangeRate otherQuantity)) @@ -787,15 +781,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricPotentialChangeRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +869,10 @@ public bool Equals(ElectricPotentialChangeRate other, double tolerance, Comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -898,7 +889,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -911,7 +902,12 @@ public bool Equals(ElectricPotentialChangeRate other, ElectricPotentialChangeRat /// A hash code for the current ElectricPotentialChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -922,7 +918,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialChangeRateUnit unit) + public QuantityValue As(ElectricPotentialChangeRateUnit unit) { if (Unit == unit) return Value; @@ -931,7 +927,7 @@ public double As(ElectricPotentialChangeRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -946,7 +942,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); @@ -1012,45 +1008,45 @@ private bool TryToUnit(ElectricPotentialChangeRateUnit unit, [NotNullWhen(true)] ElectricPotentialChangeRate? convertedOrNull = (Unit, unit) switch { // ElectricPotentialChangeRateUnit -> BaseUnit - (ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 3600) * 1e3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value * 1E6) * 1e3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 60) * 1e3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value) * 1e3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 3600) * 1e6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value * 1E6) * 1e6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 60) * 1e6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value) * 1e6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 3600) * 1e-6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value * 1E6) * 1e-6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 60) * 1e-6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value) * 1e-6d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 3600) * 1e-3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value * 1E6) * 1e-3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value / 60) * 1e-3d, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate((_value) * 1e-3d, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * new QuantityValue(5, 18, false), ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * new QuantityValue(50, 3, false), ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * new QuantityValue(2500, 9, false), ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000000000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * new QuantityValue(50000, 3, false), ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 3600000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 60000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 1000000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 3600000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 60000, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 1000, ElectricPotentialChangeRateUnit.VoltPerSecond), (ElectricPotentialChangeRateUnit.VoltPerHour, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 3600, ElectricPotentialChangeRateUnit.VoltPerSecond), - (ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1E6, ElectricPotentialChangeRateUnit.VoltPerSecond), + (ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000000, ElectricPotentialChangeRateUnit.VoltPerSecond), (ElectricPotentialChangeRateUnit.VoltPerMinute, ElectricPotentialChangeRateUnit.VoltPerSecond) => new ElectricPotentialChangeRate(_value / 60, ElectricPotentialChangeRateUnit.VoltPerSecond), // BaseUnit -> ElectricPotentialChangeRateUnit - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerHour) => new ElectricPotentialChangeRate((_value * 3600) / 1e3d, ElectricPotentialChangeRateUnit.KilovoltPerHour), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond) => new ElectricPotentialChangeRate((_value / 1E6) / 1e3d, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerMinute) => new ElectricPotentialChangeRate((_value * 60) / 1e3d, ElectricPotentialChangeRateUnit.KilovoltPerMinute), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerSecond) => new ElectricPotentialChangeRate((_value) / 1e3d, ElectricPotentialChangeRateUnit.KilovoltPerSecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerHour) => new ElectricPotentialChangeRate((_value * 3600) / 1e6d, ElectricPotentialChangeRateUnit.MegavoltPerHour), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond) => new ElectricPotentialChangeRate((_value / 1E6) / 1e6d, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerMinute) => new ElectricPotentialChangeRate((_value * 60) / 1e6d, ElectricPotentialChangeRateUnit.MegavoltPerMinute), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerSecond) => new ElectricPotentialChangeRate((_value) / 1e6d, ElectricPotentialChangeRateUnit.MegavoltPerSecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerHour) => new ElectricPotentialChangeRate((_value * 3600) / 1e-6d, ElectricPotentialChangeRateUnit.MicrovoltPerHour), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond) => new ElectricPotentialChangeRate((_value / 1E6) / 1e-6d, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerMinute) => new ElectricPotentialChangeRate((_value * 60) / 1e-6d, ElectricPotentialChangeRateUnit.MicrovoltPerMinute), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerSecond) => new ElectricPotentialChangeRate((_value) / 1e-6d, ElectricPotentialChangeRateUnit.MicrovoltPerSecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerHour) => new ElectricPotentialChangeRate((_value * 3600) / 1e-3d, ElectricPotentialChangeRateUnit.MillivoltPerHour), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond) => new ElectricPotentialChangeRate((_value / 1E6) / 1e-3d, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerMinute) => new ElectricPotentialChangeRate((_value * 60) / 1e-3d, ElectricPotentialChangeRateUnit.MillivoltPerMinute), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerSecond) => new ElectricPotentialChangeRate((_value) / 1e-3d, ElectricPotentialChangeRateUnit.MillivoltPerSecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerHour) => new ElectricPotentialChangeRate(_value * new QuantityValue(18, 5, false), ElectricPotentialChangeRateUnit.KilovoltPerHour), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond) => new ElectricPotentialChangeRate(_value / 1000000000, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerMinute) => new ElectricPotentialChangeRate(_value * new QuantityValue(3, 50, false), ElectricPotentialChangeRateUnit.KilovoltPerMinute), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.KilovoltPerSecond) => new ElectricPotentialChangeRate(_value / 1000, ElectricPotentialChangeRateUnit.KilovoltPerSecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerHour) => new ElectricPotentialChangeRate(_value * new QuantityValue(9, 2500, false), ElectricPotentialChangeRateUnit.MegavoltPerHour), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond) => new ElectricPotentialChangeRate(_value / 1000000000000, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerMinute) => new ElectricPotentialChangeRate(_value * new QuantityValue(3, 50000, false), ElectricPotentialChangeRateUnit.MegavoltPerMinute), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MegavoltPerSecond) => new ElectricPotentialChangeRate(_value / 1000000, ElectricPotentialChangeRateUnit.MegavoltPerSecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerHour) => new ElectricPotentialChangeRate(_value * 3600000000, ElectricPotentialChangeRateUnit.MicrovoltPerHour), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond) => new ElectricPotentialChangeRate(_value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerMinute) => new ElectricPotentialChangeRate(_value * 60000000, ElectricPotentialChangeRateUnit.MicrovoltPerMinute), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MicrovoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000000, ElectricPotentialChangeRateUnit.MicrovoltPerSecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerHour) => new ElectricPotentialChangeRate(_value * 3600000, ElectricPotentialChangeRateUnit.MillivoltPerHour), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond) => new ElectricPotentialChangeRate(_value / 1000, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerMinute) => new ElectricPotentialChangeRate(_value * 60000, ElectricPotentialChangeRateUnit.MillivoltPerMinute), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.MillivoltPerSecond) => new ElectricPotentialChangeRate(_value * 1000, ElectricPotentialChangeRateUnit.MillivoltPerSecond), (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerHour) => new ElectricPotentialChangeRate(_value * 3600, ElectricPotentialChangeRateUnit.VoltPerHour), - (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerMicrosecond) => new ElectricPotentialChangeRate(_value / 1E6, ElectricPotentialChangeRateUnit.VoltPerMicrosecond), + (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerMicrosecond) => new ElectricPotentialChangeRate(_value / 1000000, ElectricPotentialChangeRateUnit.VoltPerMicrosecond), (ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerMinute) => new ElectricPotentialChangeRate(_value * 60, ElectricPotentialChangeRateUnit.VoltPerMinute), _ => null diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 2e33b0e6d9..e212f9502b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,7 +83,7 @@ static ElectricPotentialDc() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) + public ElectricPotentialDc(QuantityValue value, ElectricPotentialDcUnit unit) { _value = value; _unit = unit; @@ -96,7 +97,7 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialDc(double value, UnitSystem unitSystem) + public ElectricPotentialDc(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -147,10 +148,10 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -175,27 +176,27 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); + public QuantityValue KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); /// /// Gets a value of this quantity converted into /// - public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); + public QuantityValue MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); /// /// Gets a value of this quantity converted into /// - public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); + public QuantityValue MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); /// /// Gets a value of this quantity converted into /// - public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); + public QuantityValue MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); /// /// Gets a value of this quantity converted into /// - public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc); + public QuantityValue VoltsDc => As(ElectricPotentialDcUnit.VoltDc); #endregion @@ -251,7 +252,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvid /// /// Creates a from . /// - public static ElectricPotentialDc FromKilovoltsDc(double value) + public static ElectricPotentialDc FromKilovoltsDc(QuantityValue value) { return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc); } @@ -259,7 +260,7 @@ public static ElectricPotentialDc FromKilovoltsDc(double value) /// /// Creates a from . /// - public static ElectricPotentialDc FromMegavoltsDc(double value) + public static ElectricPotentialDc FromMegavoltsDc(QuantityValue value) { return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc); } @@ -267,7 +268,7 @@ public static ElectricPotentialDc FromMegavoltsDc(double value) /// /// Creates a from . /// - public static ElectricPotentialDc FromMicrovoltsDc(double value) + public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue value) { return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc); } @@ -275,7 +276,7 @@ public static ElectricPotentialDc FromMicrovoltsDc(double value) /// /// Creates a from . /// - public static ElectricPotentialDc FromMillivoltsDc(double value) + public static ElectricPotentialDc FromMillivoltsDc(QuantityValue value) { return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc); } @@ -283,7 +284,7 @@ public static ElectricPotentialDc FromMillivoltsDc(double value) /// /// Creates a from . /// - public static ElectricPotentialDc FromVoltsDc(double value) + public static ElectricPotentialDc FromVoltsDc(QuantityValue value) { return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc); } @@ -294,7 +295,7 @@ public static ElectricPotentialDc FromVoltsDc(double value) /// Value to convert from. /// Unit to convert from. /// ElectricPotentialDc unit value. - public static ElectricPotentialDc From(double value, ElectricPotentialDcUnit fromUnit) + public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcUnit fromUnit) { return new ElectricPotentialDc(value, fromUnit); } @@ -466,25 +467,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(double left, ElectricPotentialDc right) + public static ElectricPotentialDc operator *(QuantityValue left, ElectricPotentialDc right) { return new ElectricPotentialDc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(ElectricPotentialDc left, double right) + public static ElectricPotentialDc operator *(ElectricPotentialDc left, QuantityValue right) { return new ElectricPotentialDc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialDc operator /(ElectricPotentialDc left, double right) + public static ElectricPotentialDc operator /(ElectricPotentialDc left, QuantityValue right) { return new ElectricPotentialDc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialDc left, ElectricPotentialDc right) + public static QuantityValue operator /(ElectricPotentialDc left, ElectricPotentialDc right) { return left.VoltsDc / right.VoltsDc; } @@ -517,27 +518,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricPotentialDc otherQuantity)) @@ -547,15 +541,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricPotentialDc other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -638,10 +629,10 @@ public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -658,7 +649,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -671,7 +662,12 @@ public bool Equals(ElectricPotentialDc other, ElectricPotentialDc tolerance) /// A hash code for the current ElectricPotentialDc. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -682,7 +678,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialDcUnit unit) + public QuantityValue As(ElectricPotentialDcUnit unit) { if (Unit == unit) return Value; @@ -691,7 +687,7 @@ public double As(ElectricPotentialDcUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -706,7 +702,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); @@ -772,16 +768,16 @@ private bool TryToUnit(ElectricPotentialDcUnit unit, [NotNullWhen(true)] out Ele ElectricPotentialDc? convertedOrNull = (Unit, unit) switch { // ElectricPotentialDcUnit -> BaseUnit - (ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc((_value) * 1e3d, ElectricPotentialDcUnit.VoltDc), - (ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc((_value) * 1e6d, ElectricPotentialDcUnit.VoltDc), - (ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc((_value) * 1e-6d, ElectricPotentialDcUnit.VoltDc), - (ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc((_value) * 1e-3d, ElectricPotentialDcUnit.VoltDc), + (ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc(_value * 1000, ElectricPotentialDcUnit.VoltDc), + (ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc(_value * 1000000, ElectricPotentialDcUnit.VoltDc), + (ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc(_value / 1000000, ElectricPotentialDcUnit.VoltDc), + (ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDcUnit.VoltDc) => new ElectricPotentialDc(_value / 1000, ElectricPotentialDcUnit.VoltDc), // BaseUnit -> ElectricPotentialDcUnit - (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.KilovoltDc) => new ElectricPotentialDc((_value) / 1e3d, ElectricPotentialDcUnit.KilovoltDc), - (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MegavoltDc) => new ElectricPotentialDc((_value) / 1e6d, ElectricPotentialDcUnit.MegavoltDc), - (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MicrovoltDc) => new ElectricPotentialDc((_value) / 1e-6d, ElectricPotentialDcUnit.MicrovoltDc), - (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MillivoltDc) => new ElectricPotentialDc((_value) / 1e-3d, ElectricPotentialDcUnit.MillivoltDc), + (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.KilovoltDc) => new ElectricPotentialDc(_value / 1000, ElectricPotentialDcUnit.KilovoltDc), + (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MegavoltDc) => new ElectricPotentialDc(_value / 1000000, ElectricPotentialDcUnit.MegavoltDc), + (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MicrovoltDc) => new ElectricPotentialDc(_value * 1000000, ElectricPotentialDcUnit.MicrovoltDc), + (ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MillivoltDc) => new ElectricPotentialDc(_value * 1000, ElectricPotentialDcUnit.MillivoltDc), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index e3e3b52d35..acd432a81a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -90,7 +88,7 @@ static ElectricResistance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricResistance(double value, ElectricResistanceUnit unit) + public ElectricResistance(QuantityValue value, ElectricResistanceUnit unit) { _value = value; _unit = unit; @@ -104,7 +102,7 @@ public ElectricResistance(double value, ElectricResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistance(double value, UnitSystem unitSystem) + public ElectricResistance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -155,10 +153,10 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,37 +181,37 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Gigaohms => As(ElectricResistanceUnit.Gigaohm); + public QuantityValue Gigaohms => As(ElectricResistanceUnit.Gigaohm); /// /// Gets a value of this quantity converted into /// - public double Kiloohms => As(ElectricResistanceUnit.Kiloohm); + public QuantityValue Kiloohms => As(ElectricResistanceUnit.Kiloohm); /// /// Gets a value of this quantity converted into /// - public double Megaohms => As(ElectricResistanceUnit.Megaohm); + public QuantityValue Megaohms => As(ElectricResistanceUnit.Megaohm); /// /// Gets a value of this quantity converted into /// - public double Microohms => As(ElectricResistanceUnit.Microohm); + public QuantityValue Microohms => As(ElectricResistanceUnit.Microohm); /// /// Gets a value of this quantity converted into /// - public double Milliohms => As(ElectricResistanceUnit.Milliohm); + public QuantityValue Milliohms => As(ElectricResistanceUnit.Milliohm); /// /// Gets a value of this quantity converted into /// - public double Ohms => As(ElectricResistanceUnit.Ohm); + public QuantityValue Ohms => As(ElectricResistanceUnit.Ohm); /// /// Gets a value of this quantity converted into /// - public double Teraohms => As(ElectricResistanceUnit.Teraohm); + public QuantityValue Teraohms => As(ElectricResistanceUnit.Teraohm); #endregion @@ -273,7 +271,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvide /// /// Creates a from . /// - public static ElectricResistance FromGigaohms(double value) + public static ElectricResistance FromGigaohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm); } @@ -281,7 +279,7 @@ public static ElectricResistance FromGigaohms(double value) /// /// Creates a from . /// - public static ElectricResistance FromKiloohms(double value) + public static ElectricResistance FromKiloohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm); } @@ -289,7 +287,7 @@ public static ElectricResistance FromKiloohms(double value) /// /// Creates a from . /// - public static ElectricResistance FromMegaohms(double value) + public static ElectricResistance FromMegaohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Megaohm); } @@ -297,7 +295,7 @@ public static ElectricResistance FromMegaohms(double value) /// /// Creates a from . /// - public static ElectricResistance FromMicroohms(double value) + public static ElectricResistance FromMicroohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Microohm); } @@ -305,7 +303,7 @@ public static ElectricResistance FromMicroohms(double value) /// /// Creates a from . /// - public static ElectricResistance FromMilliohms(double value) + public static ElectricResistance FromMilliohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Milliohm); } @@ -313,7 +311,7 @@ public static ElectricResistance FromMilliohms(double value) /// /// Creates a from . /// - public static ElectricResistance FromOhms(double value) + public static ElectricResistance FromOhms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Ohm); } @@ -321,7 +319,7 @@ public static ElectricResistance FromOhms(double value) /// /// Creates a from . /// - public static ElectricResistance FromTeraohms(double value) + public static ElectricResistance FromTeraohms(QuantityValue value) { return new ElectricResistance(value, ElectricResistanceUnit.Teraohm); } @@ -332,7 +330,7 @@ public static ElectricResistance FromTeraohms(double value) /// Value to convert from. /// Unit to convert from. /// ElectricResistance unit value. - public static ElectricResistance From(double value, ElectricResistanceUnit fromUnit) + public static ElectricResistance From(QuantityValue value, ElectricResistanceUnit fromUnit) { return new ElectricResistance(value, fromUnit); } @@ -504,25 +502,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistance operator *(double left, ElectricResistance right) + public static ElectricResistance operator *(QuantityValue left, ElectricResistance right) { return new ElectricResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistance operator *(ElectricResistance left, double right) + public static ElectricResistance operator *(ElectricResistance left, QuantityValue right) { return new ElectricResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistance operator /(ElectricResistance left, double right) + public static ElectricResistance operator /(ElectricResistance left, QuantityValue right) { return new ElectricResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricResistance left, ElectricResistance right) + public static QuantityValue operator /(ElectricResistance left, ElectricResistance right) { return left.Ohms / right.Ohms; } @@ -565,27 +563,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricResistance left, ElectricResistance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistance other, ElectricResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricResistance left, ElectricResistance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricResistance otherQuantity)) @@ -595,15 +586,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricResistance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -686,10 +674,10 @@ public bool Equals(ElectricResistance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -706,7 +694,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricResistance other, ElectricResistance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -719,7 +707,12 @@ public bool Equals(ElectricResistance other, ElectricResistance tolerance) /// A hash code for the current ElectricResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -730,7 +723,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistanceUnit unit) + public QuantityValue As(ElectricResistanceUnit unit) { if (Unit == unit) return Value; @@ -739,7 +732,7 @@ public double As(ElectricResistanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -754,7 +747,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); @@ -820,20 +813,20 @@ private bool TryToUnit(ElectricResistanceUnit unit, [NotNullWhen(true)] out Elec ElectricResistance? convertedOrNull = (Unit, unit) switch { // ElectricResistanceUnit -> BaseUnit - (ElectricResistanceUnit.Gigaohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e9d, ElectricResistanceUnit.Ohm), - (ElectricResistanceUnit.Kiloohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e3d, ElectricResistanceUnit.Ohm), - (ElectricResistanceUnit.Megaohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e6d, ElectricResistanceUnit.Ohm), - (ElectricResistanceUnit.Microohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e-6d, ElectricResistanceUnit.Ohm), - (ElectricResistanceUnit.Milliohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e-3d, ElectricResistanceUnit.Ohm), - (ElectricResistanceUnit.Teraohm, ElectricResistanceUnit.Ohm) => new ElectricResistance((_value) * 1e12d, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Gigaohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value * 1000000000, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Kiloohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value * 1000, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Megaohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value * 1000000, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Microohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value / 1000000, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Milliohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value / 1000, ElectricResistanceUnit.Ohm), + (ElectricResistanceUnit.Teraohm, ElectricResistanceUnit.Ohm) => new ElectricResistance(_value * 1000000000000, ElectricResistanceUnit.Ohm), // BaseUnit -> ElectricResistanceUnit - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Gigaohm) => new ElectricResistance((_value) / 1e9d, ElectricResistanceUnit.Gigaohm), - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Kiloohm) => new ElectricResistance((_value) / 1e3d, ElectricResistanceUnit.Kiloohm), - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Megaohm) => new ElectricResistance((_value) / 1e6d, ElectricResistanceUnit.Megaohm), - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Microohm) => new ElectricResistance((_value) / 1e-6d, ElectricResistanceUnit.Microohm), - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Milliohm) => new ElectricResistance((_value) / 1e-3d, ElectricResistanceUnit.Milliohm), - (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Teraohm) => new ElectricResistance((_value) / 1e12d, ElectricResistanceUnit.Teraohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Gigaohm) => new ElectricResistance(_value / 1000000000, ElectricResistanceUnit.Gigaohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Kiloohm) => new ElectricResistance(_value / 1000, ElectricResistanceUnit.Kiloohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Megaohm) => new ElectricResistance(_value / 1000000, ElectricResistanceUnit.Megaohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Microohm) => new ElectricResistance(_value * 1000000, ElectricResistanceUnit.Microohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Milliohm) => new ElectricResistance(_value * 1000, ElectricResistanceUnit.Milliohm), + (ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Teraohm) => new ElectricResistance(_value / 1000000000000, ElectricResistanceUnit.Teraohm), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index e9f74b5beb..82ce49dc6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -94,7 +95,7 @@ static ElectricResistivity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricResistivity(double value, ElectricResistivityUnit unit) + public ElectricResistivity(QuantityValue value, ElectricResistivityUnit unit) { _value = value; _unit = unit; @@ -108,7 +109,7 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistivity(double value, UnitSystem unitSystem) + public ElectricResistivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,10 +160,10 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -187,72 +188,72 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); + public QuantityValue KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); + public QuantityValue KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); /// /// Gets a value of this quantity converted into /// - public double MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); + public QuantityValue MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); + public QuantityValue MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); /// /// Gets a value of this quantity converted into /// - public double MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); + public QuantityValue MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); + public QuantityValue MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); /// /// Gets a value of this quantity converted into /// - public double MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); + public QuantityValue MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); + public QuantityValue MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); /// /// Gets a value of this quantity converted into /// - public double NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); + public QuantityValue NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); + public QuantityValue NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); /// /// Gets a value of this quantity converted into /// - public double OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); + public QuantityValue OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); /// /// Gets a value of this quantity converted into /// - public double OhmMeters => As(ElectricResistivityUnit.OhmMeter); + public QuantityValue OhmMeters => As(ElectricResistivityUnit.OhmMeter); /// /// Gets a value of this quantity converted into /// - public double PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); + public QuantityValue PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); /// /// Gets a value of this quantity converted into /// - public double PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); + public QuantityValue PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); #endregion @@ -326,7 +327,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvid /// /// Creates a from . /// - public static ElectricResistivity FromKiloohmsCentimeter(double value) + public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmCentimeter); } @@ -334,7 +335,7 @@ public static ElectricResistivity FromKiloohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromKiloohmMeters(double value) + public static ElectricResistivity FromKiloohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmMeter); } @@ -342,7 +343,7 @@ public static ElectricResistivity FromKiloohmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMegaohmsCentimeter(double value) + public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmCentimeter); } @@ -350,7 +351,7 @@ public static ElectricResistivity FromMegaohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMegaohmMeters(double value) + public static ElectricResistivity FromMegaohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmMeter); } @@ -358,7 +359,7 @@ public static ElectricResistivity FromMegaohmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMicroohmsCentimeter(double value) + public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmCentimeter); } @@ -366,7 +367,7 @@ public static ElectricResistivity FromMicroohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMicroohmMeters(double value) + public static ElectricResistivity FromMicroohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter); } @@ -374,7 +375,7 @@ public static ElectricResistivity FromMicroohmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMilliohmsCentimeter(double value) + public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmCentimeter); } @@ -382,7 +383,7 @@ public static ElectricResistivity FromMilliohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromMilliohmMeters(double value) + public static ElectricResistivity FromMilliohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter); } @@ -390,7 +391,7 @@ public static ElectricResistivity FromMilliohmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromNanoohmsCentimeter(double value) + public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmCentimeter); } @@ -398,7 +399,7 @@ public static ElectricResistivity FromNanoohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromNanoohmMeters(double value) + public static ElectricResistivity FromNanoohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter); } @@ -406,7 +407,7 @@ public static ElectricResistivity FromNanoohmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromOhmsCentimeter(double value) + public static ElectricResistivity FromOhmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.OhmCentimeter); } @@ -414,7 +415,7 @@ public static ElectricResistivity FromOhmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromOhmMeters(double value) + public static ElectricResistivity FromOhmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter); } @@ -422,7 +423,7 @@ public static ElectricResistivity FromOhmMeters(double value) /// /// Creates a from . /// - public static ElectricResistivity FromPicoohmsCentimeter(double value) + public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmCentimeter); } @@ -430,7 +431,7 @@ public static ElectricResistivity FromPicoohmsCentimeter(double value) /// /// Creates a from . /// - public static ElectricResistivity FromPicoohmMeters(double value) + public static ElectricResistivity FromPicoohmMeters(QuantityValue value) { return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmMeter); } @@ -441,7 +442,7 @@ public static ElectricResistivity FromPicoohmMeters(double value) /// Value to convert from. /// Unit to convert from. /// ElectricResistivity unit value. - public static ElectricResistivity From(double value, ElectricResistivityUnit fromUnit) + public static ElectricResistivity From(QuantityValue value, ElectricResistivityUnit fromUnit) { return new ElectricResistivity(value, fromUnit); } @@ -613,25 +614,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistivity operator *(double left, ElectricResistivity right) + public static ElectricResistivity operator *(QuantityValue left, ElectricResistivity right) { return new ElectricResistivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistivity operator *(ElectricResistivity left, double right) + public static ElectricResistivity operator *(ElectricResistivity left, QuantityValue right) { return new ElectricResistivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistivity operator /(ElectricResistivity left, double right) + public static ElectricResistivity operator /(ElectricResistivity left, QuantityValue right) { return new ElectricResistivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricResistivity left, ElectricResistivity right) + public static QuantityValue operator /(ElectricResistivity left, ElectricResistivity right) { return left.OhmMeters / right.OhmMeters; } @@ -644,7 +645,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect /// The corresponding inverse quantity, . public ElectricConductivity Inverse() { - return OhmMeters == 0.0 ? ElectricConductivity.Zero : ElectricConductivity.FromSiemensPerMeter(1 / OhmMeters); + return ElectricConductivity.FromSiemensPerMeter(QuantityValue.Inverse(OhmMeters)); } #endregion @@ -675,27 +676,20 @@ public ElectricConductivity Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricResistivity left, ElectricResistivity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricResistivity other, ElectricResistivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricResistivity left, ElectricResistivity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricResistivity otherQuantity)) @@ -705,15 +699,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricResistivity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +787,10 @@ public bool Equals(ElectricResistivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -816,7 +807,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricResistivity other, ElectricResistivity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -829,7 +820,12 @@ public bool Equals(ElectricResistivity other, ElectricResistivity tolerance) /// A hash code for the current ElectricResistivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -840,7 +836,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistivityUnit unit) + public QuantityValue As(ElectricResistivityUnit unit) { if (Unit == unit) return Value; @@ -849,7 +845,7 @@ public double As(ElectricResistivityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -864,7 +860,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); @@ -930,34 +926,34 @@ private bool TryToUnit(ElectricResistivityUnit unit, [NotNullWhen(true)] out Ele ElectricResistivity? convertedOrNull = (Unit, unit) switch { // ElectricResistivityUnit -> BaseUnit - (ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e3d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.KiloohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e3d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e6d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MegaohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e6d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e-6d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MicroohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e-6d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e-3d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.MilliohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e-3d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e-9d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.NanoohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e-9d, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value * 10, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.KiloohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value * 1000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value * 10000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MegaohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value * 1000000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 100000000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MicroohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 1000000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 100000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.MilliohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 1000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 100000000000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.NanoohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 1000000000, ElectricResistivityUnit.OhmMeter), (ElectricResistivityUnit.OhmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 100, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value / 100) * 1e-12d, ElectricResistivityUnit.OhmMeter), - (ElectricResistivityUnit.PicoohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity((_value) * 1e-12d, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 100000000000000, ElectricResistivityUnit.OhmMeter), + (ElectricResistivityUnit.PicoohmMeter, ElectricResistivityUnit.OhmMeter) => new ElectricResistivity(_value / 1000000000000, ElectricResistivityUnit.OhmMeter), // BaseUnit -> ElectricResistivityUnit - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.KiloohmCentimeter) => new ElectricResistivity((_value * 100) / 1e3d, ElectricResistivityUnit.KiloohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.KiloohmMeter) => new ElectricResistivity((_value) / 1e3d, ElectricResistivityUnit.KiloohmMeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MegaohmCentimeter) => new ElectricResistivity((_value * 100) / 1e6d, ElectricResistivityUnit.MegaohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MegaohmMeter) => new ElectricResistivity((_value) / 1e6d, ElectricResistivityUnit.MegaohmMeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MicroohmCentimeter) => new ElectricResistivity((_value * 100) / 1e-6d, ElectricResistivityUnit.MicroohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MicroohmMeter) => new ElectricResistivity((_value) / 1e-6d, ElectricResistivityUnit.MicroohmMeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MilliohmCentimeter) => new ElectricResistivity((_value * 100) / 1e-3d, ElectricResistivityUnit.MilliohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MilliohmMeter) => new ElectricResistivity((_value) / 1e-3d, ElectricResistivityUnit.MilliohmMeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.NanoohmCentimeter) => new ElectricResistivity((_value * 100) / 1e-9d, ElectricResistivityUnit.NanoohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.NanoohmMeter) => new ElectricResistivity((_value) / 1e-9d, ElectricResistivityUnit.NanoohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.KiloohmCentimeter) => new ElectricResistivity(_value / 10, ElectricResistivityUnit.KiloohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.KiloohmMeter) => new ElectricResistivity(_value / 1000, ElectricResistivityUnit.KiloohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MegaohmCentimeter) => new ElectricResistivity(_value / 10000, ElectricResistivityUnit.MegaohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MegaohmMeter) => new ElectricResistivity(_value / 1000000, ElectricResistivityUnit.MegaohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MicroohmCentimeter) => new ElectricResistivity(_value * 100000000, ElectricResistivityUnit.MicroohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MicroohmMeter) => new ElectricResistivity(_value * 1000000, ElectricResistivityUnit.MicroohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MilliohmCentimeter) => new ElectricResistivity(_value * 100000, ElectricResistivityUnit.MilliohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.MilliohmMeter) => new ElectricResistivity(_value * 1000, ElectricResistivityUnit.MilliohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.NanoohmCentimeter) => new ElectricResistivity(_value * 100000000000, ElectricResistivityUnit.NanoohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.NanoohmMeter) => new ElectricResistivity(_value * 1000000000, ElectricResistivityUnit.NanoohmMeter), (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.OhmCentimeter) => new ElectricResistivity(_value * 100, ElectricResistivityUnit.OhmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmCentimeter) => new ElectricResistivity((_value * 100) / 1e-12d, ElectricResistivityUnit.PicoohmCentimeter), - (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmMeter) => new ElectricResistivity((_value) / 1e-12d, ElectricResistivityUnit.PicoohmMeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmCentimeter) => new ElectricResistivity(_value * 100000000000000, ElectricResistivityUnit.PicoohmCentimeter), + (ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmMeter) => new ElectricResistivity(_value * 1000000000000, ElectricResistivityUnit.PicoohmMeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 7de41a6d27..49129d76ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static ElectricSurfaceChargeDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) + public ElectricSurfaceChargeDensity(QuantityValue value, ElectricSurfaceChargeDensityUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) + public ElectricSurfaceChargeDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,17 +177,17 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + public QuantityValue CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + public QuantityValue CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); /// /// Gets a value of this quantity converted into /// - public double CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + public QuantityValue CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); #endregion @@ -238,7 +239,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFor /// /// Creates a from . /// - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(double value) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(QuantityValue value) { return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); } @@ -246,7 +247,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(doubl /// /// Creates a from . /// - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(double value) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityValue value) { return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); } @@ -254,7 +255,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(double valu /// /// Creates a from . /// - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(double value) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityValue value) { return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); } @@ -265,7 +266,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(double val /// Value to convert from. /// Unit to convert from. /// ElectricSurfaceChargeDensity unit value. - public static ElectricSurfaceChargeDensity From(double value, ElectricSurfaceChargeDensityUnit fromUnit) + public static ElectricSurfaceChargeDensity From(QuantityValue value, ElectricSurfaceChargeDensityUnit fromUnit) { return new ElectricSurfaceChargeDensity(value, fromUnit); } @@ -437,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(double left, ElectricSurfaceChargeDensity right) + public static ElectricSurfaceChargeDensity operator *(QuantityValue left, ElectricSurfaceChargeDensity right) { return new ElectricSurfaceChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, double right) + public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, QuantityValue right) { return new ElectricSurfaceChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, double right) + public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, QuantityValue right) { return new ElectricSurfaceChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static QuantityValue operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.CoulombsPerSquareMeter / right.CoulombsPerSquareMeter; } @@ -488,27 +489,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ElectricSurfaceChargeDensity otherQuantity)) @@ -518,15 +512,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ElectricSurfaceChargeDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -609,10 +600,10 @@ public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -629,7 +620,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -642,7 +633,12 @@ public bool Equals(ElectricSurfaceChargeDensity other, ElectricSurfaceChargeDens /// A hash code for the current ElectricSurfaceChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -653,7 +649,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricSurfaceChargeDensityUnit unit) + public QuantityValue As(ElectricSurfaceChargeDensityUnit unit) { if (Unit == unit) return Value; @@ -662,7 +658,7 @@ public double As(ElectricSurfaceChargeDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -677,7 +673,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); @@ -743,12 +739,12 @@ private bool TryToUnit(ElectricSurfaceChargeDensityUnit unit, [NotNullWhen(true) ElectricSurfaceChargeDensity? convertedOrNull = (Unit, unit) switch { // ElectricSurfaceChargeDensityUnit -> BaseUnit - (ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter) => new ElectricSurfaceChargeDensity(_value * 1.0e4, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), - (ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter) => new ElectricSurfaceChargeDensity(_value * 1.5500031000062000e3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), + (ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter) => new ElectricSurfaceChargeDensity(_value * 10000, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), + (ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter) => new ElectricSurfaceChargeDensity(_value * new QuantityValue(7750015500031, 5000000000, false), ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), // BaseUnit -> ElectricSurfaceChargeDensityUnit - (ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter) => new ElectricSurfaceChargeDensity(_value / 1.0e4, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter), - (ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch) => new ElectricSurfaceChargeDensity(_value / 1.5500031000062000e3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch), + (ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter) => new ElectricSurfaceChargeDensity(_value / 10000, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter), + (ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch) => new ElectricSurfaceChargeDensity(_value * new QuantityValue(5000000000, 7750015500031, false), ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index bf03909e6e..d4542418aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -64,7 +62,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -133,7 +131,7 @@ static Energy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Energy(double value, EnergyUnit unit) + public Energy(QuantityValue value, EnergyUnit unit) { _value = value; _unit = unit; @@ -147,7 +145,7 @@ public Energy(double value, EnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Energy(double value, UnitSystem unitSystem) + public Energy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -198,10 +196,10 @@ public Energy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -226,202 +224,202 @@ public Energy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); + public QuantityValue BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); /// /// Gets a value of this quantity converted into /// - public double Calories => As(EnergyUnit.Calorie); + public QuantityValue Calories => As(EnergyUnit.Calorie); /// /// Gets a value of this quantity converted into /// - public double DecathermsEc => As(EnergyUnit.DecathermEc); + public QuantityValue DecathermsEc => As(EnergyUnit.DecathermEc); /// /// Gets a value of this quantity converted into /// - public double DecathermsImperial => As(EnergyUnit.DecathermImperial); + public QuantityValue DecathermsImperial => As(EnergyUnit.DecathermImperial); /// /// Gets a value of this quantity converted into /// - public double DecathermsUs => As(EnergyUnit.DecathermUs); + public QuantityValue DecathermsUs => As(EnergyUnit.DecathermUs); /// /// Gets a value of this quantity converted into /// - public double ElectronVolts => As(EnergyUnit.ElectronVolt); + public QuantityValue ElectronVolts => As(EnergyUnit.ElectronVolt); /// /// Gets a value of this quantity converted into /// - public double Ergs => As(EnergyUnit.Erg); + public QuantityValue Ergs => As(EnergyUnit.Erg); /// /// Gets a value of this quantity converted into /// - public double FootPounds => As(EnergyUnit.FootPound); + public QuantityValue FootPounds => As(EnergyUnit.FootPound); /// /// Gets a value of this quantity converted into /// - public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); + public QuantityValue GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); /// /// Gets a value of this quantity converted into /// - public double GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); + public QuantityValue GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); /// /// Gets a value of this quantity converted into /// - public double Gigajoules => As(EnergyUnit.Gigajoule); + public QuantityValue Gigajoules => As(EnergyUnit.Gigajoule); /// /// Gets a value of this quantity converted into /// - public double GigawattDays => As(EnergyUnit.GigawattDay); + public QuantityValue GigawattDays => As(EnergyUnit.GigawattDay); /// /// Gets a value of this quantity converted into /// - public double GigawattHours => As(EnergyUnit.GigawattHour); + public QuantityValue GigawattHours => As(EnergyUnit.GigawattHour); /// /// Gets a value of this quantity converted into /// - public double HorsepowerHours => As(EnergyUnit.HorsepowerHour); + public QuantityValue HorsepowerHours => As(EnergyUnit.HorsepowerHour); /// /// Gets a value of this quantity converted into /// - public double Joules => As(EnergyUnit.Joule); + public QuantityValue Joules => As(EnergyUnit.Joule); /// /// Gets a value of this quantity converted into /// - public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); + public QuantityValue KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); /// /// Gets a value of this quantity converted into /// - public double Kilocalories => As(EnergyUnit.Kilocalorie); + public QuantityValue Kilocalories => As(EnergyUnit.Kilocalorie); /// /// Gets a value of this quantity converted into /// - public double KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); + public QuantityValue KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); /// /// Gets a value of this quantity converted into /// - public double Kilojoules => As(EnergyUnit.Kilojoule); + public QuantityValue Kilojoules => As(EnergyUnit.Kilojoule); /// /// Gets a value of this quantity converted into /// - public double KilowattDays => As(EnergyUnit.KilowattDay); + public QuantityValue KilowattDays => As(EnergyUnit.KilowattDay); /// /// Gets a value of this quantity converted into /// - public double KilowattHours => As(EnergyUnit.KilowattHour); + public QuantityValue KilowattHours => As(EnergyUnit.KilowattHour); /// /// Gets a value of this quantity converted into /// - public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); + public QuantityValue MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); /// /// Gets a value of this quantity converted into /// - public double Megacalories => As(EnergyUnit.Megacalorie); + public QuantityValue Megacalories => As(EnergyUnit.Megacalorie); /// /// Gets a value of this quantity converted into /// - public double MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); + public QuantityValue MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); /// /// Gets a value of this quantity converted into /// - public double Megajoules => As(EnergyUnit.Megajoule); + public QuantityValue Megajoules => As(EnergyUnit.Megajoule); /// /// Gets a value of this quantity converted into /// - public double MegawattDays => As(EnergyUnit.MegawattDay); + public QuantityValue MegawattDays => As(EnergyUnit.MegawattDay); /// /// Gets a value of this quantity converted into /// - public double MegawattHours => As(EnergyUnit.MegawattHour); + public QuantityValue MegawattHours => As(EnergyUnit.MegawattHour); /// /// Gets a value of this quantity converted into /// - public double Microjoules => As(EnergyUnit.Microjoule); + public QuantityValue Microjoules => As(EnergyUnit.Microjoule); /// /// Gets a value of this quantity converted into /// - public double Millijoules => As(EnergyUnit.Millijoule); + public QuantityValue Millijoules => As(EnergyUnit.Millijoule); /// /// Gets a value of this quantity converted into /// - public double Nanojoules => As(EnergyUnit.Nanojoule); + public QuantityValue Nanojoules => As(EnergyUnit.Nanojoule); /// /// Gets a value of this quantity converted into /// - public double Petajoules => As(EnergyUnit.Petajoule); + public QuantityValue Petajoules => As(EnergyUnit.Petajoule); /// /// Gets a value of this quantity converted into /// - public double TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); + public QuantityValue TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); /// /// Gets a value of this quantity converted into /// - public double Terajoules => As(EnergyUnit.Terajoule); + public QuantityValue Terajoules => As(EnergyUnit.Terajoule); /// /// Gets a value of this quantity converted into /// - public double TerawattDays => As(EnergyUnit.TerawattDay); + public QuantityValue TerawattDays => As(EnergyUnit.TerawattDay); /// /// Gets a value of this quantity converted into /// - public double TerawattHours => As(EnergyUnit.TerawattHour); + public QuantityValue TerawattHours => As(EnergyUnit.TerawattHour); /// /// Gets a value of this quantity converted into /// - public double ThermsEc => As(EnergyUnit.ThermEc); + public QuantityValue ThermsEc => As(EnergyUnit.ThermEc); /// /// Gets a value of this quantity converted into /// - public double ThermsImperial => As(EnergyUnit.ThermImperial); + public QuantityValue ThermsImperial => As(EnergyUnit.ThermImperial); /// /// Gets a value of this quantity converted into /// - public double ThermsUs => As(EnergyUnit.ThermUs); + public QuantityValue ThermsUs => As(EnergyUnit.ThermUs); /// /// Gets a value of this quantity converted into /// - public double WattDays => As(EnergyUnit.WattDay); + public QuantityValue WattDays => As(EnergyUnit.WattDay); /// /// Gets a value of this quantity converted into /// - public double WattHours => As(EnergyUnit.WattHour); + public QuantityValue WattHours => As(EnergyUnit.WattHour); #endregion @@ -547,7 +545,7 @@ public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Energy FromBritishThermalUnits(double value) + public static Energy FromBritishThermalUnits(QuantityValue value) { return new Energy(value, EnergyUnit.BritishThermalUnit); } @@ -555,7 +553,7 @@ public static Energy FromBritishThermalUnits(double value) /// /// Creates a from . /// - public static Energy FromCalories(double value) + public static Energy FromCalories(QuantityValue value) { return new Energy(value, EnergyUnit.Calorie); } @@ -563,7 +561,7 @@ public static Energy FromCalories(double value) /// /// Creates a from . /// - public static Energy FromDecathermsEc(double value) + public static Energy FromDecathermsEc(QuantityValue value) { return new Energy(value, EnergyUnit.DecathermEc); } @@ -571,7 +569,7 @@ public static Energy FromDecathermsEc(double value) /// /// Creates a from . /// - public static Energy FromDecathermsImperial(double value) + public static Energy FromDecathermsImperial(QuantityValue value) { return new Energy(value, EnergyUnit.DecathermImperial); } @@ -579,7 +577,7 @@ public static Energy FromDecathermsImperial(double value) /// /// Creates a from . /// - public static Energy FromDecathermsUs(double value) + public static Energy FromDecathermsUs(QuantityValue value) { return new Energy(value, EnergyUnit.DecathermUs); } @@ -587,7 +585,7 @@ public static Energy FromDecathermsUs(double value) /// /// Creates a from . /// - public static Energy FromElectronVolts(double value) + public static Energy FromElectronVolts(QuantityValue value) { return new Energy(value, EnergyUnit.ElectronVolt); } @@ -595,7 +593,7 @@ public static Energy FromElectronVolts(double value) /// /// Creates a from . /// - public static Energy FromErgs(double value) + public static Energy FromErgs(QuantityValue value) { return new Energy(value, EnergyUnit.Erg); } @@ -603,7 +601,7 @@ public static Energy FromErgs(double value) /// /// Creates a from . /// - public static Energy FromFootPounds(double value) + public static Energy FromFootPounds(QuantityValue value) { return new Energy(value, EnergyUnit.FootPound); } @@ -611,7 +609,7 @@ public static Energy FromFootPounds(double value) /// /// Creates a from . /// - public static Energy FromGigabritishThermalUnits(double value) + public static Energy FromGigabritishThermalUnits(QuantityValue value) { return new Energy(value, EnergyUnit.GigabritishThermalUnit); } @@ -619,7 +617,7 @@ public static Energy FromGigabritishThermalUnits(double value) /// /// Creates a from . /// - public static Energy FromGigaelectronVolts(double value) + public static Energy FromGigaelectronVolts(QuantityValue value) { return new Energy(value, EnergyUnit.GigaelectronVolt); } @@ -627,7 +625,7 @@ public static Energy FromGigaelectronVolts(double value) /// /// Creates a from . /// - public static Energy FromGigajoules(double value) + public static Energy FromGigajoules(QuantityValue value) { return new Energy(value, EnergyUnit.Gigajoule); } @@ -635,7 +633,7 @@ public static Energy FromGigajoules(double value) /// /// Creates a from . /// - public static Energy FromGigawattDays(double value) + public static Energy FromGigawattDays(QuantityValue value) { return new Energy(value, EnergyUnit.GigawattDay); } @@ -643,7 +641,7 @@ public static Energy FromGigawattDays(double value) /// /// Creates a from . /// - public static Energy FromGigawattHours(double value) + public static Energy FromGigawattHours(QuantityValue value) { return new Energy(value, EnergyUnit.GigawattHour); } @@ -651,7 +649,7 @@ public static Energy FromGigawattHours(double value) /// /// Creates a from . /// - public static Energy FromHorsepowerHours(double value) + public static Energy FromHorsepowerHours(QuantityValue value) { return new Energy(value, EnergyUnit.HorsepowerHour); } @@ -659,7 +657,7 @@ public static Energy FromHorsepowerHours(double value) /// /// Creates a from . /// - public static Energy FromJoules(double value) + public static Energy FromJoules(QuantityValue value) { return new Energy(value, EnergyUnit.Joule); } @@ -667,7 +665,7 @@ public static Energy FromJoules(double value) /// /// Creates a from . /// - public static Energy FromKilobritishThermalUnits(double value) + public static Energy FromKilobritishThermalUnits(QuantityValue value) { return new Energy(value, EnergyUnit.KilobritishThermalUnit); } @@ -675,7 +673,7 @@ public static Energy FromKilobritishThermalUnits(double value) /// /// Creates a from . /// - public static Energy FromKilocalories(double value) + public static Energy FromKilocalories(QuantityValue value) { return new Energy(value, EnergyUnit.Kilocalorie); } @@ -683,7 +681,7 @@ public static Energy FromKilocalories(double value) /// /// Creates a from . /// - public static Energy FromKiloelectronVolts(double value) + public static Energy FromKiloelectronVolts(QuantityValue value) { return new Energy(value, EnergyUnit.KiloelectronVolt); } @@ -691,7 +689,7 @@ public static Energy FromKiloelectronVolts(double value) /// /// Creates a from . /// - public static Energy FromKilojoules(double value) + public static Energy FromKilojoules(QuantityValue value) { return new Energy(value, EnergyUnit.Kilojoule); } @@ -699,7 +697,7 @@ public static Energy FromKilojoules(double value) /// /// Creates a from . /// - public static Energy FromKilowattDays(double value) + public static Energy FromKilowattDays(QuantityValue value) { return new Energy(value, EnergyUnit.KilowattDay); } @@ -707,7 +705,7 @@ public static Energy FromKilowattDays(double value) /// /// Creates a from . /// - public static Energy FromKilowattHours(double value) + public static Energy FromKilowattHours(QuantityValue value) { return new Energy(value, EnergyUnit.KilowattHour); } @@ -715,7 +713,7 @@ public static Energy FromKilowattHours(double value) /// /// Creates a from . /// - public static Energy FromMegabritishThermalUnits(double value) + public static Energy FromMegabritishThermalUnits(QuantityValue value) { return new Energy(value, EnergyUnit.MegabritishThermalUnit); } @@ -723,7 +721,7 @@ public static Energy FromMegabritishThermalUnits(double value) /// /// Creates a from . /// - public static Energy FromMegacalories(double value) + public static Energy FromMegacalories(QuantityValue value) { return new Energy(value, EnergyUnit.Megacalorie); } @@ -731,7 +729,7 @@ public static Energy FromMegacalories(double value) /// /// Creates a from . /// - public static Energy FromMegaelectronVolts(double value) + public static Energy FromMegaelectronVolts(QuantityValue value) { return new Energy(value, EnergyUnit.MegaelectronVolt); } @@ -739,7 +737,7 @@ public static Energy FromMegaelectronVolts(double value) /// /// Creates a from . /// - public static Energy FromMegajoules(double value) + public static Energy FromMegajoules(QuantityValue value) { return new Energy(value, EnergyUnit.Megajoule); } @@ -747,7 +745,7 @@ public static Energy FromMegajoules(double value) /// /// Creates a from . /// - public static Energy FromMegawattDays(double value) + public static Energy FromMegawattDays(QuantityValue value) { return new Energy(value, EnergyUnit.MegawattDay); } @@ -755,7 +753,7 @@ public static Energy FromMegawattDays(double value) /// /// Creates a from . /// - public static Energy FromMegawattHours(double value) + public static Energy FromMegawattHours(QuantityValue value) { return new Energy(value, EnergyUnit.MegawattHour); } @@ -763,7 +761,7 @@ public static Energy FromMegawattHours(double value) /// /// Creates a from . /// - public static Energy FromMicrojoules(double value) + public static Energy FromMicrojoules(QuantityValue value) { return new Energy(value, EnergyUnit.Microjoule); } @@ -771,7 +769,7 @@ public static Energy FromMicrojoules(double value) /// /// Creates a from . /// - public static Energy FromMillijoules(double value) + public static Energy FromMillijoules(QuantityValue value) { return new Energy(value, EnergyUnit.Millijoule); } @@ -779,7 +777,7 @@ public static Energy FromMillijoules(double value) /// /// Creates a from . /// - public static Energy FromNanojoules(double value) + public static Energy FromNanojoules(QuantityValue value) { return new Energy(value, EnergyUnit.Nanojoule); } @@ -787,7 +785,7 @@ public static Energy FromNanojoules(double value) /// /// Creates a from . /// - public static Energy FromPetajoules(double value) + public static Energy FromPetajoules(QuantityValue value) { return new Energy(value, EnergyUnit.Petajoule); } @@ -795,7 +793,7 @@ public static Energy FromPetajoules(double value) /// /// Creates a from . /// - public static Energy FromTeraelectronVolts(double value) + public static Energy FromTeraelectronVolts(QuantityValue value) { return new Energy(value, EnergyUnit.TeraelectronVolt); } @@ -803,7 +801,7 @@ public static Energy FromTeraelectronVolts(double value) /// /// Creates a from . /// - public static Energy FromTerajoules(double value) + public static Energy FromTerajoules(QuantityValue value) { return new Energy(value, EnergyUnit.Terajoule); } @@ -811,7 +809,7 @@ public static Energy FromTerajoules(double value) /// /// Creates a from . /// - public static Energy FromTerawattDays(double value) + public static Energy FromTerawattDays(QuantityValue value) { return new Energy(value, EnergyUnit.TerawattDay); } @@ -819,7 +817,7 @@ public static Energy FromTerawattDays(double value) /// /// Creates a from . /// - public static Energy FromTerawattHours(double value) + public static Energy FromTerawattHours(QuantityValue value) { return new Energy(value, EnergyUnit.TerawattHour); } @@ -827,7 +825,7 @@ public static Energy FromTerawattHours(double value) /// /// Creates a from . /// - public static Energy FromThermsEc(double value) + public static Energy FromThermsEc(QuantityValue value) { return new Energy(value, EnergyUnit.ThermEc); } @@ -835,7 +833,7 @@ public static Energy FromThermsEc(double value) /// /// Creates a from . /// - public static Energy FromThermsImperial(double value) + public static Energy FromThermsImperial(QuantityValue value) { return new Energy(value, EnergyUnit.ThermImperial); } @@ -843,7 +841,7 @@ public static Energy FromThermsImperial(double value) /// /// Creates a from . /// - public static Energy FromThermsUs(double value) + public static Energy FromThermsUs(QuantityValue value) { return new Energy(value, EnergyUnit.ThermUs); } @@ -851,7 +849,7 @@ public static Energy FromThermsUs(double value) /// /// Creates a from . /// - public static Energy FromWattDays(double value) + public static Energy FromWattDays(QuantityValue value) { return new Energy(value, EnergyUnit.WattDay); } @@ -859,7 +857,7 @@ public static Energy FromWattDays(double value) /// /// Creates a from . /// - public static Energy FromWattHours(double value) + public static Energy FromWattHours(QuantityValue value) { return new Energy(value, EnergyUnit.WattHour); } @@ -870,7 +868,7 @@ public static Energy FromWattHours(double value) /// Value to convert from. /// Unit to convert from. /// Energy unit value. - public static Energy From(double value, EnergyUnit fromUnit) + public static Energy From(QuantityValue value, EnergyUnit fromUnit) { return new Energy(value, fromUnit); } @@ -1042,25 +1040,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ } /// Get from multiplying value and . - public static Energy operator *(double left, Energy right) + public static Energy operator *(QuantityValue left, Energy right) { return new Energy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Energy operator *(Energy left, double right) + public static Energy operator *(Energy left, QuantityValue right) { return new Energy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Energy operator /(Energy left, double right) + public static Energy operator /(Energy left, QuantityValue right) { return new Energy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Energy left, Energy right) + public static QuantityValue operator /(Energy left, Energy right) { return left.Joules / right.Joules; } @@ -1163,27 +1161,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Energy left, Energy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Energy other, Energy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Energy left, Energy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Energy otherQuantity)) @@ -1193,15 +1184,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Energy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1284,10 +1272,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1304,7 +1292,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Energy other, Energy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1317,7 +1305,12 @@ public bool Equals(Energy other, Energy tolerance) /// A hash code for the current Energy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1328,7 +1321,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EnergyUnit unit) + public QuantityValue As(EnergyUnit unit) { if (Unit == unit) return Value; @@ -1337,7 +1330,7 @@ public double As(EnergyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1352,7 +1345,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); @@ -1418,86 +1411,86 @@ private bool TryToUnit(EnergyUnit unit, [NotNullWhen(true)] out Energy? converte Energy? convertedOrNull = (Unit, unit) switch { // EnergyUnit -> BaseUnit - (EnergyUnit.BritishThermalUnit, EnergyUnit.Joule) => new Energy(_value * 1055.05585262, EnergyUnit.Joule), - (EnergyUnit.Calorie, EnergyUnit.Joule) => new Energy(_value * 4.184, EnergyUnit.Joule), - (EnergyUnit.DecathermEc, EnergyUnit.Joule) => new Energy((_value * 1.05505585262e8) * 1e1d, EnergyUnit.Joule), - (EnergyUnit.DecathermImperial, EnergyUnit.Joule) => new Energy((_value * 1.05505585257348e8) * 1e1d, EnergyUnit.Joule), - (EnergyUnit.DecathermUs, EnergyUnit.Joule) => new Energy((_value * 1.054804e8) * 1e1d, EnergyUnit.Joule), - (EnergyUnit.ElectronVolt, EnergyUnit.Joule) => new Energy(_value * 1.602176565e-19, EnergyUnit.Joule), - (EnergyUnit.Erg, EnergyUnit.Joule) => new Energy(_value * 1e-7, EnergyUnit.Joule), - (EnergyUnit.FootPound, EnergyUnit.Joule) => new Energy(_value * 1.355817948, EnergyUnit.Joule), - (EnergyUnit.GigabritishThermalUnit, EnergyUnit.Joule) => new Energy((_value * 1055.05585262) * 1e9d, EnergyUnit.Joule), - (EnergyUnit.GigaelectronVolt, EnergyUnit.Joule) => new Energy((_value * 1.602176565e-19) * 1e9d, EnergyUnit.Joule), - (EnergyUnit.Gigajoule, EnergyUnit.Joule) => new Energy((_value) * 1e9d, EnergyUnit.Joule), - (EnergyUnit.GigawattDay, EnergyUnit.Joule) => new Energy((_value * 24 * 3600d) * 1e9d, EnergyUnit.Joule), - (EnergyUnit.GigawattHour, EnergyUnit.Joule) => new Energy((_value * 3600d) * 1e9d, EnergyUnit.Joule), - (EnergyUnit.HorsepowerHour, EnergyUnit.Joule) => new Energy(_value * 2.6845195377e6, EnergyUnit.Joule), - (EnergyUnit.KilobritishThermalUnit, EnergyUnit.Joule) => new Energy((_value * 1055.05585262) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.Kilocalorie, EnergyUnit.Joule) => new Energy((_value * 4.184) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.KiloelectronVolt, EnergyUnit.Joule) => new Energy((_value * 1.602176565e-19) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.Kilojoule, EnergyUnit.Joule) => new Energy((_value) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.KilowattDay, EnergyUnit.Joule) => new Energy((_value * 24 * 3600d) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.KilowattHour, EnergyUnit.Joule) => new Energy((_value * 3600d) * 1e3d, EnergyUnit.Joule), - (EnergyUnit.MegabritishThermalUnit, EnergyUnit.Joule) => new Energy((_value * 1055.05585262) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.Megacalorie, EnergyUnit.Joule) => new Energy((_value * 4.184) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.MegaelectronVolt, EnergyUnit.Joule) => new Energy((_value * 1.602176565e-19) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.Megajoule, EnergyUnit.Joule) => new Energy((_value) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.MegawattDay, EnergyUnit.Joule) => new Energy((_value * 24 * 3600d) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.MegawattHour, EnergyUnit.Joule) => new Energy((_value * 3600d) * 1e6d, EnergyUnit.Joule), - (EnergyUnit.Microjoule, EnergyUnit.Joule) => new Energy((_value) * 1e-6d, EnergyUnit.Joule), - (EnergyUnit.Millijoule, EnergyUnit.Joule) => new Energy((_value) * 1e-3d, EnergyUnit.Joule), - (EnergyUnit.Nanojoule, EnergyUnit.Joule) => new Energy((_value) * 1e-9d, EnergyUnit.Joule), - (EnergyUnit.Petajoule, EnergyUnit.Joule) => new Energy((_value) * 1e15d, EnergyUnit.Joule), - (EnergyUnit.TeraelectronVolt, EnergyUnit.Joule) => new Energy((_value * 1.602176565e-19) * 1e12d, EnergyUnit.Joule), - (EnergyUnit.Terajoule, EnergyUnit.Joule) => new Energy((_value) * 1e12d, EnergyUnit.Joule), - (EnergyUnit.TerawattDay, EnergyUnit.Joule) => new Energy((_value * 24 * 3600d) * 1e12d, EnergyUnit.Joule), - (EnergyUnit.TerawattHour, EnergyUnit.Joule) => new Energy((_value * 3600d) * 1e12d, EnergyUnit.Joule), - (EnergyUnit.ThermEc, EnergyUnit.Joule) => new Energy(_value * 1.05505585262e8, EnergyUnit.Joule), - (EnergyUnit.ThermImperial, EnergyUnit.Joule) => new Energy(_value * 1.05505585257348e8, EnergyUnit.Joule), - (EnergyUnit.ThermUs, EnergyUnit.Joule) => new Energy(_value * 1.054804e8, EnergyUnit.Joule), - (EnergyUnit.WattDay, EnergyUnit.Joule) => new Energy(_value * 24 * 3600d, EnergyUnit.Joule), - (EnergyUnit.WattHour, EnergyUnit.Joule) => new Energy(_value * 3600d, EnergyUnit.Joule), + (EnergyUnit.BritishThermalUnit, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(52752792631, 50000000, false), EnergyUnit.Joule), + (EnergyUnit.Calorie, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(523, 125, false), EnergyUnit.Joule), + (EnergyUnit.DecathermEc, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(52752792631, 50, false), EnergyUnit.Joule), + (EnergyUnit.DecathermImperial, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(26376396314337, 25000, false), EnergyUnit.Joule), + (EnergyUnit.DecathermUs, EnergyUnit.Joule) => new Energy(_value * 1054804000, EnergyUnit.Joule), + (EnergyUnit.ElectronVolt, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(320435313, 200000000, false) / BigInteger.Pow(10, 19), EnergyUnit.Joule), + (EnergyUnit.Erg, EnergyUnit.Joule) => new Energy(_value / 10000000, EnergyUnit.Joule), + (EnergyUnit.FootPound, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(338954487, 250000000, false), EnergyUnit.Joule), + (EnergyUnit.GigabritishThermalUnit, EnergyUnit.Joule) => new Energy(_value * 1055055852620, EnergyUnit.Joule), + (EnergyUnit.GigaelectronVolt, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(320435313, 2000000000000000000, false), EnergyUnit.Joule), + (EnergyUnit.Gigajoule, EnergyUnit.Joule) => new Energy(_value * 1000000000, EnergyUnit.Joule), + (EnergyUnit.GigawattDay, EnergyUnit.Joule) => new Energy(_value * 86400000000000, EnergyUnit.Joule), + (EnergyUnit.GigawattHour, EnergyUnit.Joule) => new Energy(_value * 3600000000000, EnergyUnit.Joule), + (EnergyUnit.HorsepowerHour, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(26845195377, 10000, false), EnergyUnit.Joule), + (EnergyUnit.KilobritishThermalUnit, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(52752792631, 50000, false), EnergyUnit.Joule), + (EnergyUnit.Kilocalorie, EnergyUnit.Joule) => new Energy(_value * 4184, EnergyUnit.Joule), + (EnergyUnit.KiloelectronVolt, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(320435313, 200000, false) / BigInteger.Pow(10, 19), EnergyUnit.Joule), + (EnergyUnit.Kilojoule, EnergyUnit.Joule) => new Energy(_value * 1000, EnergyUnit.Joule), + (EnergyUnit.KilowattDay, EnergyUnit.Joule) => new Energy(_value * 86400000, EnergyUnit.Joule), + (EnergyUnit.KilowattHour, EnergyUnit.Joule) => new Energy(_value * 3600000, EnergyUnit.Joule), + (EnergyUnit.MegabritishThermalUnit, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(52752792631, 50, false), EnergyUnit.Joule), + (EnergyUnit.Megacalorie, EnergyUnit.Joule) => new Energy(_value * 4184000, EnergyUnit.Joule), + (EnergyUnit.MegaelectronVolt, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(320435313, 200, false) / BigInteger.Pow(10, 19), EnergyUnit.Joule), + (EnergyUnit.Megajoule, EnergyUnit.Joule) => new Energy(_value * 1000000, EnergyUnit.Joule), + (EnergyUnit.MegawattDay, EnergyUnit.Joule) => new Energy(_value * 86400000000, EnergyUnit.Joule), + (EnergyUnit.MegawattHour, EnergyUnit.Joule) => new Energy(_value * 3600000000, EnergyUnit.Joule), + (EnergyUnit.Microjoule, EnergyUnit.Joule) => new Energy(_value / 1000000, EnergyUnit.Joule), + (EnergyUnit.Millijoule, EnergyUnit.Joule) => new Energy(_value / 1000, EnergyUnit.Joule), + (EnergyUnit.Nanojoule, EnergyUnit.Joule) => new Energy(_value / 1000000000, EnergyUnit.Joule), + (EnergyUnit.Petajoule, EnergyUnit.Joule) => new Energy(_value * 1000000000000000, EnergyUnit.Joule), + (EnergyUnit.TeraelectronVolt, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(320435313, 2000000000000000, false), EnergyUnit.Joule), + (EnergyUnit.Terajoule, EnergyUnit.Joule) => new Energy(_value * 1000000000000, EnergyUnit.Joule), + (EnergyUnit.TerawattDay, EnergyUnit.Joule) => new Energy(_value * 86400000000000000, EnergyUnit.Joule), + (EnergyUnit.TerawattHour, EnergyUnit.Joule) => new Energy(_value * 3600000000000000, EnergyUnit.Joule), + (EnergyUnit.ThermEc, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(52752792631, 500, false), EnergyUnit.Joule), + (EnergyUnit.ThermImperial, EnergyUnit.Joule) => new Energy(_value * new QuantityValue(26376396314337, 250000, false), EnergyUnit.Joule), + (EnergyUnit.ThermUs, EnergyUnit.Joule) => new Energy(_value * 105480400, EnergyUnit.Joule), + (EnergyUnit.WattDay, EnergyUnit.Joule) => new Energy(_value * 86400, EnergyUnit.Joule), + (EnergyUnit.WattHour, EnergyUnit.Joule) => new Energy(_value * 3600, EnergyUnit.Joule), // BaseUnit -> EnergyUnit - (EnergyUnit.Joule, EnergyUnit.BritishThermalUnit) => new Energy(_value / 1055.05585262, EnergyUnit.BritishThermalUnit), - (EnergyUnit.Joule, EnergyUnit.Calorie) => new Energy(_value / 4.184, EnergyUnit.Calorie), - (EnergyUnit.Joule, EnergyUnit.DecathermEc) => new Energy((_value / 1.05505585262e8) / 1e1d, EnergyUnit.DecathermEc), - (EnergyUnit.Joule, EnergyUnit.DecathermImperial) => new Energy((_value / 1.05505585257348e8) / 1e1d, EnergyUnit.DecathermImperial), - (EnergyUnit.Joule, EnergyUnit.DecathermUs) => new Energy((_value / 1.054804e8) / 1e1d, EnergyUnit.DecathermUs), - (EnergyUnit.Joule, EnergyUnit.ElectronVolt) => new Energy(_value / 1.602176565e-19, EnergyUnit.ElectronVolt), - (EnergyUnit.Joule, EnergyUnit.Erg) => new Energy(_value / 1e-7, EnergyUnit.Erg), - (EnergyUnit.Joule, EnergyUnit.FootPound) => new Energy(_value / 1.355817948, EnergyUnit.FootPound), - (EnergyUnit.Joule, EnergyUnit.GigabritishThermalUnit) => new Energy((_value / 1055.05585262) / 1e9d, EnergyUnit.GigabritishThermalUnit), - (EnergyUnit.Joule, EnergyUnit.GigaelectronVolt) => new Energy((_value / 1.602176565e-19) / 1e9d, EnergyUnit.GigaelectronVolt), - (EnergyUnit.Joule, EnergyUnit.Gigajoule) => new Energy((_value) / 1e9d, EnergyUnit.Gigajoule), - (EnergyUnit.Joule, EnergyUnit.GigawattDay) => new Energy((_value / (24 * 3600d)) / 1e9d, EnergyUnit.GigawattDay), - (EnergyUnit.Joule, EnergyUnit.GigawattHour) => new Energy((_value / 3600d) / 1e9d, EnergyUnit.GigawattHour), - (EnergyUnit.Joule, EnergyUnit.HorsepowerHour) => new Energy(_value / 2.6845195377e6, EnergyUnit.HorsepowerHour), - (EnergyUnit.Joule, EnergyUnit.KilobritishThermalUnit) => new Energy((_value / 1055.05585262) / 1e3d, EnergyUnit.KilobritishThermalUnit), - (EnergyUnit.Joule, EnergyUnit.Kilocalorie) => new Energy((_value / 4.184) / 1e3d, EnergyUnit.Kilocalorie), - (EnergyUnit.Joule, EnergyUnit.KiloelectronVolt) => new Energy((_value / 1.602176565e-19) / 1e3d, EnergyUnit.KiloelectronVolt), - (EnergyUnit.Joule, EnergyUnit.Kilojoule) => new Energy((_value) / 1e3d, EnergyUnit.Kilojoule), - (EnergyUnit.Joule, EnergyUnit.KilowattDay) => new Energy((_value / (24 * 3600d)) / 1e3d, EnergyUnit.KilowattDay), - (EnergyUnit.Joule, EnergyUnit.KilowattHour) => new Energy((_value / 3600d) / 1e3d, EnergyUnit.KilowattHour), - (EnergyUnit.Joule, EnergyUnit.MegabritishThermalUnit) => new Energy((_value / 1055.05585262) / 1e6d, EnergyUnit.MegabritishThermalUnit), - (EnergyUnit.Joule, EnergyUnit.Megacalorie) => new Energy((_value / 4.184) / 1e6d, EnergyUnit.Megacalorie), - (EnergyUnit.Joule, EnergyUnit.MegaelectronVolt) => new Energy((_value / 1.602176565e-19) / 1e6d, EnergyUnit.MegaelectronVolt), - (EnergyUnit.Joule, EnergyUnit.Megajoule) => new Energy((_value) / 1e6d, EnergyUnit.Megajoule), - (EnergyUnit.Joule, EnergyUnit.MegawattDay) => new Energy((_value / (24 * 3600d)) / 1e6d, EnergyUnit.MegawattDay), - (EnergyUnit.Joule, EnergyUnit.MegawattHour) => new Energy((_value / 3600d) / 1e6d, EnergyUnit.MegawattHour), - (EnergyUnit.Joule, EnergyUnit.Microjoule) => new Energy((_value) / 1e-6d, EnergyUnit.Microjoule), - (EnergyUnit.Joule, EnergyUnit.Millijoule) => new Energy((_value) / 1e-3d, EnergyUnit.Millijoule), - (EnergyUnit.Joule, EnergyUnit.Nanojoule) => new Energy((_value) / 1e-9d, EnergyUnit.Nanojoule), - (EnergyUnit.Joule, EnergyUnit.Petajoule) => new Energy((_value) / 1e15d, EnergyUnit.Petajoule), - (EnergyUnit.Joule, EnergyUnit.TeraelectronVolt) => new Energy((_value / 1.602176565e-19) / 1e12d, EnergyUnit.TeraelectronVolt), - (EnergyUnit.Joule, EnergyUnit.Terajoule) => new Energy((_value) / 1e12d, EnergyUnit.Terajoule), - (EnergyUnit.Joule, EnergyUnit.TerawattDay) => new Energy((_value / (24 * 3600d)) / 1e12d, EnergyUnit.TerawattDay), - (EnergyUnit.Joule, EnergyUnit.TerawattHour) => new Energy((_value / 3600d) / 1e12d, EnergyUnit.TerawattHour), - (EnergyUnit.Joule, EnergyUnit.ThermEc) => new Energy(_value / 1.05505585262e8, EnergyUnit.ThermEc), - (EnergyUnit.Joule, EnergyUnit.ThermImperial) => new Energy(_value / 1.05505585257348e8, EnergyUnit.ThermImperial), - (EnergyUnit.Joule, EnergyUnit.ThermUs) => new Energy(_value / 1.054804e8, EnergyUnit.ThermUs), - (EnergyUnit.Joule, EnergyUnit.WattDay) => new Energy(_value / (24 * 3600d), EnergyUnit.WattDay), - (EnergyUnit.Joule, EnergyUnit.WattHour) => new Energy(_value / 3600d, EnergyUnit.WattHour), + (EnergyUnit.Joule, EnergyUnit.BritishThermalUnit) => new Energy(_value * new QuantityValue(50000000, 52752792631, false), EnergyUnit.BritishThermalUnit), + (EnergyUnit.Joule, EnergyUnit.Calorie) => new Energy(_value * new QuantityValue(125, 523, false), EnergyUnit.Calorie), + (EnergyUnit.Joule, EnergyUnit.DecathermEc) => new Energy(_value * new QuantityValue(50, 52752792631, false), EnergyUnit.DecathermEc), + (EnergyUnit.Joule, EnergyUnit.DecathermImperial) => new Energy(_value * new QuantityValue(25000, 26376396314337, false), EnergyUnit.DecathermImperial), + (EnergyUnit.Joule, EnergyUnit.DecathermUs) => new Energy(_value / 1054804000, EnergyUnit.DecathermUs), + (EnergyUnit.Joule, EnergyUnit.ElectronVolt) => new Energy(_value * new QuantityValue(200000000, 320435313, false) * BigInteger.Pow(10, 19), EnergyUnit.ElectronVolt), + (EnergyUnit.Joule, EnergyUnit.Erg) => new Energy(_value * 10000000, EnergyUnit.Erg), + (EnergyUnit.Joule, EnergyUnit.FootPound) => new Energy(_value * new QuantityValue(250000000, 338954487, false), EnergyUnit.FootPound), + (EnergyUnit.Joule, EnergyUnit.GigabritishThermalUnit) => new Energy(_value / 1055055852620, EnergyUnit.GigabritishThermalUnit), + (EnergyUnit.Joule, EnergyUnit.GigaelectronVolt) => new Energy(_value * new QuantityValue(2000000000000000000, 320435313, false), EnergyUnit.GigaelectronVolt), + (EnergyUnit.Joule, EnergyUnit.Gigajoule) => new Energy(_value / 1000000000, EnergyUnit.Gigajoule), + (EnergyUnit.Joule, EnergyUnit.GigawattDay) => new Energy(_value / 86400000000000, EnergyUnit.GigawattDay), + (EnergyUnit.Joule, EnergyUnit.GigawattHour) => new Energy(_value / 3600000000000, EnergyUnit.GigawattHour), + (EnergyUnit.Joule, EnergyUnit.HorsepowerHour) => new Energy(_value * new QuantityValue(10000, 26845195377, false), EnergyUnit.HorsepowerHour), + (EnergyUnit.Joule, EnergyUnit.KilobritishThermalUnit) => new Energy(_value * new QuantityValue(50000, 52752792631, false), EnergyUnit.KilobritishThermalUnit), + (EnergyUnit.Joule, EnergyUnit.Kilocalorie) => new Energy(_value / 4184, EnergyUnit.Kilocalorie), + (EnergyUnit.Joule, EnergyUnit.KiloelectronVolt) => new Energy(_value * new QuantityValue(200000, 320435313, false) * BigInteger.Pow(10, 19), EnergyUnit.KiloelectronVolt), + (EnergyUnit.Joule, EnergyUnit.Kilojoule) => new Energy(_value / 1000, EnergyUnit.Kilojoule), + (EnergyUnit.Joule, EnergyUnit.KilowattDay) => new Energy(_value / 86400000, EnergyUnit.KilowattDay), + (EnergyUnit.Joule, EnergyUnit.KilowattHour) => new Energy(_value / 3600000, EnergyUnit.KilowattHour), + (EnergyUnit.Joule, EnergyUnit.MegabritishThermalUnit) => new Energy(_value * new QuantityValue(50, 52752792631, false), EnergyUnit.MegabritishThermalUnit), + (EnergyUnit.Joule, EnergyUnit.Megacalorie) => new Energy(_value / 4184000, EnergyUnit.Megacalorie), + (EnergyUnit.Joule, EnergyUnit.MegaelectronVolt) => new Energy(_value * new QuantityValue(200, 320435313, false) * BigInteger.Pow(10, 19), EnergyUnit.MegaelectronVolt), + (EnergyUnit.Joule, EnergyUnit.Megajoule) => new Energy(_value / 1000000, EnergyUnit.Megajoule), + (EnergyUnit.Joule, EnergyUnit.MegawattDay) => new Energy(_value / 86400000000, EnergyUnit.MegawattDay), + (EnergyUnit.Joule, EnergyUnit.MegawattHour) => new Energy(_value / 3600000000, EnergyUnit.MegawattHour), + (EnergyUnit.Joule, EnergyUnit.Microjoule) => new Energy(_value * 1000000, EnergyUnit.Microjoule), + (EnergyUnit.Joule, EnergyUnit.Millijoule) => new Energy(_value * 1000, EnergyUnit.Millijoule), + (EnergyUnit.Joule, EnergyUnit.Nanojoule) => new Energy(_value * 1000000000, EnergyUnit.Nanojoule), + (EnergyUnit.Joule, EnergyUnit.Petajoule) => new Energy(_value / 1000000000000000, EnergyUnit.Petajoule), + (EnergyUnit.Joule, EnergyUnit.TeraelectronVolt) => new Energy(_value * new QuantityValue(2000000000000000, 320435313, false), EnergyUnit.TeraelectronVolt), + (EnergyUnit.Joule, EnergyUnit.Terajoule) => new Energy(_value / 1000000000000, EnergyUnit.Terajoule), + (EnergyUnit.Joule, EnergyUnit.TerawattDay) => new Energy(_value / 86400000000000000, EnergyUnit.TerawattDay), + (EnergyUnit.Joule, EnergyUnit.TerawattHour) => new Energy(_value / 3600000000000000, EnergyUnit.TerawattHour), + (EnergyUnit.Joule, EnergyUnit.ThermEc) => new Energy(_value * new QuantityValue(500, 52752792631, false), EnergyUnit.ThermEc), + (EnergyUnit.Joule, EnergyUnit.ThermImperial) => new Energy(_value * new QuantityValue(250000, 26376396314337, false), EnergyUnit.ThermImperial), + (EnergyUnit.Joule, EnergyUnit.ThermUs) => new Energy(_value / 105480400, EnergyUnit.ThermUs), + (EnergyUnit.Joule, EnergyUnit.WattDay) => new Energy(_value / 86400, EnergyUnit.WattDay), + (EnergyUnit.Joule, EnergyUnit.WattHour) => new Energy(_value / 3600, EnergyUnit.WattHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs index d11aeb52bb..fac1e72521 100644 --- a/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/EnergyDensity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -95,7 +93,7 @@ static EnergyDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public EnergyDensity(double value, EnergyDensityUnit unit) + public EnergyDensity(QuantityValue value, EnergyDensityUnit unit) { _value = value; _unit = unit; @@ -109,7 +107,7 @@ public EnergyDensity(double value, EnergyDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public EnergyDensity(double value, UnitSystem unitSystem) + public EnergyDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -160,10 +158,10 @@ public EnergyDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,62 +186,62 @@ public EnergyDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GigajoulesPerCubicMeter => As(EnergyDensityUnit.GigajoulePerCubicMeter); + public QuantityValue GigajoulesPerCubicMeter => As(EnergyDensityUnit.GigajoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double GigawattHoursPerCubicMeter => As(EnergyDensityUnit.GigawattHourPerCubicMeter); + public QuantityValue GigawattHoursPerCubicMeter => As(EnergyDensityUnit.GigawattHourPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double JoulesPerCubicMeter => As(EnergyDensityUnit.JoulePerCubicMeter); + public QuantityValue JoulesPerCubicMeter => As(EnergyDensityUnit.JoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerCubicMeter => As(EnergyDensityUnit.KilojoulePerCubicMeter); + public QuantityValue KilojoulesPerCubicMeter => As(EnergyDensityUnit.KilojoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilowattHoursPerCubicMeter => As(EnergyDensityUnit.KilowattHourPerCubicMeter); + public QuantityValue KilowattHoursPerCubicMeter => As(EnergyDensityUnit.KilowattHourPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerCubicMeter => As(EnergyDensityUnit.MegajoulePerCubicMeter); + public QuantityValue MegajoulesPerCubicMeter => As(EnergyDensityUnit.MegajoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MegawattHoursPerCubicMeter => As(EnergyDensityUnit.MegawattHourPerCubicMeter); + public QuantityValue MegawattHoursPerCubicMeter => As(EnergyDensityUnit.MegawattHourPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double PetajoulesPerCubicMeter => As(EnergyDensityUnit.PetajoulePerCubicMeter); + public QuantityValue PetajoulesPerCubicMeter => As(EnergyDensityUnit.PetajoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double PetawattHoursPerCubicMeter => As(EnergyDensityUnit.PetawattHourPerCubicMeter); + public QuantityValue PetawattHoursPerCubicMeter => As(EnergyDensityUnit.PetawattHourPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TerajoulesPerCubicMeter => As(EnergyDensityUnit.TerajoulePerCubicMeter); + public QuantityValue TerajoulesPerCubicMeter => As(EnergyDensityUnit.TerajoulePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TerawattHoursPerCubicMeter => As(EnergyDensityUnit.TerawattHourPerCubicMeter); + public QuantityValue TerawattHoursPerCubicMeter => As(EnergyDensityUnit.TerawattHourPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double WattHoursPerCubicMeter => As(EnergyDensityUnit.WattHourPerCubicMeter); + public QuantityValue WattHoursPerCubicMeter => As(EnergyDensityUnit.WattHourPerCubicMeter); #endregion @@ -313,7 +311,7 @@ public static string GetAbbreviation(EnergyDensityUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static EnergyDensity FromGigajoulesPerCubicMeter(double value) + public static EnergyDensity FromGigajoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.GigajoulePerCubicMeter); } @@ -321,7 +319,7 @@ public static EnergyDensity FromGigajoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromGigawattHoursPerCubicMeter(double value) + public static EnergyDensity FromGigawattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.GigawattHourPerCubicMeter); } @@ -329,7 +327,7 @@ public static EnergyDensity FromGigawattHoursPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromJoulesPerCubicMeter(double value) + public static EnergyDensity FromJoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.JoulePerCubicMeter); } @@ -337,7 +335,7 @@ public static EnergyDensity FromJoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromKilojoulesPerCubicMeter(double value) + public static EnergyDensity FromKilojoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.KilojoulePerCubicMeter); } @@ -345,7 +343,7 @@ public static EnergyDensity FromKilojoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromKilowattHoursPerCubicMeter(double value) + public static EnergyDensity FromKilowattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.KilowattHourPerCubicMeter); } @@ -353,7 +351,7 @@ public static EnergyDensity FromKilowattHoursPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromMegajoulesPerCubicMeter(double value) + public static EnergyDensity FromMegajoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.MegajoulePerCubicMeter); } @@ -361,7 +359,7 @@ public static EnergyDensity FromMegajoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromMegawattHoursPerCubicMeter(double value) + public static EnergyDensity FromMegawattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.MegawattHourPerCubicMeter); } @@ -369,7 +367,7 @@ public static EnergyDensity FromMegawattHoursPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromPetajoulesPerCubicMeter(double value) + public static EnergyDensity FromPetajoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.PetajoulePerCubicMeter); } @@ -377,7 +375,7 @@ public static EnergyDensity FromPetajoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromPetawattHoursPerCubicMeter(double value) + public static EnergyDensity FromPetawattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.PetawattHourPerCubicMeter); } @@ -385,7 +383,7 @@ public static EnergyDensity FromPetawattHoursPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromTerajoulesPerCubicMeter(double value) + public static EnergyDensity FromTerajoulesPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.TerajoulePerCubicMeter); } @@ -393,7 +391,7 @@ public static EnergyDensity FromTerajoulesPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromTerawattHoursPerCubicMeter(double value) + public static EnergyDensity FromTerawattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.TerawattHourPerCubicMeter); } @@ -401,7 +399,7 @@ public static EnergyDensity FromTerawattHoursPerCubicMeter(double value) /// /// Creates a from . /// - public static EnergyDensity FromWattHoursPerCubicMeter(double value) + public static EnergyDensity FromWattHoursPerCubicMeter(QuantityValue value) { return new EnergyDensity(value, EnergyDensityUnit.WattHourPerCubicMeter); } @@ -412,7 +410,7 @@ public static EnergyDensity FromWattHoursPerCubicMeter(double value) /// Value to convert from. /// Unit to convert from. /// EnergyDensity unit value. - public static EnergyDensity From(double value, EnergyDensityUnit fromUnit) + public static EnergyDensity From(QuantityValue value, EnergyDensityUnit fromUnit) { return new EnergyDensity(value, fromUnit); } @@ -584,25 +582,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ } /// Get from multiplying value and . - public static EnergyDensity operator *(double left, EnergyDensity right) + public static EnergyDensity operator *(QuantityValue left, EnergyDensity right) { return new EnergyDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static EnergyDensity operator *(EnergyDensity left, double right) + public static EnergyDensity operator *(EnergyDensity left, QuantityValue right) { return new EnergyDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static EnergyDensity operator /(EnergyDensity left, double right) + public static EnergyDensity operator /(EnergyDensity left, QuantityValue right) { return new EnergyDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(EnergyDensity left, EnergyDensity right) + public static QuantityValue operator /(EnergyDensity left, EnergyDensity right) { return left.JoulesPerCubicMeter / right.JoulesPerCubicMeter; } @@ -645,27 +643,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(EnergyDensity left, EnergyDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(EnergyDensity other, EnergyDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(EnergyDensity left, EnergyDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is EnergyDensity otherQuantity)) @@ -675,15 +666,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(EnergyDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -766,10 +754,10 @@ public bool Equals(EnergyDensity other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -786,7 +774,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(EnergyDensity other, EnergyDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -799,7 +787,12 @@ public bool Equals(EnergyDensity other, EnergyDensity tolerance) /// A hash code for the current EnergyDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -810,7 +803,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EnergyDensityUnit unit) + public QuantityValue As(EnergyDensityUnit unit) { if (Unit == unit) return Value; @@ -819,7 +812,7 @@ public double As(EnergyDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -834,7 +827,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is EnergyDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyDensityUnit)} is supported.", nameof(unit)); @@ -900,30 +893,30 @@ private bool TryToUnit(EnergyDensityUnit unit, [NotNullWhen(true)] out EnergyDen EnergyDensity? convertedOrNull = (Unit, unit) switch { // EnergyDensityUnit -> BaseUnit - (EnergyDensityUnit.GigajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value) * 1e9d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.GigawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value * 3.6e+3) * 1e9d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.KilojoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value) * 1e3d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.KilowattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value * 3.6e+3) * 1e3d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.MegajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value) * 1e6d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.MegawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value * 3.6e+3) * 1e6d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.PetajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value) * 1e15d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.PetawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value * 3.6e+3) * 1e15d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.TerajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value) * 1e12d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.TerawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity((_value * 3.6e+3) * 1e12d, EnergyDensityUnit.JoulePerCubicMeter), - (EnergyDensityUnit.WattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3.6e+3, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.GigajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 1000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.GigawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.KilojoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 1000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.KilowattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.MegajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 1000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.MegawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.PetajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 1000000000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.PetawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600000000000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.TerajoulePerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 1000000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.TerawattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600000000000000, EnergyDensityUnit.JoulePerCubicMeter), + (EnergyDensityUnit.WattHourPerCubicMeter, EnergyDensityUnit.JoulePerCubicMeter) => new EnergyDensity(_value * 3600, EnergyDensityUnit.JoulePerCubicMeter), // BaseUnit -> EnergyDensityUnit - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.GigajoulePerCubicMeter) => new EnergyDensity((_value) / 1e9d, EnergyDensityUnit.GigajoulePerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.GigawattHourPerCubicMeter) => new EnergyDensity((_value / 3.6e+3) / 1e9d, EnergyDensityUnit.GigawattHourPerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.KilojoulePerCubicMeter) => new EnergyDensity((_value) / 1e3d, EnergyDensityUnit.KilojoulePerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.KilowattHourPerCubicMeter) => new EnergyDensity((_value / 3.6e+3) / 1e3d, EnergyDensityUnit.KilowattHourPerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.MegajoulePerCubicMeter) => new EnergyDensity((_value) / 1e6d, EnergyDensityUnit.MegajoulePerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.MegawattHourPerCubicMeter) => new EnergyDensity((_value / 3.6e+3) / 1e6d, EnergyDensityUnit.MegawattHourPerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.PetajoulePerCubicMeter) => new EnergyDensity((_value) / 1e15d, EnergyDensityUnit.PetajoulePerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.PetawattHourPerCubicMeter) => new EnergyDensity((_value / 3.6e+3) / 1e15d, EnergyDensityUnit.PetawattHourPerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.TerajoulePerCubicMeter) => new EnergyDensity((_value) / 1e12d, EnergyDensityUnit.TerajoulePerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.TerawattHourPerCubicMeter) => new EnergyDensity((_value / 3.6e+3) / 1e12d, EnergyDensityUnit.TerawattHourPerCubicMeter), - (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.WattHourPerCubicMeter) => new EnergyDensity(_value / 3.6e+3, EnergyDensityUnit.WattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.GigajoulePerCubicMeter) => new EnergyDensity(_value / 1000000000, EnergyDensityUnit.GigajoulePerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.GigawattHourPerCubicMeter) => new EnergyDensity(_value / 3600000000000, EnergyDensityUnit.GigawattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.KilojoulePerCubicMeter) => new EnergyDensity(_value / 1000, EnergyDensityUnit.KilojoulePerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.KilowattHourPerCubicMeter) => new EnergyDensity(_value / 3600000, EnergyDensityUnit.KilowattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.MegajoulePerCubicMeter) => new EnergyDensity(_value / 1000000, EnergyDensityUnit.MegajoulePerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.MegawattHourPerCubicMeter) => new EnergyDensity(_value / 3600000000, EnergyDensityUnit.MegawattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.PetajoulePerCubicMeter) => new EnergyDensity(_value / 1000000000000000, EnergyDensityUnit.PetajoulePerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.PetawattHourPerCubicMeter) => new EnergyDensity(_value / 3600000000000000000, EnergyDensityUnit.PetawattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.TerajoulePerCubicMeter) => new EnergyDensity(_value / 1000000000000, EnergyDensityUnit.TerajoulePerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.TerawattHourPerCubicMeter) => new EnergyDensity(_value / 3600000000000000, EnergyDensityUnit.TerawattHourPerCubicMeter), + (EnergyDensityUnit.JoulePerCubicMeter, EnergyDensityUnit.WattHourPerCubicMeter) => new EnergyDensity(_value / 3600, EnergyDensityUnit.WattHourPerCubicMeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 44ae5ecd7a..83b13990e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -56,7 +54,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -92,7 +90,7 @@ static Entropy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Entropy(double value, EntropyUnit unit) + public Entropy(QuantityValue value, EntropyUnit unit) { _value = value; _unit = unit; @@ -106,7 +104,7 @@ public Entropy(double value, EntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Entropy(double value, UnitSystem unitSystem) + public Entropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -157,10 +155,10 @@ public Entropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -185,37 +183,37 @@ public Entropy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); + public QuantityValue CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); /// /// Gets a value of this quantity converted into /// - public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); + public QuantityValue JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); + public QuantityValue JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); + public QuantityValue KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); + public QuantityValue KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); + public QuantityValue KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); + public QuantityValue MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); #endregion @@ -275,7 +273,7 @@ public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider /// /// Creates a from . /// - public static Entropy FromCaloriesPerKelvin(double value) + public static Entropy FromCaloriesPerKelvin(QuantityValue value) { return new Entropy(value, EntropyUnit.CaloriePerKelvin); } @@ -283,7 +281,7 @@ public static Entropy FromCaloriesPerKelvin(double value) /// /// Creates a from . /// - public static Entropy FromJoulesPerDegreeCelsius(double value) + public static Entropy FromJoulesPerDegreeCelsius(QuantityValue value) { return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius); } @@ -291,7 +289,7 @@ public static Entropy FromJoulesPerDegreeCelsius(double value) /// /// Creates a from . /// - public static Entropy FromJoulesPerKelvin(double value) + public static Entropy FromJoulesPerKelvin(QuantityValue value) { return new Entropy(value, EntropyUnit.JoulePerKelvin); } @@ -299,7 +297,7 @@ public static Entropy FromJoulesPerKelvin(double value) /// /// Creates a from . /// - public static Entropy FromKilocaloriesPerKelvin(double value) + public static Entropy FromKilocaloriesPerKelvin(QuantityValue value) { return new Entropy(value, EntropyUnit.KilocaloriePerKelvin); } @@ -307,7 +305,7 @@ public static Entropy FromKilocaloriesPerKelvin(double value) /// /// Creates a from . /// - public static Entropy FromKilojoulesPerDegreeCelsius(double value) + public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue value) { return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius); } @@ -315,7 +313,7 @@ public static Entropy FromKilojoulesPerDegreeCelsius(double value) /// /// Creates a from . /// - public static Entropy FromKilojoulesPerKelvin(double value) + public static Entropy FromKilojoulesPerKelvin(QuantityValue value) { return new Entropy(value, EntropyUnit.KilojoulePerKelvin); } @@ -323,7 +321,7 @@ public static Entropy FromKilojoulesPerKelvin(double value) /// /// Creates a from . /// - public static Entropy FromMegajoulesPerKelvin(double value) + public static Entropy FromMegajoulesPerKelvin(QuantityValue value) { return new Entropy(value, EntropyUnit.MegajoulePerKelvin); } @@ -334,7 +332,7 @@ public static Entropy FromMegajoulesPerKelvin(double value) /// Value to convert from. /// Unit to convert from. /// Entropy unit value. - public static Entropy From(double value, EntropyUnit fromUnit) + public static Entropy From(QuantityValue value, EntropyUnit fromUnit) { return new Entropy(value, fromUnit); } @@ -506,25 +504,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro } /// Get from multiplying value and . - public static Entropy operator *(double left, Entropy right) + public static Entropy operator *(QuantityValue left, Entropy right) { return new Entropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Entropy operator *(Entropy left, double right) + public static Entropy operator *(Entropy left, QuantityValue right) { return new Entropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Entropy operator /(Entropy left, double right) + public static Entropy operator /(Entropy left, QuantityValue right) { return new Entropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Entropy left, Entropy right) + public static QuantityValue operator /(Entropy left, Entropy right) { return left.JoulesPerKelvin / right.JoulesPerKelvin; } @@ -579,27 +577,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Entropy left, Entropy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Entropy other, Entropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Entropy left, Entropy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Entropy otherQuantity)) @@ -609,15 +600,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Entropy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +688,10 @@ public bool Equals(Entropy other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -720,7 +708,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Entropy other, Entropy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -733,7 +721,12 @@ public bool Equals(Entropy other, Entropy tolerance) /// A hash code for the current Entropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -744,7 +737,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EntropyUnit unit) + public QuantityValue As(EntropyUnit unit) { if (Unit == unit) return Value; @@ -753,7 +746,7 @@ public double As(EntropyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -768,7 +761,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); @@ -834,20 +827,20 @@ private bool TryToUnit(EntropyUnit unit, [NotNullWhen(true)] out Entropy? conver Entropy? convertedOrNull = (Unit, unit) switch { // EntropyUnit -> BaseUnit - (EntropyUnit.CaloriePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy(_value * 4.184, EntropyUnit.JoulePerKelvin), + (EntropyUnit.CaloriePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy(_value * new QuantityValue(523, 125, false), EntropyUnit.JoulePerKelvin), (EntropyUnit.JoulePerDegreeCelsius, EntropyUnit.JoulePerKelvin) => new Entropy(_value, EntropyUnit.JoulePerKelvin), - (EntropyUnit.KilocaloriePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy((_value * 4.184) * 1e3d, EntropyUnit.JoulePerKelvin), - (EntropyUnit.KilojoulePerDegreeCelsius, EntropyUnit.JoulePerKelvin) => new Entropy((_value) * 1e3d, EntropyUnit.JoulePerKelvin), - (EntropyUnit.KilojoulePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy((_value) * 1e3d, EntropyUnit.JoulePerKelvin), - (EntropyUnit.MegajoulePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy((_value) * 1e6d, EntropyUnit.JoulePerKelvin), + (EntropyUnit.KilocaloriePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy(_value * 4184, EntropyUnit.JoulePerKelvin), + (EntropyUnit.KilojoulePerDegreeCelsius, EntropyUnit.JoulePerKelvin) => new Entropy(_value * 1000, EntropyUnit.JoulePerKelvin), + (EntropyUnit.KilojoulePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy(_value * 1000, EntropyUnit.JoulePerKelvin), + (EntropyUnit.MegajoulePerKelvin, EntropyUnit.JoulePerKelvin) => new Entropy(_value * 1000000, EntropyUnit.JoulePerKelvin), // BaseUnit -> EntropyUnit - (EntropyUnit.JoulePerKelvin, EntropyUnit.CaloriePerKelvin) => new Entropy(_value / 4.184, EntropyUnit.CaloriePerKelvin), + (EntropyUnit.JoulePerKelvin, EntropyUnit.CaloriePerKelvin) => new Entropy(_value * new QuantityValue(125, 523, false), EntropyUnit.CaloriePerKelvin), (EntropyUnit.JoulePerKelvin, EntropyUnit.JoulePerDegreeCelsius) => new Entropy(_value, EntropyUnit.JoulePerDegreeCelsius), - (EntropyUnit.JoulePerKelvin, EntropyUnit.KilocaloriePerKelvin) => new Entropy((_value / 4.184) / 1e3d, EntropyUnit.KilocaloriePerKelvin), - (EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerDegreeCelsius) => new Entropy((_value) / 1e3d, EntropyUnit.KilojoulePerDegreeCelsius), - (EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerKelvin) => new Entropy((_value) / 1e3d, EntropyUnit.KilojoulePerKelvin), - (EntropyUnit.JoulePerKelvin, EntropyUnit.MegajoulePerKelvin) => new Entropy((_value) / 1e6d, EntropyUnit.MegajoulePerKelvin), + (EntropyUnit.JoulePerKelvin, EntropyUnit.KilocaloriePerKelvin) => new Entropy(_value / 4184, EntropyUnit.KilocaloriePerKelvin), + (EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerDegreeCelsius) => new Entropy(_value / 1000, EntropyUnit.KilojoulePerDegreeCelsius), + (EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerKelvin) => new Entropy(_value / 1000, EntropyUnit.KilojoulePerKelvin), + (EntropyUnit.JoulePerKelvin, EntropyUnit.MegajoulePerKelvin) => new Entropy(_value / 1000000, EntropyUnit.MegajoulePerKelvin), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index a1274c9d42..5a83bfcc8d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -65,7 +63,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -109,7 +107,7 @@ static Force() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Force(double value, ForceUnit unit) + public Force(QuantityValue value, ForceUnit unit) { _value = value; _unit = unit; @@ -123,7 +121,7 @@ public Force(double value, ForceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Force(double value, UnitSystem unitSystem) + public Force(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -174,10 +172,10 @@ public Force(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -202,77 +200,77 @@ public Force(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Decanewtons => As(ForceUnit.Decanewton); + public QuantityValue Decanewtons => As(ForceUnit.Decanewton); /// /// Gets a value of this quantity converted into /// - public double Dyne => As(ForceUnit.Dyn); + public QuantityValue Dyne => As(ForceUnit.Dyn); /// /// Gets a value of this quantity converted into /// - public double KilogramsForce => As(ForceUnit.KilogramForce); + public QuantityValue KilogramsForce => As(ForceUnit.KilogramForce); /// /// Gets a value of this quantity converted into /// - public double Kilonewtons => As(ForceUnit.Kilonewton); + public QuantityValue Kilonewtons => As(ForceUnit.Kilonewton); /// /// Gets a value of this quantity converted into /// - public double KiloPonds => As(ForceUnit.KiloPond); + public QuantityValue KiloPonds => As(ForceUnit.KiloPond); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForce => As(ForceUnit.KilopoundForce); + public QuantityValue KilopoundsForce => As(ForceUnit.KilopoundForce); /// /// Gets a value of this quantity converted into /// - public double Meganewtons => As(ForceUnit.Meganewton); + public QuantityValue Meganewtons => As(ForceUnit.Meganewton); /// /// Gets a value of this quantity converted into /// - public double Micronewtons => As(ForceUnit.Micronewton); + public QuantityValue Micronewtons => As(ForceUnit.Micronewton); /// /// Gets a value of this quantity converted into /// - public double Millinewtons => As(ForceUnit.Millinewton); + public QuantityValue Millinewtons => As(ForceUnit.Millinewton); /// /// Gets a value of this quantity converted into /// - public double Newtons => As(ForceUnit.Newton); + public QuantityValue Newtons => As(ForceUnit.Newton); /// /// Gets a value of this quantity converted into /// - public double OunceForce => As(ForceUnit.OunceForce); + public QuantityValue OunceForce => As(ForceUnit.OunceForce); /// /// Gets a value of this quantity converted into /// - public double Poundals => As(ForceUnit.Poundal); + public QuantityValue Poundals => As(ForceUnit.Poundal); /// /// Gets a value of this quantity converted into /// - public double PoundsForce => As(ForceUnit.PoundForce); + public QuantityValue PoundsForce => As(ForceUnit.PoundForce); /// /// Gets a value of this quantity converted into /// - public double ShortTonsForce => As(ForceUnit.ShortTonForce); + public QuantityValue ShortTonsForce => As(ForceUnit.ShortTonForce); /// /// Gets a value of this quantity converted into /// - public double TonnesForce => As(ForceUnit.TonneForce); + public QuantityValue TonnesForce => As(ForceUnit.TonneForce); #endregion @@ -348,7 +346,7 @@ public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Force FromDecanewtons(double value) + public static Force FromDecanewtons(QuantityValue value) { return new Force(value, ForceUnit.Decanewton); } @@ -356,7 +354,7 @@ public static Force FromDecanewtons(double value) /// /// Creates a from . /// - public static Force FromDyne(double value) + public static Force FromDyne(QuantityValue value) { return new Force(value, ForceUnit.Dyn); } @@ -364,7 +362,7 @@ public static Force FromDyne(double value) /// /// Creates a from . /// - public static Force FromKilogramsForce(double value) + public static Force FromKilogramsForce(QuantityValue value) { return new Force(value, ForceUnit.KilogramForce); } @@ -372,7 +370,7 @@ public static Force FromKilogramsForce(double value) /// /// Creates a from . /// - public static Force FromKilonewtons(double value) + public static Force FromKilonewtons(QuantityValue value) { return new Force(value, ForceUnit.Kilonewton); } @@ -380,7 +378,7 @@ public static Force FromKilonewtons(double value) /// /// Creates a from . /// - public static Force FromKiloPonds(double value) + public static Force FromKiloPonds(QuantityValue value) { return new Force(value, ForceUnit.KiloPond); } @@ -388,7 +386,7 @@ public static Force FromKiloPonds(double value) /// /// Creates a from . /// - public static Force FromKilopoundsForce(double value) + public static Force FromKilopoundsForce(QuantityValue value) { return new Force(value, ForceUnit.KilopoundForce); } @@ -396,7 +394,7 @@ public static Force FromKilopoundsForce(double value) /// /// Creates a from . /// - public static Force FromMeganewtons(double value) + public static Force FromMeganewtons(QuantityValue value) { return new Force(value, ForceUnit.Meganewton); } @@ -404,7 +402,7 @@ public static Force FromMeganewtons(double value) /// /// Creates a from . /// - public static Force FromMicronewtons(double value) + public static Force FromMicronewtons(QuantityValue value) { return new Force(value, ForceUnit.Micronewton); } @@ -412,7 +410,7 @@ public static Force FromMicronewtons(double value) /// /// Creates a from . /// - public static Force FromMillinewtons(double value) + public static Force FromMillinewtons(QuantityValue value) { return new Force(value, ForceUnit.Millinewton); } @@ -420,7 +418,7 @@ public static Force FromMillinewtons(double value) /// /// Creates a from . /// - public static Force FromNewtons(double value) + public static Force FromNewtons(QuantityValue value) { return new Force(value, ForceUnit.Newton); } @@ -428,7 +426,7 @@ public static Force FromNewtons(double value) /// /// Creates a from . /// - public static Force FromOunceForce(double value) + public static Force FromOunceForce(QuantityValue value) { return new Force(value, ForceUnit.OunceForce); } @@ -436,7 +434,7 @@ public static Force FromOunceForce(double value) /// /// Creates a from . /// - public static Force FromPoundals(double value) + public static Force FromPoundals(QuantityValue value) { return new Force(value, ForceUnit.Poundal); } @@ -444,7 +442,7 @@ public static Force FromPoundals(double value) /// /// Creates a from . /// - public static Force FromPoundsForce(double value) + public static Force FromPoundsForce(QuantityValue value) { return new Force(value, ForceUnit.PoundForce); } @@ -452,7 +450,7 @@ public static Force FromPoundsForce(double value) /// /// Creates a from . /// - public static Force FromShortTonsForce(double value) + public static Force FromShortTonsForce(QuantityValue value) { return new Force(value, ForceUnit.ShortTonForce); } @@ -460,7 +458,7 @@ public static Force FromShortTonsForce(double value) /// /// Creates a from . /// - public static Force FromTonnesForce(double value) + public static Force FromTonnesForce(QuantityValue value) { return new Force(value, ForceUnit.TonneForce); } @@ -471,7 +469,7 @@ public static Force FromTonnesForce(double value) /// Value to convert from. /// Unit to convert from. /// Force unit value. - public static Force From(double value, ForceUnit fromUnit) + public static Force From(QuantityValue value, ForceUnit fromUnit) { return new Force(value, fromUnit); } @@ -643,25 +641,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static Force operator *(double left, Force right) + public static Force operator *(QuantityValue left, Force right) { return new Force(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Force operator *(Force left, double right) + public static Force operator *(Force left, QuantityValue right) { return new Force(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Force operator /(Force left, double right) + public static Force operator /(Force left, QuantityValue right) { return new Force(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Force left, Force right) + public static QuantityValue operator /(Force left, Force right) { return left.Newtons / right.Newtons; } @@ -770,27 +768,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Force left, Force right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Force other, Force tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Force left, Force right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Force otherQuantity)) @@ -800,15 +791,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Force other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -891,10 +879,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -911,7 +899,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Force other, Force tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -924,7 +912,12 @@ public bool Equals(Force other, Force tolerance) /// A hash code for the current Force. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -935,7 +928,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceUnit unit) + public QuantityValue As(ForceUnit unit) { if (Unit == unit) return Value; @@ -944,7 +937,7 @@ public double As(ForceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -959,7 +952,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); @@ -1025,36 +1018,36 @@ private bool TryToUnit(ForceUnit unit, [NotNullWhen(true)] out Force? converted) Force? convertedOrNull = (Unit, unit) switch { // ForceUnit -> BaseUnit - (ForceUnit.Decanewton, ForceUnit.Newton) => new Force((_value) * 1e1d, ForceUnit.Newton), - (ForceUnit.Dyn, ForceUnit.Newton) => new Force(_value / 1e5, ForceUnit.Newton), - (ForceUnit.KilogramForce, ForceUnit.Newton) => new Force(_value * 9.80665, ForceUnit.Newton), - (ForceUnit.Kilonewton, ForceUnit.Newton) => new Force((_value) * 1e3d, ForceUnit.Newton), - (ForceUnit.KiloPond, ForceUnit.Newton) => new Force(_value * 9.80665, ForceUnit.Newton), - (ForceUnit.KilopoundForce, ForceUnit.Newton) => new Force((_value * 4.4482216152605) * 1e3d, ForceUnit.Newton), - (ForceUnit.Meganewton, ForceUnit.Newton) => new Force((_value) * 1e6d, ForceUnit.Newton), - (ForceUnit.Micronewton, ForceUnit.Newton) => new Force((_value) * 1e-6d, ForceUnit.Newton), - (ForceUnit.Millinewton, ForceUnit.Newton) => new Force((_value) * 1e-3d, ForceUnit.Newton), - (ForceUnit.OunceForce, ForceUnit.Newton) => new Force(_value * (4.4482216152605 / 16), ForceUnit.Newton), - (ForceUnit.Poundal, ForceUnit.Newton) => new Force(_value * 0.138254954376, ForceUnit.Newton), - (ForceUnit.PoundForce, ForceUnit.Newton) => new Force(_value * 4.4482216152605, ForceUnit.Newton), - (ForceUnit.ShortTonForce, ForceUnit.Newton) => new Force(_value * (4.4482216152605 * 2000), ForceUnit.Newton), - (ForceUnit.TonneForce, ForceUnit.Newton) => new Force(_value * (9.80665 * 1000), ForceUnit.Newton), + (ForceUnit.Decanewton, ForceUnit.Newton) => new Force(_value * 10, ForceUnit.Newton), + (ForceUnit.Dyn, ForceUnit.Newton) => new Force(_value / 100000, ForceUnit.Newton), + (ForceUnit.KilogramForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(196133, 20000, false), ForceUnit.Newton), + (ForceUnit.Kilonewton, ForceUnit.Newton) => new Force(_value * 1000, ForceUnit.Newton), + (ForceUnit.KiloPond, ForceUnit.Newton) => new Force(_value * new QuantityValue(196133, 20000, false), ForceUnit.Newton), + (ForceUnit.KilopoundForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(8896443230521, 2000000000, false), ForceUnit.Newton), + (ForceUnit.Meganewton, ForceUnit.Newton) => new Force(_value * 1000000, ForceUnit.Newton), + (ForceUnit.Micronewton, ForceUnit.Newton) => new Force(_value / 1000000, ForceUnit.Newton), + (ForceUnit.Millinewton, ForceUnit.Newton) => new Force(_value / 1000, ForceUnit.Newton), + (ForceUnit.OunceForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(8896443230521, 32000000000000, false), ForceUnit.Newton), + (ForceUnit.Poundal, ForceUnit.Newton) => new Force(_value * new QuantityValue(17281869297, 125000000000, false), ForceUnit.Newton), + (ForceUnit.PoundForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(8896443230521, 2000000000000, false), ForceUnit.Newton), + (ForceUnit.ShortTonForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(8896443230521, 1000000000, false), ForceUnit.Newton), + (ForceUnit.TonneForce, ForceUnit.Newton) => new Force(_value * new QuantityValue(196133, 20, false), ForceUnit.Newton), // BaseUnit -> ForceUnit - (ForceUnit.Newton, ForceUnit.Decanewton) => new Force((_value) / 1e1d, ForceUnit.Decanewton), - (ForceUnit.Newton, ForceUnit.Dyn) => new Force(_value * 1e5, ForceUnit.Dyn), - (ForceUnit.Newton, ForceUnit.KilogramForce) => new Force(_value / 9.80665, ForceUnit.KilogramForce), - (ForceUnit.Newton, ForceUnit.Kilonewton) => new Force((_value) / 1e3d, ForceUnit.Kilonewton), - (ForceUnit.Newton, ForceUnit.KiloPond) => new Force(_value / 9.80665, ForceUnit.KiloPond), - (ForceUnit.Newton, ForceUnit.KilopoundForce) => new Force((_value / 4.4482216152605) / 1e3d, ForceUnit.KilopoundForce), - (ForceUnit.Newton, ForceUnit.Meganewton) => new Force((_value) / 1e6d, ForceUnit.Meganewton), - (ForceUnit.Newton, ForceUnit.Micronewton) => new Force((_value) / 1e-6d, ForceUnit.Micronewton), - (ForceUnit.Newton, ForceUnit.Millinewton) => new Force((_value) / 1e-3d, ForceUnit.Millinewton), - (ForceUnit.Newton, ForceUnit.OunceForce) => new Force(_value / (4.4482216152605 / 16), ForceUnit.OunceForce), - (ForceUnit.Newton, ForceUnit.Poundal) => new Force(_value / 0.138254954376, ForceUnit.Poundal), - (ForceUnit.Newton, ForceUnit.PoundForce) => new Force(_value / 4.4482216152605, ForceUnit.PoundForce), - (ForceUnit.Newton, ForceUnit.ShortTonForce) => new Force(_value / (4.4482216152605 * 2000), ForceUnit.ShortTonForce), - (ForceUnit.Newton, ForceUnit.TonneForce) => new Force(_value / (9.80665 * 1000), ForceUnit.TonneForce), + (ForceUnit.Newton, ForceUnit.Decanewton) => new Force(_value / 10, ForceUnit.Decanewton), + (ForceUnit.Newton, ForceUnit.Dyn) => new Force(_value * 100000, ForceUnit.Dyn), + (ForceUnit.Newton, ForceUnit.KilogramForce) => new Force(_value * new QuantityValue(20000, 196133, false), ForceUnit.KilogramForce), + (ForceUnit.Newton, ForceUnit.Kilonewton) => new Force(_value / 1000, ForceUnit.Kilonewton), + (ForceUnit.Newton, ForceUnit.KiloPond) => new Force(_value * new QuantityValue(20000, 196133, false), ForceUnit.KiloPond), + (ForceUnit.Newton, ForceUnit.KilopoundForce) => new Force(_value * new QuantityValue(2000000000, 8896443230521, false), ForceUnit.KilopoundForce), + (ForceUnit.Newton, ForceUnit.Meganewton) => new Force(_value / 1000000, ForceUnit.Meganewton), + (ForceUnit.Newton, ForceUnit.Micronewton) => new Force(_value * 1000000, ForceUnit.Micronewton), + (ForceUnit.Newton, ForceUnit.Millinewton) => new Force(_value * 1000, ForceUnit.Millinewton), + (ForceUnit.Newton, ForceUnit.OunceForce) => new Force(_value * new QuantityValue(32000000000000, 8896443230521, false), ForceUnit.OunceForce), + (ForceUnit.Newton, ForceUnit.Poundal) => new Force(_value * new QuantityValue(125000000000, 17281869297, false), ForceUnit.Poundal), + (ForceUnit.Newton, ForceUnit.PoundForce) => new Force(_value * new QuantityValue(2000000000000, 8896443230521, false), ForceUnit.PoundForce), + (ForceUnit.Newton, ForceUnit.ShortTonForce) => new Force(_value * new QuantityValue(1000000000, 8896443230521, false), ForceUnit.ShortTonForce), + (ForceUnit.Newton, ForceUnit.TonneForce) => new Force(_value * new QuantityValue(20, 196133, false), ForceUnit.TonneForce), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 8593920393..3dfa8f9a83 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,7 +96,7 @@ static ForceChangeRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ForceChangeRate(double value, ForceChangeRateUnit unit) + public ForceChangeRate(QuantityValue value, ForceChangeRateUnit unit) { _value = value; _unit = unit; @@ -112,7 +110,7 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForceChangeRate(double value, UnitSystem unitSystem) + public ForceChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -163,10 +161,10 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,77 +189,77 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); + public QuantityValue CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); + public QuantityValue DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); /// /// Gets a value of this quantity converted into /// - public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); + public QuantityValue DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); + public QuantityValue DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); + public QuantityValue KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); + public QuantityValue KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); + public QuantityValue KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); + public QuantityValue KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); /// /// Gets a value of this quantity converted into /// - public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); + public QuantityValue MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); + public QuantityValue MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); + public QuantityValue NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); + public QuantityValue NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); + public QuantityValue NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); + public QuantityValue PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); + public QuantityValue PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); #endregion @@ -337,7 +335,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? /// /// Creates a from . /// - public static ForceChangeRate FromCentinewtonsPerSecond(double value) + public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond); } @@ -345,7 +343,7 @@ public static ForceChangeRate FromCentinewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromDecanewtonsPerMinute(double value) + public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute); } @@ -353,7 +351,7 @@ public static ForceChangeRate FromDecanewtonsPerMinute(double value) /// /// Creates a from . /// - public static ForceChangeRate FromDecanewtonsPerSecond(double value) + public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond); } @@ -361,7 +359,7 @@ public static ForceChangeRate FromDecanewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromDecinewtonsPerSecond(double value) + public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond); } @@ -369,7 +367,7 @@ public static ForceChangeRate FromDecinewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromKilonewtonsPerMinute(double value) + public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute); } @@ -377,7 +375,7 @@ public static ForceChangeRate FromKilonewtonsPerMinute(double value) /// /// Creates a from . /// - public static ForceChangeRate FromKilonewtonsPerSecond(double value) + public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond); } @@ -385,7 +383,7 @@ public static ForceChangeRate FromKilonewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromKilopoundsForcePerMinute(double value) + public static ForceChangeRate FromKilopoundsForcePerMinute(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerMinute); } @@ -393,7 +391,7 @@ public static ForceChangeRate FromKilopoundsForcePerMinute(double value) /// /// Creates a from . /// - public static ForceChangeRate FromKilopoundsForcePerSecond(double value) + public static ForceChangeRate FromKilopoundsForcePerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerSecond); } @@ -401,7 +399,7 @@ public static ForceChangeRate FromKilopoundsForcePerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromMicronewtonsPerSecond(double value) + public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond); } @@ -409,7 +407,7 @@ public static ForceChangeRate FromMicronewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromMillinewtonsPerSecond(double value) + public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond); } @@ -417,7 +415,7 @@ public static ForceChangeRate FromMillinewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromNanonewtonsPerSecond(double value) + public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond); } @@ -425,7 +423,7 @@ public static ForceChangeRate FromNanonewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromNewtonsPerMinute(double value) + public static ForceChangeRate FromNewtonsPerMinute(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute); } @@ -433,7 +431,7 @@ public static ForceChangeRate FromNewtonsPerMinute(double value) /// /// Creates a from . /// - public static ForceChangeRate FromNewtonsPerSecond(double value) + public static ForceChangeRate FromNewtonsPerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond); } @@ -441,7 +439,7 @@ public static ForceChangeRate FromNewtonsPerSecond(double value) /// /// Creates a from . /// - public static ForceChangeRate FromPoundsForcePerMinute(double value) + public static ForceChangeRate FromPoundsForcePerMinute(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerMinute); } @@ -449,7 +447,7 @@ public static ForceChangeRate FromPoundsForcePerMinute(double value) /// /// Creates a from . /// - public static ForceChangeRate FromPoundsForcePerSecond(double value) + public static ForceChangeRate FromPoundsForcePerSecond(QuantityValue value) { return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerSecond); } @@ -460,7 +458,7 @@ public static ForceChangeRate FromPoundsForcePerSecond(double value) /// Value to convert from. /// Unit to convert from. /// ForceChangeRate unit value. - public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit) + public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit) { return new ForceChangeRate(value, fromUnit); } @@ -632,25 +630,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForceChangeRate operator *(double left, ForceChangeRate right) + public static ForceChangeRate operator *(QuantityValue left, ForceChangeRate right) { return new ForceChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForceChangeRate operator *(ForceChangeRate left, double right) + public static ForceChangeRate operator *(ForceChangeRate left, QuantityValue right) { return new ForceChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForceChangeRate operator /(ForceChangeRate left, double right) + public static ForceChangeRate operator /(ForceChangeRate left, QuantityValue right) { return new ForceChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ForceChangeRate left, ForceChangeRate right) + public static QuantityValue operator /(ForceChangeRate left, ForceChangeRate right) { return left.NewtonsPerSecond / right.NewtonsPerSecond; } @@ -693,27 +691,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ForceChangeRate left, ForceChangeRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForceChangeRate other, ForceChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ForceChangeRate left, ForceChangeRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ForceChangeRate otherQuantity)) @@ -723,15 +714,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ForceChangeRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -814,10 +802,10 @@ public bool Equals(ForceChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -834,7 +822,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ForceChangeRate other, ForceChangeRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -847,7 +835,12 @@ public bool Equals(ForceChangeRate other, ForceChangeRate tolerance) /// A hash code for the current ForceChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -858,7 +851,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceChangeRateUnit unit) + public QuantityValue As(ForceChangeRateUnit unit) { if (Unit == unit) return Value; @@ -867,7 +860,7 @@ public double As(ForceChangeRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -882,7 +875,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); @@ -948,36 +941,36 @@ private bool TryToUnit(ForceChangeRateUnit unit, [NotNullWhen(true)] out ForceCh ForceChangeRate? convertedOrNull = (Unit, unit) switch { // ForceChangeRateUnit -> BaseUnit - (ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e-2d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value / 60) * 1e1d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e1d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e-1d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value / 60) * 1e3d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e3d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.KilopoundForcePerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value * 4.4482216152605095551842641431421 / 60) * 1e3d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.KilopoundForcePerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value * 4.4482216152605095551842641431421) * 1e3d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e-6d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e-3d, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate((_value) * 1e-9d, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 100, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 6, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * 10, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 10, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * new QuantityValue(50, 3, false), ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * 1000, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.KilopoundForcePerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * new QuantityValue(8896443230521, 120000000000, false), ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.KilopoundForcePerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * new QuantityValue(8896443230521, 2000000000, false), ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 1000000, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 1000, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 1000000000, ForceChangeRateUnit.NewtonPerSecond), (ForceChangeRateUnit.NewtonPerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value / 60, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.PoundForcePerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * 4.4482216152605095551842641431421 / 60, ForceChangeRateUnit.NewtonPerSecond), - (ForceChangeRateUnit.PoundForcePerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * 4.4482216152605095551842641431421, ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.PoundForcePerMinute, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * new QuantityValue(8896443230521, 120000000000000, false), ForceChangeRateUnit.NewtonPerSecond), + (ForceChangeRateUnit.PoundForcePerSecond, ForceChangeRateUnit.NewtonPerSecond) => new ForceChangeRate(_value * new QuantityValue(8896443230521, 2000000000000, false), ForceChangeRateUnit.NewtonPerSecond), // BaseUnit -> ForceChangeRateUnit - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.CentinewtonPerSecond) => new ForceChangeRate((_value) / 1e-2d, ForceChangeRateUnit.CentinewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecanewtonPerMinute) => new ForceChangeRate((_value * 60) / 1e1d, ForceChangeRateUnit.DecanewtonPerMinute), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecanewtonPerSecond) => new ForceChangeRate((_value) / 1e1d, ForceChangeRateUnit.DecanewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecinewtonPerSecond) => new ForceChangeRate((_value) / 1e-1d, ForceChangeRateUnit.DecinewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilonewtonPerMinute) => new ForceChangeRate((_value * 60) / 1e3d, ForceChangeRateUnit.KilonewtonPerMinute), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilonewtonPerSecond) => new ForceChangeRate((_value) / 1e3d, ForceChangeRateUnit.KilonewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilopoundForcePerMinute) => new ForceChangeRate((_value / 4.4482216152605095551842641431421 * 60) / 1e3d, ForceChangeRateUnit.KilopoundForcePerMinute), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilopoundForcePerSecond) => new ForceChangeRate((_value / 4.4482216152605095551842641431421) / 1e3d, ForceChangeRateUnit.KilopoundForcePerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.MicronewtonPerSecond) => new ForceChangeRate((_value) / 1e-6d, ForceChangeRateUnit.MicronewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.MillinewtonPerSecond) => new ForceChangeRate((_value) / 1e-3d, ForceChangeRateUnit.MillinewtonPerSecond), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.NanonewtonPerSecond) => new ForceChangeRate((_value) / 1e-9d, ForceChangeRateUnit.NanonewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.CentinewtonPerSecond) => new ForceChangeRate(_value * 100, ForceChangeRateUnit.CentinewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecanewtonPerMinute) => new ForceChangeRate(_value * 6, ForceChangeRateUnit.DecanewtonPerMinute), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecanewtonPerSecond) => new ForceChangeRate(_value / 10, ForceChangeRateUnit.DecanewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.DecinewtonPerSecond) => new ForceChangeRate(_value * 10, ForceChangeRateUnit.DecinewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilonewtonPerMinute) => new ForceChangeRate(_value * new QuantityValue(3, 50, false), ForceChangeRateUnit.KilonewtonPerMinute), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilonewtonPerSecond) => new ForceChangeRate(_value / 1000, ForceChangeRateUnit.KilonewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilopoundForcePerMinute) => new ForceChangeRate(_value * new QuantityValue(120000000000, 8896443230521, false), ForceChangeRateUnit.KilopoundForcePerMinute), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.KilopoundForcePerSecond) => new ForceChangeRate(_value * new QuantityValue(2000000000, 8896443230521, false), ForceChangeRateUnit.KilopoundForcePerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.MicronewtonPerSecond) => new ForceChangeRate(_value * 1000000, ForceChangeRateUnit.MicronewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.MillinewtonPerSecond) => new ForceChangeRate(_value * 1000, ForceChangeRateUnit.MillinewtonPerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.NanonewtonPerSecond) => new ForceChangeRate(_value * 1000000000, ForceChangeRateUnit.NanonewtonPerSecond), (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.NewtonPerMinute) => new ForceChangeRate(_value * 60, ForceChangeRateUnit.NewtonPerMinute), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerMinute) => new ForceChangeRate(_value / 4.4482216152605095551842641431421 * 60, ForceChangeRateUnit.PoundForcePerMinute), - (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerSecond) => new ForceChangeRate(_value / 4.4482216152605095551842641431421, ForceChangeRateUnit.PoundForcePerSecond), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerMinute) => new ForceChangeRate(_value * new QuantityValue(120000000000000, 8896443230521, false), ForceChangeRateUnit.PoundForcePerMinute), + (ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerSecond) => new ForceChangeRate(_value * new QuantityValue(2000000000000, 8896443230521, false), ForceChangeRateUnit.PoundForcePerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index b33a84b513..d620d74ddd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -62,7 +60,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -129,7 +127,7 @@ static ForcePerLength() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ForcePerLength(double value, ForcePerLengthUnit unit) + public ForcePerLength(QuantityValue value, ForcePerLengthUnit unit) { _value = value; _unit = unit; @@ -143,7 +141,7 @@ public ForcePerLength(double value, ForcePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForcePerLength(double value, UnitSystem unitSystem) + public ForcePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -194,10 +192,10 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -222,192 +220,192 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); + public QuantityValue CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); + public QuantityValue CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); + public QuantityValue CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); + public QuantityValue DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); + public QuantityValue DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); + public QuantityValue DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); + public QuantityValue DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); + public QuantityValue DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); + public QuantityValue DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); + public QuantityValue KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); + public QuantityValue KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); + public QuantityValue KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); + public QuantityValue KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); + public QuantityValue KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); + public QuantityValue KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); + public QuantityValue KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); + public QuantityValue KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); /// /// Gets a value of this quantity converted into /// - public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); + public QuantityValue MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); + public QuantityValue MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); + public QuantityValue MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); + public QuantityValue MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); + public QuantityValue MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); + public QuantityValue MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); + public QuantityValue MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); + public QuantityValue MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); + public QuantityValue MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); + public QuantityValue NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); + public QuantityValue NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); + public QuantityValue NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); + public QuantityValue NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); + public QuantityValue NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); + public QuantityValue NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); + public QuantityValue PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); + public QuantityValue PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); + public QuantityValue PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); + public QuantityValue TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); + public QuantityValue TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); + public QuantityValue TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); #endregion @@ -529,7 +527,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static ForcePerLength FromCentinewtonsPerCentimeter(double value) + public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter); } @@ -537,7 +535,7 @@ public static ForcePerLength FromCentinewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromCentinewtonsPerMeter(double value) + public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter); } @@ -545,7 +543,7 @@ public static ForcePerLength FromCentinewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromCentinewtonsPerMillimeter(double value) + public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter); } @@ -553,7 +551,7 @@ public static ForcePerLength FromCentinewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecanewtonsPerCentimeter(double value) + public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter); } @@ -561,7 +559,7 @@ public static ForcePerLength FromDecanewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecanewtonsPerMeter(double value) + public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter); } @@ -569,7 +567,7 @@ public static ForcePerLength FromDecanewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecanewtonsPerMillimeter(double value) + public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter); } @@ -577,7 +575,7 @@ public static ForcePerLength FromDecanewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecinewtonsPerCentimeter(double value) + public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter); } @@ -585,7 +583,7 @@ public static ForcePerLength FromDecinewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecinewtonsPerMeter(double value) + public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter); } @@ -593,7 +591,7 @@ public static ForcePerLength FromDecinewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromDecinewtonsPerMillimeter(double value) + public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter); } @@ -601,7 +599,7 @@ public static ForcePerLength FromDecinewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilogramsForcePerCentimeter(double value) + public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter); } @@ -609,7 +607,7 @@ public static ForcePerLength FromKilogramsForcePerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilogramsForcePerMeter(double value) + public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter); } @@ -617,7 +615,7 @@ public static ForcePerLength FromKilogramsForcePerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilogramsForcePerMillimeter(double value) + public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter); } @@ -625,7 +623,7 @@ public static ForcePerLength FromKilogramsForcePerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilonewtonsPerCentimeter(double value) + public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter); } @@ -633,7 +631,7 @@ public static ForcePerLength FromKilonewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilonewtonsPerMeter(double value) + public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter); } @@ -641,7 +639,7 @@ public static ForcePerLength FromKilonewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilonewtonsPerMillimeter(double value) + public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter); } @@ -649,7 +647,7 @@ public static ForcePerLength FromKilonewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilopoundsForcePerFoot(double value) + public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot); } @@ -657,7 +655,7 @@ public static ForcePerLength FromKilopoundsForcePerFoot(double value) /// /// Creates a from . /// - public static ForcePerLength FromKilopoundsForcePerInch(double value) + public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch); } @@ -665,7 +663,7 @@ public static ForcePerLength FromKilopoundsForcePerInch(double value) /// /// Creates a from . /// - public static ForcePerLength FromMeganewtonsPerCentimeter(double value) + public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter); } @@ -673,7 +671,7 @@ public static ForcePerLength FromMeganewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMeganewtonsPerMeter(double value) + public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter); } @@ -681,7 +679,7 @@ public static ForcePerLength FromMeganewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMeganewtonsPerMillimeter(double value) + public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter); } @@ -689,7 +687,7 @@ public static ForcePerLength FromMeganewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMicronewtonsPerCentimeter(double value) + public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter); } @@ -697,7 +695,7 @@ public static ForcePerLength FromMicronewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMicronewtonsPerMeter(double value) + public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter); } @@ -705,7 +703,7 @@ public static ForcePerLength FromMicronewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMicronewtonsPerMillimeter(double value) + public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter); } @@ -713,7 +711,7 @@ public static ForcePerLength FromMicronewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMillinewtonsPerCentimeter(double value) + public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter); } @@ -721,7 +719,7 @@ public static ForcePerLength FromMillinewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMillinewtonsPerMeter(double value) + public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter); } @@ -729,7 +727,7 @@ public static ForcePerLength FromMillinewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromMillinewtonsPerMillimeter(double value) + public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter); } @@ -737,7 +735,7 @@ public static ForcePerLength FromMillinewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNanonewtonsPerCentimeter(double value) + public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter); } @@ -745,7 +743,7 @@ public static ForcePerLength FromNanonewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNanonewtonsPerMeter(double value) + public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter); } @@ -753,7 +751,7 @@ public static ForcePerLength FromNanonewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNanonewtonsPerMillimeter(double value) + public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter); } @@ -761,7 +759,7 @@ public static ForcePerLength FromNanonewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNewtonsPerCentimeter(double value) + public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter); } @@ -769,7 +767,7 @@ public static ForcePerLength FromNewtonsPerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNewtonsPerMeter(double value) + public static ForcePerLength FromNewtonsPerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter); } @@ -777,7 +775,7 @@ public static ForcePerLength FromNewtonsPerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromNewtonsPerMillimeter(double value) + public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter); } @@ -785,7 +783,7 @@ public static ForcePerLength FromNewtonsPerMillimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromPoundsForcePerFoot(double value) + public static ForcePerLength FromPoundsForcePerFoot(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot); } @@ -793,7 +791,7 @@ public static ForcePerLength FromPoundsForcePerFoot(double value) /// /// Creates a from . /// - public static ForcePerLength FromPoundsForcePerInch(double value) + public static ForcePerLength FromPoundsForcePerInch(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch); } @@ -801,7 +799,7 @@ public static ForcePerLength FromPoundsForcePerInch(double value) /// /// Creates a from . /// - public static ForcePerLength FromPoundsForcePerYard(double value) + public static ForcePerLength FromPoundsForcePerYard(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard); } @@ -809,7 +807,7 @@ public static ForcePerLength FromPoundsForcePerYard(double value) /// /// Creates a from . /// - public static ForcePerLength FromTonnesForcePerCentimeter(double value) + public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter); } @@ -817,7 +815,7 @@ public static ForcePerLength FromTonnesForcePerCentimeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromTonnesForcePerMeter(double value) + public static ForcePerLength FromTonnesForcePerMeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter); } @@ -825,7 +823,7 @@ public static ForcePerLength FromTonnesForcePerMeter(double value) /// /// Creates a from . /// - public static ForcePerLength FromTonnesForcePerMillimeter(double value) + public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue value) { return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter); } @@ -836,7 +834,7 @@ public static ForcePerLength FromTonnesForcePerMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// ForcePerLength unit value. - public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit) + public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUnit) { return new ForcePerLength(value, fromUnit); } @@ -1008,25 +1006,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForcePerLength operator *(double left, ForcePerLength right) + public static ForcePerLength operator *(QuantityValue left, ForcePerLength right) { return new ForcePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForcePerLength operator *(ForcePerLength left, double right) + public static ForcePerLength operator *(ForcePerLength left, QuantityValue right) { return new ForcePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForcePerLength operator /(ForcePerLength left, double right) + public static ForcePerLength operator /(ForcePerLength left, QuantityValue right) { return new ForcePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ForcePerLength left, ForcePerLength right) + public static QuantityValue operator /(ForcePerLength left, ForcePerLength right) { return left.NewtonsPerMeter / right.NewtonsPerMeter; } @@ -1117,27 +1115,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ForcePerLength left, ForcePerLength right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ForcePerLength other, ForcePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ForcePerLength left, ForcePerLength right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ForcePerLength otherQuantity)) @@ -1147,15 +1138,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ForcePerLength other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1238,10 +1226,10 @@ public bool Equals(ForcePerLength other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1258,7 +1246,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ForcePerLength other, ForcePerLength tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1271,7 +1259,12 @@ public bool Equals(ForcePerLength other, ForcePerLength tolerance) /// A hash code for the current ForcePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1282,7 +1275,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForcePerLengthUnit unit) + public QuantityValue As(ForcePerLengthUnit unit) { if (Unit == unit) return Value; @@ -1291,7 +1284,7 @@ public double As(ForcePerLengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1306,7 +1299,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); @@ -1372,82 +1365,82 @@ private bool TryToUnit(ForcePerLengthUnit unit, [NotNullWhen(true)] out ForcePer ForcePerLength? convertedOrNull = (Unit, unit) switch { // ForcePerLengthUnit -> BaseUnit - (ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e-2d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e-2d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e-2d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e-1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e-1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e-1d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 980.665002864, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 9.80665002864, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 9.80665002864e3, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 14593.90292, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1.75126835e5, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e-6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e-6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e-6d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e-3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e-3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e-3d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e2) * 1e-9d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value) * 1e-9d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength((_value * 1e3) * 1e-9d, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1e2, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1e3, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.PoundForcePerFoot, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 14.59390292, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.PoundForcePerInch, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1.75126835e2, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.PoundForcePerYard, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 4.864634307, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 9.80665002864e5, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.TonneForcePerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 9.80665002864e3, ForcePerLengthUnit.NewtonPerMeter), - (ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 9.80665002864e6, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 100, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 10, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 10, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 10000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 10, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 10, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 100, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 62500000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 6250000000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 6250000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 100000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(364847573, 25000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(35025367, 200, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 100000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 10000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 1000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 1000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 10, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 1000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 10000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 1000000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value / 1000000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 100, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * 1000, ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.PoundForcePerFoot, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(364847573, 25000000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.PoundForcePerInch, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(35025367, 200000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.PoundForcePerYard, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(4864634307, 1000000000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 62500, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.TonneForcePerMeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 6250000, false), ForcePerLengthUnit.NewtonPerMeter), + (ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLengthUnit.NewtonPerMeter) => new ForcePerLength(_value * new QuantityValue(61291562679, 6250, false), ForcePerLengthUnit.NewtonPerMeter), // BaseUnit -> ForcePerLengthUnit - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e-2d, ForcePerLengthUnit.CentinewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerMeter) => new ForcePerLength((_value) / 1e-2d, ForcePerLengthUnit.CentinewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e-2d, ForcePerLengthUnit.CentinewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e1d, ForcePerLengthUnit.DecanewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerMeter) => new ForcePerLength((_value) / 1e1d, ForcePerLengthUnit.DecanewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e1d, ForcePerLengthUnit.DecanewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e-1d, ForcePerLengthUnit.DecinewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerMeter) => new ForcePerLength((_value) / 1e-1d, ForcePerLengthUnit.DecinewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e-1d, ForcePerLengthUnit.DecinewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerCentimeter) => new ForcePerLength(_value / 980.665002864, ForcePerLengthUnit.KilogramForcePerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerMeter) => new ForcePerLength(_value / 9.80665002864, ForcePerLengthUnit.KilogramForcePerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerMillimeter) => new ForcePerLength(_value / 9.80665002864e3, ForcePerLengthUnit.KilogramForcePerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e3d, ForcePerLengthUnit.KilonewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerMeter) => new ForcePerLength((_value) / 1e3d, ForcePerLengthUnit.KilonewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e3d, ForcePerLengthUnit.KilonewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilopoundForcePerFoot) => new ForcePerLength(_value / 14593.90292, ForcePerLengthUnit.KilopoundForcePerFoot), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilopoundForcePerInch) => new ForcePerLength(_value / 1.75126835e5, ForcePerLengthUnit.KilopoundForcePerInch), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e6d, ForcePerLengthUnit.MeganewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerMeter) => new ForcePerLength((_value) / 1e6d, ForcePerLengthUnit.MeganewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e6d, ForcePerLengthUnit.MeganewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e-6d, ForcePerLengthUnit.MicronewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerMeter) => new ForcePerLength((_value) / 1e-6d, ForcePerLengthUnit.MicronewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e-6d, ForcePerLengthUnit.MicronewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e-3d, ForcePerLengthUnit.MillinewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerMeter) => new ForcePerLength((_value) / 1e-3d, ForcePerLengthUnit.MillinewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e-3d, ForcePerLengthUnit.MillinewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerCentimeter) => new ForcePerLength((_value / 1e2) / 1e-9d, ForcePerLengthUnit.NanonewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerMeter) => new ForcePerLength((_value) / 1e-9d, ForcePerLengthUnit.NanonewtonPerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerMillimeter) => new ForcePerLength((_value / 1e3) / 1e-9d, ForcePerLengthUnit.NanonewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NewtonPerCentimeter) => new ForcePerLength(_value / 1e2, ForcePerLengthUnit.NewtonPerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NewtonPerMillimeter) => new ForcePerLength(_value / 1e3, ForcePerLengthUnit.NewtonPerMillimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerFoot) => new ForcePerLength(_value / 14.59390292, ForcePerLengthUnit.PoundForcePerFoot), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerInch) => new ForcePerLength(_value / 1.75126835e2, ForcePerLengthUnit.PoundForcePerInch), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerYard) => new ForcePerLength(_value / 4.864634307, ForcePerLengthUnit.PoundForcePerYard), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerCentimeter) => new ForcePerLength(_value / 9.80665002864e5, ForcePerLengthUnit.TonneForcePerCentimeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMeter) => new ForcePerLength(_value / 9.80665002864e3, ForcePerLengthUnit.TonneForcePerMeter), - (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMillimeter) => new ForcePerLength(_value / 9.80665002864e6, ForcePerLengthUnit.TonneForcePerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerCentimeter) => new ForcePerLength(_value, ForcePerLengthUnit.CentinewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerMeter) => new ForcePerLength(_value * 100, ForcePerLengthUnit.CentinewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.CentinewtonPerMillimeter) => new ForcePerLength(_value / 10, ForcePerLengthUnit.CentinewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerCentimeter) => new ForcePerLength(_value / 1000, ForcePerLengthUnit.DecanewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerMeter) => new ForcePerLength(_value / 10, ForcePerLengthUnit.DecanewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecanewtonPerMillimeter) => new ForcePerLength(_value / 10000, ForcePerLengthUnit.DecanewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerCentimeter) => new ForcePerLength(_value / 10, ForcePerLengthUnit.DecinewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerMeter) => new ForcePerLength(_value * 10, ForcePerLengthUnit.DecinewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.DecinewtonPerMillimeter) => new ForcePerLength(_value / 100, ForcePerLengthUnit.DecinewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerCentimeter) => new ForcePerLength(_value * new QuantityValue(62500000, 61291562679, false), ForcePerLengthUnit.KilogramForcePerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerMeter) => new ForcePerLength(_value * new QuantityValue(6250000000, 61291562679, false), ForcePerLengthUnit.KilogramForcePerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilogramForcePerMillimeter) => new ForcePerLength(_value * new QuantityValue(6250000, 61291562679, false), ForcePerLengthUnit.KilogramForcePerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerCentimeter) => new ForcePerLength(_value / 100000, ForcePerLengthUnit.KilonewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerMeter) => new ForcePerLength(_value / 1000, ForcePerLengthUnit.KilonewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilonewtonPerMillimeter) => new ForcePerLength(_value / 1000000, ForcePerLengthUnit.KilonewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilopoundForcePerFoot) => new ForcePerLength(_value * new QuantityValue(25000, 364847573, false), ForcePerLengthUnit.KilopoundForcePerFoot), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.KilopoundForcePerInch) => new ForcePerLength(_value * new QuantityValue(200, 35025367, false), ForcePerLengthUnit.KilopoundForcePerInch), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerCentimeter) => new ForcePerLength(_value / 100000000, ForcePerLengthUnit.MeganewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerMeter) => new ForcePerLength(_value / 1000000, ForcePerLengthUnit.MeganewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MeganewtonPerMillimeter) => new ForcePerLength(_value / 1000000000, ForcePerLengthUnit.MeganewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerCentimeter) => new ForcePerLength(_value * 10000, ForcePerLengthUnit.MicronewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerMeter) => new ForcePerLength(_value * 1000000, ForcePerLengthUnit.MicronewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MicronewtonPerMillimeter) => new ForcePerLength(_value * 1000, ForcePerLengthUnit.MicronewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerCentimeter) => new ForcePerLength(_value * 10, ForcePerLengthUnit.MillinewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerMeter) => new ForcePerLength(_value * 1000, ForcePerLengthUnit.MillinewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.MillinewtonPerMillimeter) => new ForcePerLength(_value, ForcePerLengthUnit.MillinewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerCentimeter) => new ForcePerLength(_value * 10000000, ForcePerLengthUnit.NanonewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerMeter) => new ForcePerLength(_value * 1000000000, ForcePerLengthUnit.NanonewtonPerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NanonewtonPerMillimeter) => new ForcePerLength(_value * 1000000, ForcePerLengthUnit.NanonewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NewtonPerCentimeter) => new ForcePerLength(_value / 100, ForcePerLengthUnit.NewtonPerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NewtonPerMillimeter) => new ForcePerLength(_value / 1000, ForcePerLengthUnit.NewtonPerMillimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerFoot) => new ForcePerLength(_value * new QuantityValue(25000000, 364847573, false), ForcePerLengthUnit.PoundForcePerFoot), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerInch) => new ForcePerLength(_value * new QuantityValue(200000, 35025367, false), ForcePerLengthUnit.PoundForcePerInch), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.PoundForcePerYard) => new ForcePerLength(_value * new QuantityValue(1000000000, 4864634307, false), ForcePerLengthUnit.PoundForcePerYard), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerCentimeter) => new ForcePerLength(_value * new QuantityValue(62500, 61291562679, false), ForcePerLengthUnit.TonneForcePerCentimeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMeter) => new ForcePerLength(_value * new QuantityValue(6250000, 61291562679, false), ForcePerLengthUnit.TonneForcePerMeter), + (ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMillimeter) => new ForcePerLength(_value * new QuantityValue(6250, 61291562679, false), ForcePerLengthUnit.TonneForcePerMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 4e19ecf2dc..535a5add05 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,7 +94,7 @@ static Frequency() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Frequency(double value, FrequencyUnit unit) + public Frequency(QuantityValue value, FrequencyUnit unit) { _value = value; _unit = unit; @@ -110,7 +108,7 @@ public Frequency(double value, FrequencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Frequency(double value, UnitSystem unitSystem) + public Frequency(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -161,10 +159,10 @@ public Frequency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,67 +187,67 @@ public Frequency(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); + public QuantityValue BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); /// /// Gets a value of this quantity converted into /// - public double BUnits => As(FrequencyUnit.BUnit); + public QuantityValue BUnits => As(FrequencyUnit.BUnit); /// /// Gets a value of this quantity converted into /// - public double CyclesPerHour => As(FrequencyUnit.CyclePerHour); + public QuantityValue CyclesPerHour => As(FrequencyUnit.CyclePerHour); /// /// Gets a value of this quantity converted into /// - public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); + public QuantityValue CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); /// /// Gets a value of this quantity converted into /// - public double Gigahertz => As(FrequencyUnit.Gigahertz); + public QuantityValue Gigahertz => As(FrequencyUnit.Gigahertz); /// /// Gets a value of this quantity converted into /// - public double Hertz => As(FrequencyUnit.Hertz); + public QuantityValue Hertz => As(FrequencyUnit.Hertz); /// /// Gets a value of this quantity converted into /// - public double Kilohertz => As(FrequencyUnit.Kilohertz); + public QuantityValue Kilohertz => As(FrequencyUnit.Kilohertz); /// /// Gets a value of this quantity converted into /// - public double Megahertz => As(FrequencyUnit.Megahertz); + public QuantityValue Megahertz => As(FrequencyUnit.Megahertz); /// /// Gets a value of this quantity converted into /// - public double Microhertz => As(FrequencyUnit.Microhertz); + public QuantityValue Microhertz => As(FrequencyUnit.Microhertz); /// /// Gets a value of this quantity converted into /// - public double Millihertz => As(FrequencyUnit.Millihertz); + public QuantityValue Millihertz => As(FrequencyUnit.Millihertz); /// /// Gets a value of this quantity converted into /// - public double PerSecond => As(FrequencyUnit.PerSecond); + public QuantityValue PerSecond => As(FrequencyUnit.PerSecond); /// /// Gets a value of this quantity converted into /// - public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); + public QuantityValue RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); /// /// Gets a value of this quantity converted into /// - public double Terahertz => As(FrequencyUnit.Terahertz); + public QuantityValue Terahertz => As(FrequencyUnit.Terahertz); #endregion @@ -321,7 +319,7 @@ public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provid /// /// Creates a from . /// - public static Frequency FromBeatsPerMinute(double value) + public static Frequency FromBeatsPerMinute(QuantityValue value) { return new Frequency(value, FrequencyUnit.BeatPerMinute); } @@ -329,7 +327,7 @@ public static Frequency FromBeatsPerMinute(double value) /// /// Creates a from . /// - public static Frequency FromBUnits(double value) + public static Frequency FromBUnits(QuantityValue value) { return new Frequency(value, FrequencyUnit.BUnit); } @@ -337,7 +335,7 @@ public static Frequency FromBUnits(double value) /// /// Creates a from . /// - public static Frequency FromCyclesPerHour(double value) + public static Frequency FromCyclesPerHour(QuantityValue value) { return new Frequency(value, FrequencyUnit.CyclePerHour); } @@ -345,7 +343,7 @@ public static Frequency FromCyclesPerHour(double value) /// /// Creates a from . /// - public static Frequency FromCyclesPerMinute(double value) + public static Frequency FromCyclesPerMinute(QuantityValue value) { return new Frequency(value, FrequencyUnit.CyclePerMinute); } @@ -353,7 +351,7 @@ public static Frequency FromCyclesPerMinute(double value) /// /// Creates a from . /// - public static Frequency FromGigahertz(double value) + public static Frequency FromGigahertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Gigahertz); } @@ -361,7 +359,7 @@ public static Frequency FromGigahertz(double value) /// /// Creates a from . /// - public static Frequency FromHertz(double value) + public static Frequency FromHertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Hertz); } @@ -369,7 +367,7 @@ public static Frequency FromHertz(double value) /// /// Creates a from . /// - public static Frequency FromKilohertz(double value) + public static Frequency FromKilohertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Kilohertz); } @@ -377,7 +375,7 @@ public static Frequency FromKilohertz(double value) /// /// Creates a from . /// - public static Frequency FromMegahertz(double value) + public static Frequency FromMegahertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Megahertz); } @@ -385,7 +383,7 @@ public static Frequency FromMegahertz(double value) /// /// Creates a from . /// - public static Frequency FromMicrohertz(double value) + public static Frequency FromMicrohertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Microhertz); } @@ -393,7 +391,7 @@ public static Frequency FromMicrohertz(double value) /// /// Creates a from . /// - public static Frequency FromMillihertz(double value) + public static Frequency FromMillihertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Millihertz); } @@ -401,7 +399,7 @@ public static Frequency FromMillihertz(double value) /// /// Creates a from . /// - public static Frequency FromPerSecond(double value) + public static Frequency FromPerSecond(QuantityValue value) { return new Frequency(value, FrequencyUnit.PerSecond); } @@ -409,7 +407,7 @@ public static Frequency FromPerSecond(double value) /// /// Creates a from . /// - public static Frequency FromRadiansPerSecond(double value) + public static Frequency FromRadiansPerSecond(QuantityValue value) { return new Frequency(value, FrequencyUnit.RadianPerSecond); } @@ -417,7 +415,7 @@ public static Frequency FromRadiansPerSecond(double value) /// /// Creates a from . /// - public static Frequency FromTerahertz(double value) + public static Frequency FromTerahertz(QuantityValue value) { return new Frequency(value, FrequencyUnit.Terahertz); } @@ -428,7 +426,7 @@ public static Frequency FromTerahertz(double value) /// Value to convert from. /// Unit to convert from. /// Frequency unit value. - public static Frequency From(double value, FrequencyUnit fromUnit) + public static Frequency From(QuantityValue value, FrequencyUnit fromUnit) { return new Frequency(value, fromUnit); } @@ -600,25 +598,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ } /// Get from multiplying value and . - public static Frequency operator *(double left, Frequency right) + public static Frequency operator *(QuantityValue left, Frequency right) { return new Frequency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Frequency operator *(Frequency left, double right) + public static Frequency operator *(Frequency left, QuantityValue right) { return new Frequency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Frequency operator /(Frequency left, double right) + public static Frequency operator /(Frequency left, QuantityValue right) { return new Frequency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Frequency left, Frequency right) + public static QuantityValue operator /(Frequency left, Frequency right) { return left.Hertz / right.Hertz; } @@ -661,27 +659,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Frequency left, Frequency right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Frequency other, Frequency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Frequency left, Frequency right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Frequency otherQuantity)) @@ -691,15 +682,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Frequency other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -782,10 +770,10 @@ public bool Equals(Frequency other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -802,7 +790,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Frequency other, Frequency tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -815,7 +803,12 @@ public bool Equals(Frequency other, Frequency tolerance) /// A hash code for the current Frequency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -826,7 +819,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FrequencyUnit unit) + public QuantityValue As(FrequencyUnit unit) { if (Unit == unit) return Value; @@ -835,7 +828,7 @@ public double As(FrequencyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -850,7 +843,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); @@ -917,31 +910,31 @@ private bool TryToUnit(FrequencyUnit unit, [NotNullWhen(true)] out Frequency? co { // FrequencyUnit -> BaseUnit (FrequencyUnit.BeatPerMinute, FrequencyUnit.Hertz) => new Frequency(_value / 60, FrequencyUnit.Hertz), - (FrequencyUnit.BUnit, FrequencyUnit.Hertz) => new Frequency(Math.Sqrt(_value * 1e3), FrequencyUnit.Hertz), + (FrequencyUnit.BUnit, FrequencyUnit.Hertz) => new Frequency(QuantityValue.FromDoubleRounded(Math.Sqrt((_value * 1000).ToDouble())), FrequencyUnit.Hertz), (FrequencyUnit.CyclePerHour, FrequencyUnit.Hertz) => new Frequency(_value / 3600, FrequencyUnit.Hertz), (FrequencyUnit.CyclePerMinute, FrequencyUnit.Hertz) => new Frequency(_value / 60, FrequencyUnit.Hertz), - (FrequencyUnit.Gigahertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e9d, FrequencyUnit.Hertz), - (FrequencyUnit.Kilohertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e3d, FrequencyUnit.Hertz), - (FrequencyUnit.Megahertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e6d, FrequencyUnit.Hertz), - (FrequencyUnit.Microhertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e-6d, FrequencyUnit.Hertz), - (FrequencyUnit.Millihertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e-3d, FrequencyUnit.Hertz), + (FrequencyUnit.Gigahertz, FrequencyUnit.Hertz) => new Frequency(_value * 1000000000, FrequencyUnit.Hertz), + (FrequencyUnit.Kilohertz, FrequencyUnit.Hertz) => new Frequency(_value * 1000, FrequencyUnit.Hertz), + (FrequencyUnit.Megahertz, FrequencyUnit.Hertz) => new Frequency(_value * 1000000, FrequencyUnit.Hertz), + (FrequencyUnit.Microhertz, FrequencyUnit.Hertz) => new Frequency(_value / 1000000, FrequencyUnit.Hertz), + (FrequencyUnit.Millihertz, FrequencyUnit.Hertz) => new Frequency(_value / 1000, FrequencyUnit.Hertz), (FrequencyUnit.PerSecond, FrequencyUnit.Hertz) => new Frequency(_value, FrequencyUnit.Hertz), - (FrequencyUnit.RadianPerSecond, FrequencyUnit.Hertz) => new Frequency(_value / 6.2831853072, FrequencyUnit.Hertz), - (FrequencyUnit.Terahertz, FrequencyUnit.Hertz) => new Frequency((_value) * 1e12d, FrequencyUnit.Hertz), + (FrequencyUnit.RadianPerSecond, FrequencyUnit.Hertz) => new Frequency(_value * new QuantityValue(625000000, 3926990817, false), FrequencyUnit.Hertz), + (FrequencyUnit.Terahertz, FrequencyUnit.Hertz) => new Frequency(_value * 1000000000000, FrequencyUnit.Hertz), // BaseUnit -> FrequencyUnit (FrequencyUnit.Hertz, FrequencyUnit.BeatPerMinute) => new Frequency(_value * 60, FrequencyUnit.BeatPerMinute), - (FrequencyUnit.Hertz, FrequencyUnit.BUnit) => new Frequency(_value * _value * 1e-3, FrequencyUnit.BUnit), + (FrequencyUnit.Hertz, FrequencyUnit.BUnit) => new Frequency((_value ^ 2) / 1000, FrequencyUnit.BUnit), (FrequencyUnit.Hertz, FrequencyUnit.CyclePerHour) => new Frequency(_value * 3600, FrequencyUnit.CyclePerHour), (FrequencyUnit.Hertz, FrequencyUnit.CyclePerMinute) => new Frequency(_value * 60, FrequencyUnit.CyclePerMinute), - (FrequencyUnit.Hertz, FrequencyUnit.Gigahertz) => new Frequency((_value) / 1e9d, FrequencyUnit.Gigahertz), - (FrequencyUnit.Hertz, FrequencyUnit.Kilohertz) => new Frequency((_value) / 1e3d, FrequencyUnit.Kilohertz), - (FrequencyUnit.Hertz, FrequencyUnit.Megahertz) => new Frequency((_value) / 1e6d, FrequencyUnit.Megahertz), - (FrequencyUnit.Hertz, FrequencyUnit.Microhertz) => new Frequency((_value) / 1e-6d, FrequencyUnit.Microhertz), - (FrequencyUnit.Hertz, FrequencyUnit.Millihertz) => new Frequency((_value) / 1e-3d, FrequencyUnit.Millihertz), + (FrequencyUnit.Hertz, FrequencyUnit.Gigahertz) => new Frequency(_value / 1000000000, FrequencyUnit.Gigahertz), + (FrequencyUnit.Hertz, FrequencyUnit.Kilohertz) => new Frequency(_value / 1000, FrequencyUnit.Kilohertz), + (FrequencyUnit.Hertz, FrequencyUnit.Megahertz) => new Frequency(_value / 1000000, FrequencyUnit.Megahertz), + (FrequencyUnit.Hertz, FrequencyUnit.Microhertz) => new Frequency(_value * 1000000, FrequencyUnit.Microhertz), + (FrequencyUnit.Hertz, FrequencyUnit.Millihertz) => new Frequency(_value * 1000, FrequencyUnit.Millihertz), (FrequencyUnit.Hertz, FrequencyUnit.PerSecond) => new Frequency(_value, FrequencyUnit.PerSecond), - (FrequencyUnit.Hertz, FrequencyUnit.RadianPerSecond) => new Frequency(_value * 6.2831853072, FrequencyUnit.RadianPerSecond), - (FrequencyUnit.Hertz, FrequencyUnit.Terahertz) => new Frequency((_value) / 1e12d, FrequencyUnit.Terahertz), + (FrequencyUnit.Hertz, FrequencyUnit.RadianPerSecond) => new Frequency(_value * new QuantityValue(3926990817, 625000000, false), FrequencyUnit.RadianPerSecond), + (FrequencyUnit.Hertz, FrequencyUnit.Terahertz) => new Frequency(_value / 1000000000000, FrequencyUnit.Terahertz), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index fb92ff7a00..8c3d64fde8 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,7 +85,7 @@ static FuelEfficiency() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public FuelEfficiency(double value, FuelEfficiencyUnit unit) + public FuelEfficiency(QuantityValue value, FuelEfficiencyUnit unit) { _value = value; _unit = unit; @@ -98,7 +99,7 @@ public FuelEfficiency(double value, FuelEfficiencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public FuelEfficiency(double value, UnitSystem unitSystem) + public FuelEfficiency(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -149,10 +150,10 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,22 +178,22 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilometersPerLiter => As(FuelEfficiencyUnit.KilometerPerLiter); + public QuantityValue KilometersPerLiter => As(FuelEfficiencyUnit.KilometerPerLiter); /// /// Gets a value of this quantity converted into /// - public double LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); + public QuantityValue LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); /// /// Gets a value of this quantity converted into /// - public double MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); + public QuantityValue MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); /// /// Gets a value of this quantity converted into /// - public double MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); + public QuantityValue MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); #endregion @@ -246,7 +247,7 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static FuelEfficiency FromKilometersPerLiter(double value) + public static FuelEfficiency FromKilometersPerLiter(QuantityValue value) { return new FuelEfficiency(value, FuelEfficiencyUnit.KilometerPerLiter); } @@ -254,7 +255,7 @@ public static FuelEfficiency FromKilometersPerLiter(double value) /// /// Creates a from . /// - public static FuelEfficiency FromLitersPer100Kilometers(double value) + public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue value) { return new FuelEfficiency(value, FuelEfficiencyUnit.LiterPer100Kilometers); } @@ -262,7 +263,7 @@ public static FuelEfficiency FromLitersPer100Kilometers(double value) /// /// Creates a from . /// - public static FuelEfficiency FromMilesPerUkGallon(double value) + public static FuelEfficiency FromMilesPerUkGallon(QuantityValue value) { return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUkGallon); } @@ -270,7 +271,7 @@ public static FuelEfficiency FromMilesPerUkGallon(double value) /// /// Creates a from . /// - public static FuelEfficiency FromMilesPerUsGallon(double value) + public static FuelEfficiency FromMilesPerUsGallon(QuantityValue value) { return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUsGallon); } @@ -281,7 +282,7 @@ public static FuelEfficiency FromMilesPerUsGallon(double value) /// Value to convert from. /// Unit to convert from. /// FuelEfficiency unit value. - public static FuelEfficiency From(double value, FuelEfficiencyUnit fromUnit) + public static FuelEfficiency From(QuantityValue value, FuelEfficiencyUnit fromUnit) { return new FuelEfficiency(value, fromUnit); } @@ -453,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE } /// Get from multiplying value and . - public static FuelEfficiency operator *(double left, FuelEfficiency right) + public static FuelEfficiency operator *(QuantityValue left, FuelEfficiency right) { return new FuelEfficiency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static FuelEfficiency operator *(FuelEfficiency left, double right) + public static FuelEfficiency operator *(FuelEfficiency left, QuantityValue right) { return new FuelEfficiency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static FuelEfficiency operator /(FuelEfficiency left, double right) + public static FuelEfficiency operator /(FuelEfficiency left, QuantityValue right) { return new FuelEfficiency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(FuelEfficiency left, FuelEfficiency right) + public static QuantityValue operator /(FuelEfficiency left, FuelEfficiency right) { return left.LitersPer100Kilometers / right.LitersPer100Kilometers; } @@ -504,27 +505,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(FuelEfficiency left, FuelEfficiency right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(FuelEfficiency other, FuelEfficiency tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(FuelEfficiency left, FuelEfficiency right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is FuelEfficiency otherQuantity)) @@ -534,15 +528,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(FuelEfficiency other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -625,10 +616,10 @@ public bool Equals(FuelEfficiency other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -645,7 +636,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(FuelEfficiency other, FuelEfficiency tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -658,7 +649,12 @@ public bool Equals(FuelEfficiency other, FuelEfficiency tolerance) /// A hash code for the current FuelEfficiency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -669,7 +665,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FuelEfficiencyUnit unit) + public QuantityValue As(FuelEfficiencyUnit unit) { if (Unit == unit) return Value; @@ -678,7 +674,7 @@ public double As(FuelEfficiencyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -693,7 +689,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); @@ -759,14 +755,14 @@ private bool TryToUnit(FuelEfficiencyUnit unit, [NotNullWhen(true)] out FuelEffi FuelEfficiency? convertedOrNull = (Unit, unit) switch { // FuelEfficiencyUnit -> BaseUnit - (FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency(100 / _value, FuelEfficiencyUnit.LiterPer100Kilometers), - (FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency((100 * 4.54609188) / (1.609344 * _value), FuelEfficiencyUnit.LiterPer100Kilometers), - (FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency((100 * 3.785411784) / (1.609344 * _value), FuelEfficiencyUnit.LiterPer100Kilometers), + (FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency((_value ^ -1) * 100, FuelEfficiencyUnit.LiterPer100Kilometers), + (FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency((_value ^ -1) * new QuantityValue(1148003, 4064, false), FuelEfficiencyUnit.LiterPer100Kilometers), + (FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiencyUnit.LiterPer100Kilometers) => new FuelEfficiency((_value ^ -1) * new QuantityValue(112903, 480, false), FuelEfficiencyUnit.LiterPer100Kilometers), // BaseUnit -> FuelEfficiencyUnit - (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.KilometerPerLiter) => new FuelEfficiency(100 / _value, FuelEfficiencyUnit.KilometerPerLiter), - (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUkGallon) => new FuelEfficiency((100 * 4.54609188) / (1.609344 * _value), FuelEfficiencyUnit.MilePerUkGallon), - (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUsGallon) => new FuelEfficiency((100 * 3.785411784) / (1.609344 * _value), FuelEfficiencyUnit.MilePerUsGallon), + (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.KilometerPerLiter) => new FuelEfficiency((_value ^ -1) * 100, FuelEfficiencyUnit.KilometerPerLiter), + (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUkGallon) => new FuelEfficiency((_value ^ -1) * new QuantityValue(1148003, 4064, false), FuelEfficiencyUnit.MilePerUkGallon), + (FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUsGallon) => new FuelEfficiency((_value ^ -1) * new QuantityValue(112903, 480, false), FuelEfficiencyUnit.MilePerUsGallon), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 06470bb152..bb1bc776bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -101,7 +99,7 @@ static HeatFlux() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public HeatFlux(double value, HeatFluxUnit unit) + public HeatFlux(QuantityValue value, HeatFluxUnit unit) { _value = value; _unit = unit; @@ -115,7 +113,7 @@ public HeatFlux(double value, HeatFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatFlux(double value, UnitSystem unitSystem) + public HeatFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -166,10 +164,10 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,92 +192,92 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); + public QuantityValue BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); /// /// Gets a value of this quantity converted into /// - public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); + public QuantityValue BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); /// /// Gets a value of this quantity converted into /// - public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); + public QuantityValue BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); /// /// Gets a value of this quantity converted into /// - public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); + public QuantityValue BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); /// /// Gets a value of this quantity converted into /// - public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); + public QuantityValue CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); + public QuantityValue CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); + public QuantityValue DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); + public QuantityValue KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + public QuantityValue KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); + public QuantityValue KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); + public QuantityValue MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); + public QuantityValue MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); + public QuantityValue NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); + public QuantityValue PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); /// /// Gets a value of this quantity converted into /// - public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); + public QuantityValue PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); + public QuantityValue WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); + public QuantityValue WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); + public QuantityValue WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); #endregion @@ -361,7 +359,7 @@ public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static HeatFlux FromBtusPerHourSquareFoot(double value) + public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot); } @@ -369,7 +367,7 @@ public static HeatFlux FromBtusPerHourSquareFoot(double value) /// /// Creates a from . /// - public static HeatFlux FromBtusPerMinuteSquareFoot(double value) + public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot); } @@ -377,7 +375,7 @@ public static HeatFlux FromBtusPerMinuteSquareFoot(double value) /// /// Creates a from . /// - public static HeatFlux FromBtusPerSecondSquareFoot(double value) + public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot); } @@ -385,7 +383,7 @@ public static HeatFlux FromBtusPerSecondSquareFoot(double value) /// /// Creates a from . /// - public static HeatFlux FromBtusPerSecondSquareInch(double value) + public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch); } @@ -393,7 +391,7 @@ public static HeatFlux FromBtusPerSecondSquareInch(double value) /// /// Creates a from . /// - public static HeatFlux FromCaloriesPerSecondSquareCentimeter(double value) + public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter); } @@ -401,7 +399,7 @@ public static HeatFlux FromCaloriesPerSecondSquareCentimeter(double value) /// /// Creates a from . /// - public static HeatFlux FromCentiwattsPerSquareMeter(double value) + public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter); } @@ -409,7 +407,7 @@ public static HeatFlux FromCentiwattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromDeciwattsPerSquareMeter(double value) + public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter); } @@ -417,7 +415,7 @@ public static HeatFlux FromDeciwattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromKilocaloriesPerHourSquareMeter(double value) + public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter); } @@ -425,7 +423,7 @@ public static HeatFlux FromKilocaloriesPerHourSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(double value) + public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); } @@ -433,7 +431,7 @@ public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(double value) /// /// Creates a from . /// - public static HeatFlux FromKilowattsPerSquareMeter(double value) + public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter); } @@ -441,7 +439,7 @@ public static HeatFlux FromKilowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromMicrowattsPerSquareMeter(double value) + public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter); } @@ -449,7 +447,7 @@ public static HeatFlux FromMicrowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromMilliwattsPerSquareMeter(double value) + public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter); } @@ -457,7 +455,7 @@ public static HeatFlux FromMilliwattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromNanowattsPerSquareMeter(double value) + public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter); } @@ -465,7 +463,7 @@ public static HeatFlux FromNanowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static HeatFlux FromPoundsForcePerFootSecond(double value) + public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond); } @@ -473,7 +471,7 @@ public static HeatFlux FromPoundsForcePerFootSecond(double value) /// /// Creates a from . /// - public static HeatFlux FromPoundsPerSecondCubed(double value) + public static HeatFlux FromPoundsPerSecondCubed(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed); } @@ -481,7 +479,7 @@ public static HeatFlux FromPoundsPerSecondCubed(double value) /// /// Creates a from . /// - public static HeatFlux FromWattsPerSquareFoot(double value) + public static HeatFlux FromWattsPerSquareFoot(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot); } @@ -489,7 +487,7 @@ public static HeatFlux FromWattsPerSquareFoot(double value) /// /// Creates a from . /// - public static HeatFlux FromWattsPerSquareInch(double value) + public static HeatFlux FromWattsPerSquareInch(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch); } @@ -497,7 +495,7 @@ public static HeatFlux FromWattsPerSquareInch(double value) /// /// Creates a from . /// - public static HeatFlux FromWattsPerSquareMeter(double value) + public static HeatFlux FromWattsPerSquareMeter(QuantityValue value) { return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter); } @@ -508,7 +506,7 @@ public static HeatFlux FromWattsPerSquareMeter(double value) /// Value to convert from. /// Unit to convert from. /// HeatFlux unit value. - public static HeatFlux From(double value, HeatFluxUnit fromUnit) + public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit) { return new HeatFlux(value, fromUnit); } @@ -680,25 +678,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF } /// Get from multiplying value and . - public static HeatFlux operator *(double left, HeatFlux right) + public static HeatFlux operator *(QuantityValue left, HeatFlux right) { return new HeatFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatFlux operator *(HeatFlux left, double right) + public static HeatFlux operator *(HeatFlux left, QuantityValue right) { return new HeatFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatFlux operator /(HeatFlux left, double right) + public static HeatFlux operator /(HeatFlux left, QuantityValue right) { return new HeatFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(HeatFlux left, HeatFlux right) + public static QuantityValue operator /(HeatFlux left, HeatFlux right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -741,27 +739,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(HeatFlux left, HeatFlux right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatFlux other, HeatFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(HeatFlux left, HeatFlux right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is HeatFlux otherQuantity)) @@ -771,15 +762,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(HeatFlux other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -862,10 +850,10 @@ public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -882,7 +870,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(HeatFlux other, HeatFlux tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -895,7 +883,12 @@ public bool Equals(HeatFlux other, HeatFlux tolerance) /// A hash code for the current HeatFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -906,7 +899,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatFluxUnit unit) + public QuantityValue As(HeatFluxUnit unit) { if (Unit == unit) return Value; @@ -915,7 +908,7 @@ public double As(HeatFluxUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -930,7 +923,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); @@ -996,42 +989,42 @@ private bool TryToUnit(HeatFluxUnit unit, [NotNullWhen(true)] out HeatFlux? conv HeatFlux? convertedOrNull = (Unit, unit) switch { // HeatFluxUnit -> BaseUnit - (HeatFluxUnit.BtuPerHourSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 3.15459075, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.89275445e2, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.BtuPerSecondSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.13565267e4, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.BtuPerSecondSquareInch, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.63533984e6, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 4.1868e4, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.CentiwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e-2d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.DeciwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e-1d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.163, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value * 4.1868e4) * 1e3d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.KilowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e3d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.MicrowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e-6d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.MilliwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e-3d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.NanowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux((_value) * 1e-9d, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.PoundForcePerFootSecond, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.459390293720636e1, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.PoundPerSecondCubed, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 4.5359237e-1, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.WattPerSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.07639e1, HeatFluxUnit.WattPerSquareMeter), - (HeatFluxUnit.WattPerSquareInch, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1.5500031e3, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.BtuPerHourSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(12618363, 4000000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(37855089, 200000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.BtuPerSecondSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(113565267, 10000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.BtuPerSecondSquareInch, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(40883496, 25, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 41868, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.CentiwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value / 100, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.DeciwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value / 10, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(1163, 1000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 41868000, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.KilowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * 1000, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.MicrowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value / 1000000, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.MilliwattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value / 1000, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.NanowattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value / 1000000000, HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.PoundForcePerFootSecond, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(364847573430159, 25000000000000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.PoundPerSecondCubed, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(45359237, 100000000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.WattPerSquareFoot, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(107639, 10000, false), HeatFluxUnit.WattPerSquareMeter), + (HeatFluxUnit.WattPerSquareInch, HeatFluxUnit.WattPerSquareMeter) => new HeatFlux(_value * new QuantityValue(15500031, 10000, false), HeatFluxUnit.WattPerSquareMeter), // BaseUnit -> HeatFluxUnit - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerHourSquareFoot) => new HeatFlux(_value / 3.15459075, HeatFluxUnit.BtuPerHourSquareFoot), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerMinuteSquareFoot) => new HeatFlux(_value / 1.89275445e2, HeatFluxUnit.BtuPerMinuteSquareFoot), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerSecondSquareFoot) => new HeatFlux(_value / 1.13565267e4, HeatFluxUnit.BtuPerSecondSquareFoot), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerSecondSquareInch) => new HeatFlux(_value / 1.63533984e6, HeatFluxUnit.BtuPerSecondSquareInch), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.CaloriePerSecondSquareCentimeter) => new HeatFlux(_value / 4.1868e4, HeatFluxUnit.CaloriePerSecondSquareCentimeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.CentiwattPerSquareMeter) => new HeatFlux((_value) / 1e-2d, HeatFluxUnit.CentiwattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.DeciwattPerSquareMeter) => new HeatFlux((_value) / 1e-1d, HeatFluxUnit.DeciwattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilocaloriePerHourSquareMeter) => new HeatFlux(_value / 1.163, HeatFluxUnit.KilocaloriePerHourSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter) => new HeatFlux((_value / 4.1868e4) / 1e3d, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilowattPerSquareMeter) => new HeatFlux((_value) / 1e3d, HeatFluxUnit.KilowattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.MicrowattPerSquareMeter) => new HeatFlux((_value) / 1e-6d, HeatFluxUnit.MicrowattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.MilliwattPerSquareMeter) => new HeatFlux((_value) / 1e-3d, HeatFluxUnit.MilliwattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.NanowattPerSquareMeter) => new HeatFlux((_value) / 1e-9d, HeatFluxUnit.NanowattPerSquareMeter), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.PoundForcePerFootSecond) => new HeatFlux(_value / 1.459390293720636e1, HeatFluxUnit.PoundForcePerFootSecond), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.PoundPerSecondCubed) => new HeatFlux(_value / 4.5359237e-1, HeatFluxUnit.PoundPerSecondCubed), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareFoot) => new HeatFlux(_value / 1.07639e1, HeatFluxUnit.WattPerSquareFoot), - (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareInch) => new HeatFlux(_value / 1.5500031e3, HeatFluxUnit.WattPerSquareInch), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerHourSquareFoot) => new HeatFlux(_value * new QuantityValue(4000000, 12618363, false), HeatFluxUnit.BtuPerHourSquareFoot), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerMinuteSquareFoot) => new HeatFlux(_value * new QuantityValue(200000, 37855089, false), HeatFluxUnit.BtuPerMinuteSquareFoot), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerSecondSquareFoot) => new HeatFlux(_value * new QuantityValue(10000, 113565267, false), HeatFluxUnit.BtuPerSecondSquareFoot), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.BtuPerSecondSquareInch) => new HeatFlux(_value * new QuantityValue(25, 40883496, false), HeatFluxUnit.BtuPerSecondSquareInch), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.CaloriePerSecondSquareCentimeter) => new HeatFlux(_value / 41868, HeatFluxUnit.CaloriePerSecondSquareCentimeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.CentiwattPerSquareMeter) => new HeatFlux(_value * 100, HeatFluxUnit.CentiwattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.DeciwattPerSquareMeter) => new HeatFlux(_value * 10, HeatFluxUnit.DeciwattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilocaloriePerHourSquareMeter) => new HeatFlux(_value * new QuantityValue(1000, 1163, false), HeatFluxUnit.KilocaloriePerHourSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter) => new HeatFlux(_value / 41868000, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.KilowattPerSquareMeter) => new HeatFlux(_value / 1000, HeatFluxUnit.KilowattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.MicrowattPerSquareMeter) => new HeatFlux(_value * 1000000, HeatFluxUnit.MicrowattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.MilliwattPerSquareMeter) => new HeatFlux(_value * 1000, HeatFluxUnit.MilliwattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.NanowattPerSquareMeter) => new HeatFlux(_value * 1000000000, HeatFluxUnit.NanowattPerSquareMeter), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.PoundForcePerFootSecond) => new HeatFlux(_value * new QuantityValue(25000000000000, 364847573430159, false), HeatFluxUnit.PoundForcePerFootSecond), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.PoundPerSecondCubed) => new HeatFlux(_value * new QuantityValue(100000000, 45359237, false), HeatFluxUnit.PoundPerSecondCubed), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareFoot) => new HeatFlux(_value * new QuantityValue(10000, 107639, false), HeatFluxUnit.WattPerSquareFoot), + (HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareInch) => new HeatFlux(_value * new QuantityValue(10000, 15500031, false), HeatFluxUnit.WattPerSquareInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 89e37c750e..2583772282 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,7 +83,7 @@ static HeatTransferCoefficient() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) + public HeatTransferCoefficient(QuantityValue value, HeatTransferCoefficientUnit unit) { _value = value; _unit = unit; @@ -96,7 +97,7 @@ public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatTransferCoefficient(double value, UnitSystem unitSystem) + public HeatTransferCoefficient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -147,10 +148,10 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -175,27 +176,27 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtusPerHourSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit); + public QuantityValue BtusPerHourSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double CaloriesPerHourSquareMeterDegreeCelsius => As(HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius); + public QuantityValue CaloriesPerHourSquareMeterDegreeCelsius => As(HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerHourSquareMeterDegreeCelsius => As(HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius); + public QuantityValue KilocaloriesPerHourSquareMeterDegreeCelsius => As(HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + public QuantityValue WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + public QuantityValue WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); #endregion @@ -251,7 +252,7 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatPr /// /// Creates a from . /// - public static HeatTransferCoefficient FromBtusPerHourSquareFootDegreeFahrenheit(double value) + public static HeatTransferCoefficient FromBtusPerHourSquareFootDegreeFahrenheit(QuantityValue value) { return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit); } @@ -259,7 +260,7 @@ public static HeatTransferCoefficient FromBtusPerHourSquareFootDegreeFahrenheit( /// /// Creates a from . /// - public static HeatTransferCoefficient FromCaloriesPerHourSquareMeterDegreeCelsius(double value) + public static HeatTransferCoefficient FromCaloriesPerHourSquareMeterDegreeCelsius(QuantityValue value) { return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius); } @@ -267,7 +268,7 @@ public static HeatTransferCoefficient FromCaloriesPerHourSquareMeterDegreeCelsiu /// /// Creates a from . /// - public static HeatTransferCoefficient FromKilocaloriesPerHourSquareMeterDegreeCelsius(double value) + public static HeatTransferCoefficient FromKilocaloriesPerHourSquareMeterDegreeCelsius(QuantityValue value) { return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius); } @@ -275,7 +276,7 @@ public static HeatTransferCoefficient FromKilocaloriesPerHourSquareMeterDegreeCe /// /// Creates a from . /// - public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(double value) + public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityValue value) { return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); } @@ -283,7 +284,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(double valu /// /// Creates a from . /// - public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(double value) + public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValue value) { return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); } @@ -294,7 +295,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(double value /// Value to convert from. /// Unit to convert from. /// HeatTransferCoefficient unit value. - public static HeatTransferCoefficient From(double value, HeatTransferCoefficientUnit fromUnit) + public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoefficientUnit fromUnit) { return new HeatTransferCoefficient(value, fromUnit); } @@ -466,25 +467,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(double left, HeatTransferCoefficient right) + public static HeatTransferCoefficient operator *(QuantityValue left, HeatTransferCoefficient right) { return new HeatTransferCoefficient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, double right) + public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, QuantityValue right) { return new HeatTransferCoefficient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, double right) + public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, QuantityValue right) { return new HeatTransferCoefficient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static QuantityValue operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.WattsPerSquareMeterKelvin / right.WattsPerSquareMeterKelvin; } @@ -517,27 +518,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is HeatTransferCoefficient otherQuantity)) @@ -547,15 +541,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(HeatTransferCoefficient other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -638,10 +629,10 @@ public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -658,7 +649,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -671,7 +662,12 @@ public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient tolera /// A hash code for the current HeatTransferCoefficient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -682,7 +678,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatTransferCoefficientUnit unit) + public QuantityValue As(HeatTransferCoefficientUnit unit) { if (Unit == unit) return Value; @@ -691,7 +687,7 @@ public double As(HeatTransferCoefficientUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -706,7 +702,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); @@ -772,15 +768,15 @@ private bool TryToUnit(HeatTransferCoefficientUnit unit, [NotNullWhen(true)] out HeatTransferCoefficient? convertedOrNull = (Unit, unit) switch { // HeatTransferCoefficientUnit -> BaseUnit - (HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(_value * 5.6782633411134878, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), - (HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient((_value * 4.1868) / 3600, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), - (HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(((_value * 4.1868) / 3600) * 1e3d, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), + (HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(_value * new QuantityValue(28391316705567439, 5000000000000000, false), HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), + (HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(_value * new QuantityValue(1163, 1000000, false), HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), + (HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(_value * new QuantityValue(1163, 1000, false), HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), (HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin) => new HeatTransferCoefficient(_value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), // BaseUnit -> HeatTransferCoefficientUnit - (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit) => new HeatTransferCoefficient(_value / 5.6782633411134878, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit), - (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius) => new HeatTransferCoefficient((_value / 4.1868) * 3600, HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius), - (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius) => new HeatTransferCoefficient(((_value / 4.1868) * 3600) / 1e3d, HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius), + (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit) => new HeatTransferCoefficient(_value * new QuantityValue(5000000000000000, 28391316705567439, false), HeatTransferCoefficientUnit.BtuPerHourSquareFootDegreeFahrenheit), + (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius) => new HeatTransferCoefficient(_value * new QuantityValue(1000000, 1163, false), HeatTransferCoefficientUnit.CaloriePerHourSquareMeterDegreeCelsius), + (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius) => new HeatTransferCoefficient(_value * new QuantityValue(1000, 1163, false), HeatTransferCoefficientUnit.KilocaloriePerHourSquareMeterDegreeCelsius), (HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius) => new HeatTransferCoefficient(_value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius), _ => null diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index c0b6a8a421..23f0782268 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,7 +85,7 @@ static Illuminance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Illuminance(double value, IlluminanceUnit unit) + public Illuminance(QuantityValue value, IlluminanceUnit unit) { _value = value; _unit = unit; @@ -98,7 +99,7 @@ public Illuminance(double value, IlluminanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Illuminance(double value, UnitSystem unitSystem) + public Illuminance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -149,10 +150,10 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,22 +178,22 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Kilolux => As(IlluminanceUnit.Kilolux); + public QuantityValue Kilolux => As(IlluminanceUnit.Kilolux); /// /// Gets a value of this quantity converted into /// - public double Lux => As(IlluminanceUnit.Lux); + public QuantityValue Lux => As(IlluminanceUnit.Lux); /// /// Gets a value of this quantity converted into /// - public double Megalux => As(IlluminanceUnit.Megalux); + public QuantityValue Megalux => As(IlluminanceUnit.Megalux); /// /// Gets a value of this quantity converted into /// - public double Millilux => As(IlluminanceUnit.Millilux); + public QuantityValue Millilux => As(IlluminanceUnit.Millilux); #endregion @@ -246,7 +247,7 @@ public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static Illuminance FromKilolux(double value) + public static Illuminance FromKilolux(QuantityValue value) { return new Illuminance(value, IlluminanceUnit.Kilolux); } @@ -254,7 +255,7 @@ public static Illuminance FromKilolux(double value) /// /// Creates a from . /// - public static Illuminance FromLux(double value) + public static Illuminance FromLux(QuantityValue value) { return new Illuminance(value, IlluminanceUnit.Lux); } @@ -262,7 +263,7 @@ public static Illuminance FromLux(double value) /// /// Creates a from . /// - public static Illuminance FromMegalux(double value) + public static Illuminance FromMegalux(QuantityValue value) { return new Illuminance(value, IlluminanceUnit.Megalux); } @@ -270,7 +271,7 @@ public static Illuminance FromMegalux(double value) /// /// Creates a from . /// - public static Illuminance FromMillilux(double value) + public static Illuminance FromMillilux(QuantityValue value) { return new Illuminance(value, IlluminanceUnit.Millilux); } @@ -281,7 +282,7 @@ public static Illuminance FromMillilux(double value) /// Value to convert from. /// Unit to convert from. /// Illuminance unit value. - public static Illuminance From(double value, IlluminanceUnit fromUnit) + public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit) { return new Illuminance(value, fromUnit); } @@ -453,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum } /// Get from multiplying value and . - public static Illuminance operator *(double left, Illuminance right) + public static Illuminance operator *(QuantityValue left, Illuminance right) { return new Illuminance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Illuminance operator *(Illuminance left, double right) + public static Illuminance operator *(Illuminance left, QuantityValue right) { return new Illuminance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Illuminance operator /(Illuminance left, double right) + public static Illuminance operator /(Illuminance left, QuantityValue right) { return new Illuminance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Illuminance left, Illuminance right) + public static QuantityValue operator /(Illuminance left, Illuminance right) { return left.Lux / right.Lux; } @@ -504,27 +505,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Illuminance left, Illuminance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Illuminance other, Illuminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Illuminance left, Illuminance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Illuminance otherQuantity)) @@ -534,15 +528,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Illuminance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -625,10 +616,10 @@ public bool Equals(Illuminance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -645,7 +636,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Illuminance other, Illuminance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -658,7 +649,12 @@ public bool Equals(Illuminance other, Illuminance tolerance) /// A hash code for the current Illuminance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -669,7 +665,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IlluminanceUnit unit) + public QuantityValue As(IlluminanceUnit unit) { if (Unit == unit) return Value; @@ -678,7 +674,7 @@ public double As(IlluminanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -693,7 +689,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); @@ -759,14 +755,14 @@ private bool TryToUnit(IlluminanceUnit unit, [NotNullWhen(true)] out Illuminance Illuminance? convertedOrNull = (Unit, unit) switch { // IlluminanceUnit -> BaseUnit - (IlluminanceUnit.Kilolux, IlluminanceUnit.Lux) => new Illuminance((_value) * 1e3d, IlluminanceUnit.Lux), - (IlluminanceUnit.Megalux, IlluminanceUnit.Lux) => new Illuminance((_value) * 1e6d, IlluminanceUnit.Lux), - (IlluminanceUnit.Millilux, IlluminanceUnit.Lux) => new Illuminance((_value) * 1e-3d, IlluminanceUnit.Lux), + (IlluminanceUnit.Kilolux, IlluminanceUnit.Lux) => new Illuminance(_value * 1000, IlluminanceUnit.Lux), + (IlluminanceUnit.Megalux, IlluminanceUnit.Lux) => new Illuminance(_value * 1000000, IlluminanceUnit.Lux), + (IlluminanceUnit.Millilux, IlluminanceUnit.Lux) => new Illuminance(_value / 1000, IlluminanceUnit.Lux), // BaseUnit -> IlluminanceUnit - (IlluminanceUnit.Lux, IlluminanceUnit.Kilolux) => new Illuminance((_value) / 1e3d, IlluminanceUnit.Kilolux), - (IlluminanceUnit.Lux, IlluminanceUnit.Megalux) => new Illuminance((_value) / 1e6d, IlluminanceUnit.Megalux), - (IlluminanceUnit.Lux, IlluminanceUnit.Millilux) => new Illuminance((_value) / 1e-3d, IlluminanceUnit.Millilux), + (IlluminanceUnit.Lux, IlluminanceUnit.Kilolux) => new Illuminance(_value / 1000, IlluminanceUnit.Kilolux), + (IlluminanceUnit.Lux, IlluminanceUnit.Megalux) => new Illuminance(_value / 1000000, IlluminanceUnit.Megalux), + (IlluminanceUnit.Lux, IlluminanceUnit.Millilux) => new Illuminance(_value * 1000, IlluminanceUnit.Millilux), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs index 61a392c8bc..4a1b12bd61 100644 --- a/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Impulse.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -90,7 +91,7 @@ static Impulse() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Impulse(double value, ImpulseUnit unit) + public Impulse(QuantityValue value, ImpulseUnit unit) { _value = value; _unit = unit; @@ -104,7 +105,7 @@ public Impulse(double value, ImpulseUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Impulse(double value, UnitSystem unitSystem) + public Impulse(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -155,10 +156,10 @@ public Impulse(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,67 +184,67 @@ public Impulse(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentinewtonSeconds => As(ImpulseUnit.CentinewtonSecond); + public QuantityValue CentinewtonSeconds => As(ImpulseUnit.CentinewtonSecond); /// /// Gets a value of this quantity converted into /// - public double DecanewtonSeconds => As(ImpulseUnit.DecanewtonSecond); + public QuantityValue DecanewtonSeconds => As(ImpulseUnit.DecanewtonSecond); /// /// Gets a value of this quantity converted into /// - public double DecinewtonSeconds => As(ImpulseUnit.DecinewtonSecond); + public QuantityValue DecinewtonSeconds => As(ImpulseUnit.DecinewtonSecond); /// /// Gets a value of this quantity converted into /// - public double KilogramMetersPerSecond => As(ImpulseUnit.KilogramMeterPerSecond); + public QuantityValue KilogramMetersPerSecond => As(ImpulseUnit.KilogramMeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilonewtonSeconds => As(ImpulseUnit.KilonewtonSecond); + public QuantityValue KilonewtonSeconds => As(ImpulseUnit.KilonewtonSecond); /// /// Gets a value of this quantity converted into /// - public double MeganewtonSeconds => As(ImpulseUnit.MeganewtonSecond); + public QuantityValue MeganewtonSeconds => As(ImpulseUnit.MeganewtonSecond); /// /// Gets a value of this quantity converted into /// - public double MicronewtonSeconds => As(ImpulseUnit.MicronewtonSecond); + public QuantityValue MicronewtonSeconds => As(ImpulseUnit.MicronewtonSecond); /// /// Gets a value of this quantity converted into /// - public double MillinewtonSeconds => As(ImpulseUnit.MillinewtonSecond); + public QuantityValue MillinewtonSeconds => As(ImpulseUnit.MillinewtonSecond); /// /// Gets a value of this quantity converted into /// - public double NanonewtonSeconds => As(ImpulseUnit.NanonewtonSecond); + public QuantityValue NanonewtonSeconds => As(ImpulseUnit.NanonewtonSecond); /// /// Gets a value of this quantity converted into /// - public double NewtonSeconds => As(ImpulseUnit.NewtonSecond); + public QuantityValue NewtonSeconds => As(ImpulseUnit.NewtonSecond); /// /// Gets a value of this quantity converted into /// - public double PoundFeetPerSecond => As(ImpulseUnit.PoundFootPerSecond); + public QuantityValue PoundFeetPerSecond => As(ImpulseUnit.PoundFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double PoundForceSeconds => As(ImpulseUnit.PoundForceSecond); + public QuantityValue PoundForceSeconds => As(ImpulseUnit.PoundForceSecond); /// /// Gets a value of this quantity converted into /// - public double SlugFeetPerSecond => As(ImpulseUnit.SlugFootPerSecond); + public QuantityValue SlugFeetPerSecond => As(ImpulseUnit.SlugFootPerSecond); #endregion @@ -315,7 +316,7 @@ public static string GetAbbreviation(ImpulseUnit unit, IFormatProvider? provider /// /// Creates a from . /// - public static Impulse FromCentinewtonSeconds(double value) + public static Impulse FromCentinewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.CentinewtonSecond); } @@ -323,7 +324,7 @@ public static Impulse FromCentinewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromDecanewtonSeconds(double value) + public static Impulse FromDecanewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.DecanewtonSecond); } @@ -331,7 +332,7 @@ public static Impulse FromDecanewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromDecinewtonSeconds(double value) + public static Impulse FromDecinewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.DecinewtonSecond); } @@ -339,7 +340,7 @@ public static Impulse FromDecinewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromKilogramMetersPerSecond(double value) + public static Impulse FromKilogramMetersPerSecond(QuantityValue value) { return new Impulse(value, ImpulseUnit.KilogramMeterPerSecond); } @@ -347,7 +348,7 @@ public static Impulse FromKilogramMetersPerSecond(double value) /// /// Creates a from . /// - public static Impulse FromKilonewtonSeconds(double value) + public static Impulse FromKilonewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.KilonewtonSecond); } @@ -355,7 +356,7 @@ public static Impulse FromKilonewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromMeganewtonSeconds(double value) + public static Impulse FromMeganewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.MeganewtonSecond); } @@ -363,7 +364,7 @@ public static Impulse FromMeganewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromMicronewtonSeconds(double value) + public static Impulse FromMicronewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.MicronewtonSecond); } @@ -371,7 +372,7 @@ public static Impulse FromMicronewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromMillinewtonSeconds(double value) + public static Impulse FromMillinewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.MillinewtonSecond); } @@ -379,7 +380,7 @@ public static Impulse FromMillinewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromNanonewtonSeconds(double value) + public static Impulse FromNanonewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.NanonewtonSecond); } @@ -387,7 +388,7 @@ public static Impulse FromNanonewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromNewtonSeconds(double value) + public static Impulse FromNewtonSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.NewtonSecond); } @@ -395,7 +396,7 @@ public static Impulse FromNewtonSeconds(double value) /// /// Creates a from . /// - public static Impulse FromPoundFeetPerSecond(double value) + public static Impulse FromPoundFeetPerSecond(QuantityValue value) { return new Impulse(value, ImpulseUnit.PoundFootPerSecond); } @@ -403,7 +404,7 @@ public static Impulse FromPoundFeetPerSecond(double value) /// /// Creates a from . /// - public static Impulse FromPoundForceSeconds(double value) + public static Impulse FromPoundForceSeconds(QuantityValue value) { return new Impulse(value, ImpulseUnit.PoundForceSecond); } @@ -411,7 +412,7 @@ public static Impulse FromPoundForceSeconds(double value) /// /// Creates a from . /// - public static Impulse FromSlugFeetPerSecond(double value) + public static Impulse FromSlugFeetPerSecond(QuantityValue value) { return new Impulse(value, ImpulseUnit.SlugFootPerSecond); } @@ -422,7 +423,7 @@ public static Impulse FromSlugFeetPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// Impulse unit value. - public static Impulse From(double value, ImpulseUnit fromUnit) + public static Impulse From(QuantityValue value, ImpulseUnit fromUnit) { return new Impulse(value, fromUnit); } @@ -594,25 +595,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Impul } /// Get from multiplying value and . - public static Impulse operator *(double left, Impulse right) + public static Impulse operator *(QuantityValue left, Impulse right) { return new Impulse(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Impulse operator *(Impulse left, double right) + public static Impulse operator *(Impulse left, QuantityValue right) { return new Impulse(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Impulse operator /(Impulse left, double right) + public static Impulse operator /(Impulse left, QuantityValue right) { return new Impulse(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Impulse left, Impulse right) + public static QuantityValue operator /(Impulse left, Impulse right) { return left.NewtonSeconds / right.NewtonSeconds; } @@ -645,27 +646,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Impul return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Impulse left, Impulse right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Impulse other, Impulse tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Impulse left, Impulse right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Impulse otherQuantity)) @@ -675,15 +669,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Impulse other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -766,10 +757,10 @@ public bool Equals(Impulse other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -786,7 +777,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Impulse other, Impulse tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -799,7 +790,12 @@ public bool Equals(Impulse other, Impulse tolerance) /// A hash code for the current Impulse. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -810,7 +806,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ImpulseUnit unit) + public QuantityValue As(ImpulseUnit unit) { if (Unit == unit) return Value; @@ -819,7 +815,7 @@ public double As(ImpulseUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -834,7 +830,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ImpulseUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ImpulseUnit)} is supported.", nameof(unit)); @@ -900,32 +896,32 @@ private bool TryToUnit(ImpulseUnit unit, [NotNullWhen(true)] out Impulse? conver Impulse? convertedOrNull = (Unit, unit) switch { // ImpulseUnit -> BaseUnit - (ImpulseUnit.CentinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e-2d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.DecanewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e1d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.DecinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e-1d, ImpulseUnit.NewtonSecond), + (ImpulseUnit.CentinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 100, ImpulseUnit.NewtonSecond), + (ImpulseUnit.DecanewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * 10, ImpulseUnit.NewtonSecond), + (ImpulseUnit.DecinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 10, ImpulseUnit.NewtonSecond), (ImpulseUnit.KilogramMeterPerSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value, ImpulseUnit.NewtonSecond), - (ImpulseUnit.KilonewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e3d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.MeganewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e6d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.MicronewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e-6d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.MillinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e-3d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.NanonewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse((_value) * 1e-9d, ImpulseUnit.NewtonSecond), - (ImpulseUnit.PoundFootPerSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 7.230657989877, ImpulseUnit.NewtonSecond), - (ImpulseUnit.PoundForceSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 0.2248089430997, ImpulseUnit.NewtonSecond), - (ImpulseUnit.SlugFootPerSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 0.224735720691, ImpulseUnit.NewtonSecond), + (ImpulseUnit.KilonewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * 1000, ImpulseUnit.NewtonSecond), + (ImpulseUnit.MeganewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * 1000000, ImpulseUnit.NewtonSecond), + (ImpulseUnit.MicronewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 1000000, ImpulseUnit.NewtonSecond), + (ImpulseUnit.MillinewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 1000, ImpulseUnit.NewtonSecond), + (ImpulseUnit.NanonewtonSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value / 1000000000, ImpulseUnit.NewtonSecond), + (ImpulseUnit.PoundFootPerSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * new QuantityValue(1000000000000, 7230657989877, false), ImpulseUnit.NewtonSecond), + (ImpulseUnit.PoundForceSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * new QuantityValue(10000000000000, 2248089430997, false), ImpulseUnit.NewtonSecond), + (ImpulseUnit.SlugFootPerSecond, ImpulseUnit.NewtonSecond) => new Impulse(_value * new QuantityValue(1000000000000, 224735720691, false), ImpulseUnit.NewtonSecond), // BaseUnit -> ImpulseUnit - (ImpulseUnit.NewtonSecond, ImpulseUnit.CentinewtonSecond) => new Impulse((_value) / 1e-2d, ImpulseUnit.CentinewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.DecanewtonSecond) => new Impulse((_value) / 1e1d, ImpulseUnit.DecanewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.DecinewtonSecond) => new Impulse((_value) / 1e-1d, ImpulseUnit.DecinewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.CentinewtonSecond) => new Impulse(_value * 100, ImpulseUnit.CentinewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.DecanewtonSecond) => new Impulse(_value / 10, ImpulseUnit.DecanewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.DecinewtonSecond) => new Impulse(_value * 10, ImpulseUnit.DecinewtonSecond), (ImpulseUnit.NewtonSecond, ImpulseUnit.KilogramMeterPerSecond) => new Impulse(_value, ImpulseUnit.KilogramMeterPerSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.KilonewtonSecond) => new Impulse((_value) / 1e3d, ImpulseUnit.KilonewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.MeganewtonSecond) => new Impulse((_value) / 1e6d, ImpulseUnit.MeganewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.MicronewtonSecond) => new Impulse((_value) / 1e-6d, ImpulseUnit.MicronewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.MillinewtonSecond) => new Impulse((_value) / 1e-3d, ImpulseUnit.MillinewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.NanonewtonSecond) => new Impulse((_value) / 1e-9d, ImpulseUnit.NanonewtonSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.PoundFootPerSecond) => new Impulse(_value * 7.230657989877, ImpulseUnit.PoundFootPerSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.PoundForceSecond) => new Impulse(_value * 0.2248089430997, ImpulseUnit.PoundForceSecond), - (ImpulseUnit.NewtonSecond, ImpulseUnit.SlugFootPerSecond) => new Impulse(_value * 0.224735720691, ImpulseUnit.SlugFootPerSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.KilonewtonSecond) => new Impulse(_value / 1000, ImpulseUnit.KilonewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.MeganewtonSecond) => new Impulse(_value / 1000000, ImpulseUnit.MeganewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.MicronewtonSecond) => new Impulse(_value * 1000000, ImpulseUnit.MicronewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.MillinewtonSecond) => new Impulse(_value * 1000, ImpulseUnit.MillinewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.NanonewtonSecond) => new Impulse(_value * 1000000000, ImpulseUnit.NanonewtonSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.PoundFootPerSecond) => new Impulse(_value * new QuantityValue(7230657989877, 1000000000000, false), ImpulseUnit.PoundFootPerSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.PoundForceSecond) => new Impulse(_value * new QuantityValue(2248089430997, 10000000000000, false), ImpulseUnit.PoundForceSecond), + (ImpulseUnit.NewtonSecond, ImpulseUnit.SlugFootPerSecond) => new Impulse(_value * new QuantityValue(224735720691, 1000000000000, false), ImpulseUnit.SlugFootPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index f530ebdc53..a680510396 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -103,7 +104,7 @@ static Information() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Information(double value, InformationUnit unit) + public Information(QuantityValue value, InformationUnit unit) { _value = value; _unit = unit; @@ -117,7 +118,7 @@ public Information(double value, InformationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Information(double value, UnitSystem unitSystem) + public Information(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -168,10 +169,10 @@ public Information(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -196,132 +197,132 @@ public Information(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Bits => As(InformationUnit.Bit); + public QuantityValue Bits => As(InformationUnit.Bit); /// /// Gets a value of this quantity converted into /// - public double Bytes => As(InformationUnit.Byte); + public QuantityValue Bytes => As(InformationUnit.Byte); /// /// Gets a value of this quantity converted into /// - public double Exabits => As(InformationUnit.Exabit); + public QuantityValue Exabits => As(InformationUnit.Exabit); /// /// Gets a value of this quantity converted into /// - public double Exabytes => As(InformationUnit.Exabyte); + public QuantityValue Exabytes => As(InformationUnit.Exabyte); /// /// Gets a value of this quantity converted into /// - public double Exbibits => As(InformationUnit.Exbibit); + public QuantityValue Exbibits => As(InformationUnit.Exbibit); /// /// Gets a value of this quantity converted into /// - public double Exbibytes => As(InformationUnit.Exbibyte); + public QuantityValue Exbibytes => As(InformationUnit.Exbibyte); /// /// Gets a value of this quantity converted into /// - public double Gibibits => As(InformationUnit.Gibibit); + public QuantityValue Gibibits => As(InformationUnit.Gibibit); /// /// Gets a value of this quantity converted into /// - public double Gibibytes => As(InformationUnit.Gibibyte); + public QuantityValue Gibibytes => As(InformationUnit.Gibibyte); /// /// Gets a value of this quantity converted into /// - public double Gigabits => As(InformationUnit.Gigabit); + public QuantityValue Gigabits => As(InformationUnit.Gigabit); /// /// Gets a value of this quantity converted into /// - public double Gigabytes => As(InformationUnit.Gigabyte); + public QuantityValue Gigabytes => As(InformationUnit.Gigabyte); /// /// Gets a value of this quantity converted into /// - public double Kibibits => As(InformationUnit.Kibibit); + public QuantityValue Kibibits => As(InformationUnit.Kibibit); /// /// Gets a value of this quantity converted into /// - public double Kibibytes => As(InformationUnit.Kibibyte); + public QuantityValue Kibibytes => As(InformationUnit.Kibibyte); /// /// Gets a value of this quantity converted into /// - public double Kilobits => As(InformationUnit.Kilobit); + public QuantityValue Kilobits => As(InformationUnit.Kilobit); /// /// Gets a value of this quantity converted into /// - public double Kilobytes => As(InformationUnit.Kilobyte); + public QuantityValue Kilobytes => As(InformationUnit.Kilobyte); /// /// Gets a value of this quantity converted into /// - public double Mebibits => As(InformationUnit.Mebibit); + public QuantityValue Mebibits => As(InformationUnit.Mebibit); /// /// Gets a value of this quantity converted into /// - public double Mebibytes => As(InformationUnit.Mebibyte); + public QuantityValue Mebibytes => As(InformationUnit.Mebibyte); /// /// Gets a value of this quantity converted into /// - public double Megabits => As(InformationUnit.Megabit); + public QuantityValue Megabits => As(InformationUnit.Megabit); /// /// Gets a value of this quantity converted into /// - public double Megabytes => As(InformationUnit.Megabyte); + public QuantityValue Megabytes => As(InformationUnit.Megabyte); /// /// Gets a value of this quantity converted into /// - public double Pebibits => As(InformationUnit.Pebibit); + public QuantityValue Pebibits => As(InformationUnit.Pebibit); /// /// Gets a value of this quantity converted into /// - public double Pebibytes => As(InformationUnit.Pebibyte); + public QuantityValue Pebibytes => As(InformationUnit.Pebibyte); /// /// Gets a value of this quantity converted into /// - public double Petabits => As(InformationUnit.Petabit); + public QuantityValue Petabits => As(InformationUnit.Petabit); /// /// Gets a value of this quantity converted into /// - public double Petabytes => As(InformationUnit.Petabyte); + public QuantityValue Petabytes => As(InformationUnit.Petabyte); /// /// Gets a value of this quantity converted into /// - public double Tebibits => As(InformationUnit.Tebibit); + public QuantityValue Tebibits => As(InformationUnit.Tebibit); /// /// Gets a value of this quantity converted into /// - public double Tebibytes => As(InformationUnit.Tebibyte); + public QuantityValue Tebibytes => As(InformationUnit.Tebibyte); /// /// Gets a value of this quantity converted into /// - public double Terabits => As(InformationUnit.Terabit); + public QuantityValue Terabits => As(InformationUnit.Terabit); /// /// Gets a value of this quantity converted into /// - public double Terabytes => As(InformationUnit.Terabyte); + public QuantityValue Terabytes => As(InformationUnit.Terabyte); #endregion @@ -419,7 +420,7 @@ public static string GetAbbreviation(InformationUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static Information FromBits(double value) + public static Information FromBits(QuantityValue value) { return new Information(value, InformationUnit.Bit); } @@ -427,7 +428,7 @@ public static Information FromBits(double value) /// /// Creates a from . /// - public static Information FromBytes(double value) + public static Information FromBytes(QuantityValue value) { return new Information(value, InformationUnit.Byte); } @@ -435,7 +436,7 @@ public static Information FromBytes(double value) /// /// Creates a from . /// - public static Information FromExabits(double value) + public static Information FromExabits(QuantityValue value) { return new Information(value, InformationUnit.Exabit); } @@ -443,7 +444,7 @@ public static Information FromExabits(double value) /// /// Creates a from . /// - public static Information FromExabytes(double value) + public static Information FromExabytes(QuantityValue value) { return new Information(value, InformationUnit.Exabyte); } @@ -451,7 +452,7 @@ public static Information FromExabytes(double value) /// /// Creates a from . /// - public static Information FromExbibits(double value) + public static Information FromExbibits(QuantityValue value) { return new Information(value, InformationUnit.Exbibit); } @@ -459,7 +460,7 @@ public static Information FromExbibits(double value) /// /// Creates a from . /// - public static Information FromExbibytes(double value) + public static Information FromExbibytes(QuantityValue value) { return new Information(value, InformationUnit.Exbibyte); } @@ -467,7 +468,7 @@ public static Information FromExbibytes(double value) /// /// Creates a from . /// - public static Information FromGibibits(double value) + public static Information FromGibibits(QuantityValue value) { return new Information(value, InformationUnit.Gibibit); } @@ -475,7 +476,7 @@ public static Information FromGibibits(double value) /// /// Creates a from . /// - public static Information FromGibibytes(double value) + public static Information FromGibibytes(QuantityValue value) { return new Information(value, InformationUnit.Gibibyte); } @@ -483,7 +484,7 @@ public static Information FromGibibytes(double value) /// /// Creates a from . /// - public static Information FromGigabits(double value) + public static Information FromGigabits(QuantityValue value) { return new Information(value, InformationUnit.Gigabit); } @@ -491,7 +492,7 @@ public static Information FromGigabits(double value) /// /// Creates a from . /// - public static Information FromGigabytes(double value) + public static Information FromGigabytes(QuantityValue value) { return new Information(value, InformationUnit.Gigabyte); } @@ -499,7 +500,7 @@ public static Information FromGigabytes(double value) /// /// Creates a from . /// - public static Information FromKibibits(double value) + public static Information FromKibibits(QuantityValue value) { return new Information(value, InformationUnit.Kibibit); } @@ -507,7 +508,7 @@ public static Information FromKibibits(double value) /// /// Creates a from . /// - public static Information FromKibibytes(double value) + public static Information FromKibibytes(QuantityValue value) { return new Information(value, InformationUnit.Kibibyte); } @@ -515,7 +516,7 @@ public static Information FromKibibytes(double value) /// /// Creates a from . /// - public static Information FromKilobits(double value) + public static Information FromKilobits(QuantityValue value) { return new Information(value, InformationUnit.Kilobit); } @@ -523,7 +524,7 @@ public static Information FromKilobits(double value) /// /// Creates a from . /// - public static Information FromKilobytes(double value) + public static Information FromKilobytes(QuantityValue value) { return new Information(value, InformationUnit.Kilobyte); } @@ -531,7 +532,7 @@ public static Information FromKilobytes(double value) /// /// Creates a from . /// - public static Information FromMebibits(double value) + public static Information FromMebibits(QuantityValue value) { return new Information(value, InformationUnit.Mebibit); } @@ -539,7 +540,7 @@ public static Information FromMebibits(double value) /// /// Creates a from . /// - public static Information FromMebibytes(double value) + public static Information FromMebibytes(QuantityValue value) { return new Information(value, InformationUnit.Mebibyte); } @@ -547,7 +548,7 @@ public static Information FromMebibytes(double value) /// /// Creates a from . /// - public static Information FromMegabits(double value) + public static Information FromMegabits(QuantityValue value) { return new Information(value, InformationUnit.Megabit); } @@ -555,7 +556,7 @@ public static Information FromMegabits(double value) /// /// Creates a from . /// - public static Information FromMegabytes(double value) + public static Information FromMegabytes(QuantityValue value) { return new Information(value, InformationUnit.Megabyte); } @@ -563,7 +564,7 @@ public static Information FromMegabytes(double value) /// /// Creates a from . /// - public static Information FromPebibits(double value) + public static Information FromPebibits(QuantityValue value) { return new Information(value, InformationUnit.Pebibit); } @@ -571,7 +572,7 @@ public static Information FromPebibits(double value) /// /// Creates a from . /// - public static Information FromPebibytes(double value) + public static Information FromPebibytes(QuantityValue value) { return new Information(value, InformationUnit.Pebibyte); } @@ -579,7 +580,7 @@ public static Information FromPebibytes(double value) /// /// Creates a from . /// - public static Information FromPetabits(double value) + public static Information FromPetabits(QuantityValue value) { return new Information(value, InformationUnit.Petabit); } @@ -587,7 +588,7 @@ public static Information FromPetabits(double value) /// /// Creates a from . /// - public static Information FromPetabytes(double value) + public static Information FromPetabytes(QuantityValue value) { return new Information(value, InformationUnit.Petabyte); } @@ -595,7 +596,7 @@ public static Information FromPetabytes(double value) /// /// Creates a from . /// - public static Information FromTebibits(double value) + public static Information FromTebibits(QuantityValue value) { return new Information(value, InformationUnit.Tebibit); } @@ -603,7 +604,7 @@ public static Information FromTebibits(double value) /// /// Creates a from . /// - public static Information FromTebibytes(double value) + public static Information FromTebibytes(QuantityValue value) { return new Information(value, InformationUnit.Tebibyte); } @@ -611,7 +612,7 @@ public static Information FromTebibytes(double value) /// /// Creates a from . /// - public static Information FromTerabits(double value) + public static Information FromTerabits(QuantityValue value) { return new Information(value, InformationUnit.Terabit); } @@ -619,7 +620,7 @@ public static Information FromTerabits(double value) /// /// Creates a from . /// - public static Information FromTerabytes(double value) + public static Information FromTerabytes(QuantityValue value) { return new Information(value, InformationUnit.Terabyte); } @@ -630,7 +631,7 @@ public static Information FromTerabytes(double value) /// Value to convert from. /// Unit to convert from. /// Information unit value. - public static Information From(double value, InformationUnit fromUnit) + public static Information From(QuantityValue value, InformationUnit fromUnit) { return new Information(value, fromUnit); } @@ -802,25 +803,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor } /// Get from multiplying value and . - public static Information operator *(double left, Information right) + public static Information operator *(QuantityValue left, Information right) { return new Information(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Information operator *(Information left, double right) + public static Information operator *(Information left, QuantityValue right) { return new Information(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Information operator /(Information left, double right) + public static Information operator /(Information left, QuantityValue right) { return new Information(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Information left, Information right) + public static QuantityValue operator /(Information left, Information right) { return left.Bits / right.Bits; } @@ -853,27 +854,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Information left, Information right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Information other, Information tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Information left, Information right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Information otherQuantity)) @@ -883,15 +877,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Information other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -974,10 +965,10 @@ public bool Equals(Information other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -994,7 +985,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Information other, Information tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1007,7 +998,12 @@ public bool Equals(Information other, Information tolerance) /// A hash code for the current Information. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1018,7 +1014,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) + public QuantityValue As(InformationUnit unit) { if (Unit == unit) return Value; @@ -1027,7 +1023,7 @@ public double As(InformationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1042,7 +1038,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); @@ -1109,57 +1105,57 @@ private bool TryToUnit(InformationUnit unit, [NotNullWhen(true)] out Information { // InformationUnit -> BaseUnit (InformationUnit.Byte, InformationUnit.Bit) => new Information(_value * 8, InformationUnit.Bit), - (InformationUnit.Exabit, InformationUnit.Bit) => new Information((_value) * 1e18d, InformationUnit.Bit), - (InformationUnit.Exabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e18d, InformationUnit.Bit), - (InformationUnit.Exbibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Exbibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Gibibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Gibibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Gigabit, InformationUnit.Bit) => new Information((_value) * 1e9d, InformationUnit.Bit), - (InformationUnit.Gigabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e9d, InformationUnit.Bit), - (InformationUnit.Kibibit, InformationUnit.Bit) => new Information((_value) * 1024d, InformationUnit.Bit), - (InformationUnit.Kibibyte, InformationUnit.Bit) => new Information((_value * 8) * 1024d, InformationUnit.Bit), - (InformationUnit.Kilobit, InformationUnit.Bit) => new Information((_value) * 1e3d, InformationUnit.Bit), - (InformationUnit.Kilobyte, InformationUnit.Bit) => new Information((_value * 8) * 1e3d, InformationUnit.Bit), - (InformationUnit.Mebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024), InformationUnit.Bit), - (InformationUnit.Mebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024), InformationUnit.Bit), - (InformationUnit.Megabit, InformationUnit.Bit) => new Information((_value) * 1e6d, InformationUnit.Bit), - (InformationUnit.Megabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e6d, InformationUnit.Bit), - (InformationUnit.Pebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Pebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Petabit, InformationUnit.Bit) => new Information((_value) * 1e15d, InformationUnit.Bit), - (InformationUnit.Petabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e15d, InformationUnit.Bit), - (InformationUnit.Tebibit, InformationUnit.Bit) => new Information((_value) * (1024d * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Tebibyte, InformationUnit.Bit) => new Information((_value * 8) * (1024d * 1024 * 1024 * 1024), InformationUnit.Bit), - (InformationUnit.Terabit, InformationUnit.Bit) => new Information((_value) * 1e12d, InformationUnit.Bit), - (InformationUnit.Terabyte, InformationUnit.Bit) => new Information((_value * 8) * 1e12d, InformationUnit.Bit), + (InformationUnit.Exabit, InformationUnit.Bit) => new Information(_value * 1000000000000000000, InformationUnit.Bit), + (InformationUnit.Exabyte, InformationUnit.Bit) => new Information(_value * 8000000000000000000, InformationUnit.Bit), + (InformationUnit.Exbibit, InformationUnit.Bit) => new Information(_value * 1152921504606846976, InformationUnit.Bit), + (InformationUnit.Exbibyte, InformationUnit.Bit) => new Information(_value * BigInteger.Pow(2, 63), InformationUnit.Bit), + (InformationUnit.Gibibit, InformationUnit.Bit) => new Information(_value * 1073741824, InformationUnit.Bit), + (InformationUnit.Gibibyte, InformationUnit.Bit) => new Information(_value * 8589934592, InformationUnit.Bit), + (InformationUnit.Gigabit, InformationUnit.Bit) => new Information(_value * 1000000000, InformationUnit.Bit), + (InformationUnit.Gigabyte, InformationUnit.Bit) => new Information(_value * 8000000000, InformationUnit.Bit), + (InformationUnit.Kibibit, InformationUnit.Bit) => new Information(_value * 1024, InformationUnit.Bit), + (InformationUnit.Kibibyte, InformationUnit.Bit) => new Information(_value * 8192, InformationUnit.Bit), + (InformationUnit.Kilobit, InformationUnit.Bit) => new Information(_value * 1000, InformationUnit.Bit), + (InformationUnit.Kilobyte, InformationUnit.Bit) => new Information(_value * 8000, InformationUnit.Bit), + (InformationUnit.Mebibit, InformationUnit.Bit) => new Information(_value * 1048576, InformationUnit.Bit), + (InformationUnit.Mebibyte, InformationUnit.Bit) => new Information(_value * 8388608, InformationUnit.Bit), + (InformationUnit.Megabit, InformationUnit.Bit) => new Information(_value * 1000000, InformationUnit.Bit), + (InformationUnit.Megabyte, InformationUnit.Bit) => new Information(_value * 8000000, InformationUnit.Bit), + (InformationUnit.Pebibit, InformationUnit.Bit) => new Information(_value * 1125899906842624, InformationUnit.Bit), + (InformationUnit.Pebibyte, InformationUnit.Bit) => new Information(_value * 9007199254740992, InformationUnit.Bit), + (InformationUnit.Petabit, InformationUnit.Bit) => new Information(_value * 1000000000000000, InformationUnit.Bit), + (InformationUnit.Petabyte, InformationUnit.Bit) => new Information(_value * 8000000000000000, InformationUnit.Bit), + (InformationUnit.Tebibit, InformationUnit.Bit) => new Information(_value * 1099511627776, InformationUnit.Bit), + (InformationUnit.Tebibyte, InformationUnit.Bit) => new Information(_value * 8796093022208, InformationUnit.Bit), + (InformationUnit.Terabit, InformationUnit.Bit) => new Information(_value * 1000000000000, InformationUnit.Bit), + (InformationUnit.Terabyte, InformationUnit.Bit) => new Information(_value * 8000000000000, InformationUnit.Bit), // BaseUnit -> InformationUnit (InformationUnit.Bit, InformationUnit.Byte) => new Information(_value / 8, InformationUnit.Byte), - (InformationUnit.Bit, InformationUnit.Exabit) => new Information((_value) / 1e18d, InformationUnit.Exabit), - (InformationUnit.Bit, InformationUnit.Exabyte) => new Information((_value / 8) / 1e18d, InformationUnit.Exabyte), - (InformationUnit.Bit, InformationUnit.Exbibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibit), - (InformationUnit.Bit, InformationUnit.Exbibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024 * 1024), InformationUnit.Exbibyte), - (InformationUnit.Bit, InformationUnit.Gibibit) => new Information((_value) / (1024d * 1024 * 1024), InformationUnit.Gibibit), - (InformationUnit.Bit, InformationUnit.Gibibyte) => new Information((_value / 8) / (1024d * 1024 * 1024), InformationUnit.Gibibyte), - (InformationUnit.Bit, InformationUnit.Gigabit) => new Information((_value) / 1e9d, InformationUnit.Gigabit), - (InformationUnit.Bit, InformationUnit.Gigabyte) => new Information((_value / 8) / 1e9d, InformationUnit.Gigabyte), - (InformationUnit.Bit, InformationUnit.Kibibit) => new Information((_value) / 1024d, InformationUnit.Kibibit), - (InformationUnit.Bit, InformationUnit.Kibibyte) => new Information((_value / 8) / 1024d, InformationUnit.Kibibyte), - (InformationUnit.Bit, InformationUnit.Kilobit) => new Information((_value) / 1e3d, InformationUnit.Kilobit), - (InformationUnit.Bit, InformationUnit.Kilobyte) => new Information((_value / 8) / 1e3d, InformationUnit.Kilobyte), - (InformationUnit.Bit, InformationUnit.Mebibit) => new Information((_value) / (1024d * 1024), InformationUnit.Mebibit), - (InformationUnit.Bit, InformationUnit.Mebibyte) => new Information((_value / 8) / (1024d * 1024), InformationUnit.Mebibyte), - (InformationUnit.Bit, InformationUnit.Megabit) => new Information((_value) / 1e6d, InformationUnit.Megabit), - (InformationUnit.Bit, InformationUnit.Megabyte) => new Information((_value / 8) / 1e6d, InformationUnit.Megabyte), - (InformationUnit.Bit, InformationUnit.Pebibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibit), - (InformationUnit.Bit, InformationUnit.Pebibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024 * 1024), InformationUnit.Pebibyte), - (InformationUnit.Bit, InformationUnit.Petabit) => new Information((_value) / 1e15d, InformationUnit.Petabit), - (InformationUnit.Bit, InformationUnit.Petabyte) => new Information((_value / 8) / 1e15d, InformationUnit.Petabyte), - (InformationUnit.Bit, InformationUnit.Tebibit) => new Information((_value) / (1024d * 1024 * 1024 * 1024), InformationUnit.Tebibit), - (InformationUnit.Bit, InformationUnit.Tebibyte) => new Information((_value / 8) / (1024d * 1024 * 1024 * 1024), InformationUnit.Tebibyte), - (InformationUnit.Bit, InformationUnit.Terabit) => new Information((_value) / 1e12d, InformationUnit.Terabit), - (InformationUnit.Bit, InformationUnit.Terabyte) => new Information((_value / 8) / 1e12d, InformationUnit.Terabyte), + (InformationUnit.Bit, InformationUnit.Exabit) => new Information(_value / 1000000000000000000, InformationUnit.Exabit), + (InformationUnit.Bit, InformationUnit.Exabyte) => new Information(_value / 8000000000000000000, InformationUnit.Exabyte), + (InformationUnit.Bit, InformationUnit.Exbibit) => new Information(_value / 1152921504606846976, InformationUnit.Exbibit), + (InformationUnit.Bit, InformationUnit.Exbibyte) => new Information(_value / BigInteger.Pow(2, 63), InformationUnit.Exbibyte), + (InformationUnit.Bit, InformationUnit.Gibibit) => new Information(_value / 1073741824, InformationUnit.Gibibit), + (InformationUnit.Bit, InformationUnit.Gibibyte) => new Information(_value / 8589934592, InformationUnit.Gibibyte), + (InformationUnit.Bit, InformationUnit.Gigabit) => new Information(_value / 1000000000, InformationUnit.Gigabit), + (InformationUnit.Bit, InformationUnit.Gigabyte) => new Information(_value / 8000000000, InformationUnit.Gigabyte), + (InformationUnit.Bit, InformationUnit.Kibibit) => new Information(_value / 1024, InformationUnit.Kibibit), + (InformationUnit.Bit, InformationUnit.Kibibyte) => new Information(_value / 8192, InformationUnit.Kibibyte), + (InformationUnit.Bit, InformationUnit.Kilobit) => new Information(_value / 1000, InformationUnit.Kilobit), + (InformationUnit.Bit, InformationUnit.Kilobyte) => new Information(_value / 8000, InformationUnit.Kilobyte), + (InformationUnit.Bit, InformationUnit.Mebibit) => new Information(_value / 1048576, InformationUnit.Mebibit), + (InformationUnit.Bit, InformationUnit.Mebibyte) => new Information(_value / 8388608, InformationUnit.Mebibyte), + (InformationUnit.Bit, InformationUnit.Megabit) => new Information(_value / 1000000, InformationUnit.Megabit), + (InformationUnit.Bit, InformationUnit.Megabyte) => new Information(_value / 8000000, InformationUnit.Megabyte), + (InformationUnit.Bit, InformationUnit.Pebibit) => new Information(_value / 1125899906842624, InformationUnit.Pebibit), + (InformationUnit.Bit, InformationUnit.Pebibyte) => new Information(_value / 9007199254740992, InformationUnit.Pebibyte), + (InformationUnit.Bit, InformationUnit.Petabit) => new Information(_value / 1000000000000000, InformationUnit.Petabit), + (InformationUnit.Bit, InformationUnit.Petabyte) => new Information(_value / 8000000000000000, InformationUnit.Petabyte), + (InformationUnit.Bit, InformationUnit.Tebibit) => new Information(_value / 1099511627776, InformationUnit.Tebibit), + (InformationUnit.Bit, InformationUnit.Tebibyte) => new Information(_value / 8796093022208, InformationUnit.Tebibyte), + (InformationUnit.Bit, InformationUnit.Terabit) => new Information(_value / 1000000000000, InformationUnit.Terabit), + (InformationUnit.Bit, InformationUnit.Terabyte) => new Information(_value / 8000000000000, InformationUnit.Terabyte), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index da3c2b8b4a..d12135517c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -91,7 +92,7 @@ static Irradiance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Irradiance(double value, IrradianceUnit unit) + public Irradiance(QuantityValue value, IrradianceUnit unit) { _value = value; _unit = unit; @@ -105,7 +106,7 @@ public Irradiance(double value, IrradianceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiance(double value, UnitSystem unitSystem) + public Irradiance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -156,10 +157,10 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -184,72 +185,72 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); + public QuantityValue KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); + public QuantityValue KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); + public QuantityValue MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); + public QuantityValue MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); + public QuantityValue MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); + public QuantityValue MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); + public QuantityValue MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); + public QuantityValue MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); + public QuantityValue NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); + public QuantityValue NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); + public QuantityValue PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); + public QuantityValue PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); + public QuantityValue WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); + public QuantityValue WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); #endregion @@ -323,7 +324,7 @@ public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provi /// /// Creates a from . /// - public static Irradiance FromKilowattsPerSquareCentimeter(double value) + public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.KilowattPerSquareCentimeter); } @@ -331,7 +332,7 @@ public static Irradiance FromKilowattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromKilowattsPerSquareMeter(double value) + public static Irradiance FromKilowattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter); } @@ -339,7 +340,7 @@ public static Irradiance FromKilowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromMegawattsPerSquareCentimeter(double value) + public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MegawattPerSquareCentimeter); } @@ -347,7 +348,7 @@ public static Irradiance FromMegawattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromMegawattsPerSquareMeter(double value) + public static Irradiance FromMegawattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MegawattPerSquareMeter); } @@ -355,7 +356,7 @@ public static Irradiance FromMegawattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromMicrowattsPerSquareCentimeter(double value) + public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MicrowattPerSquareCentimeter); } @@ -363,7 +364,7 @@ public static Irradiance FromMicrowattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromMicrowattsPerSquareMeter(double value) + public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MicrowattPerSquareMeter); } @@ -371,7 +372,7 @@ public static Irradiance FromMicrowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromMilliwattsPerSquareCentimeter(double value) + public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MilliwattPerSquareCentimeter); } @@ -379,7 +380,7 @@ public static Irradiance FromMilliwattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromMilliwattsPerSquareMeter(double value) + public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.MilliwattPerSquareMeter); } @@ -387,7 +388,7 @@ public static Irradiance FromMilliwattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromNanowattsPerSquareCentimeter(double value) + public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.NanowattPerSquareCentimeter); } @@ -395,7 +396,7 @@ public static Irradiance FromNanowattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromNanowattsPerSquareMeter(double value) + public static Irradiance FromNanowattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.NanowattPerSquareMeter); } @@ -403,7 +404,7 @@ public static Irradiance FromNanowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromPicowattsPerSquareCentimeter(double value) + public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.PicowattPerSquareCentimeter); } @@ -411,7 +412,7 @@ public static Irradiance FromPicowattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromPicowattsPerSquareMeter(double value) + public static Irradiance FromPicowattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.PicowattPerSquareMeter); } @@ -419,7 +420,7 @@ public static Irradiance FromPicowattsPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiance FromWattsPerSquareCentimeter(double value) + public static Irradiance FromWattsPerSquareCentimeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.WattPerSquareCentimeter); } @@ -427,7 +428,7 @@ public static Irradiance FromWattsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiance FromWattsPerSquareMeter(double value) + public static Irradiance FromWattsPerSquareMeter(QuantityValue value) { return new Irradiance(value, IrradianceUnit.WattPerSquareMeter); } @@ -438,7 +439,7 @@ public static Irradiance FromWattsPerSquareMeter(double value) /// Value to convert from. /// Unit to convert from. /// Irradiance unit value. - public static Irradiance From(double value, IrradianceUnit fromUnit) + public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit) { return new Irradiance(value, fromUnit); } @@ -610,25 +611,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiance operator *(double left, Irradiance right) + public static Irradiance operator *(QuantityValue left, Irradiance right) { return new Irradiance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiance operator *(Irradiance left, double right) + public static Irradiance operator *(Irradiance left, QuantityValue right) { return new Irradiance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiance operator /(Irradiance left, double right) + public static Irradiance operator /(Irradiance left, QuantityValue right) { return new Irradiance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Irradiance left, Irradiance right) + public static QuantityValue operator /(Irradiance left, Irradiance right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -661,27 +662,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Irradiance left, Irradiance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiance other, Irradiance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Irradiance left, Irradiance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Irradiance otherQuantity)) @@ -691,15 +685,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Irradiance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -782,10 +773,10 @@ public bool Equals(Irradiance other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -802,7 +793,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Irradiance other, Irradiance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -815,7 +806,12 @@ public bool Equals(Irradiance other, Irradiance tolerance) /// A hash code for the current Irradiance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -826,7 +822,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradianceUnit unit) + public QuantityValue As(IrradianceUnit unit) { if (Unit == unit) return Value; @@ -835,7 +831,7 @@ public double As(IrradianceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -850,7 +846,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); @@ -916,34 +912,34 @@ private bool TryToUnit(IrradianceUnit unit, [NotNullWhen(true)] out Irradiance? Irradiance? convertedOrNull = (Unit, unit) switch { // IrradianceUnit -> BaseUnit - (IrradianceUnit.KilowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e3d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.KilowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e3d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MegawattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e6d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MegawattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e6d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MicrowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e-6d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MicrowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e-6d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MilliwattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e-3d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.MilliwattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e-3d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.NanowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e-9d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.NanowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e-9d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.PicowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value * 10000) * 1e-12d, IrradianceUnit.WattPerSquareMeter), - (IrradianceUnit.PicowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance((_value) * 1e-12d, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.KilowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 10000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.KilowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 1000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MegawattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 10000000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MegawattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 1000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MicrowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 100, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MicrowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 1000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MilliwattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 10, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.MilliwattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 1000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.NanowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 100000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.NanowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 1000000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.PicowattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 100000000, IrradianceUnit.WattPerSquareMeter), + (IrradianceUnit.PicowattPerSquareMeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value / 1000000000000, IrradianceUnit.WattPerSquareMeter), (IrradianceUnit.WattPerSquareCentimeter, IrradianceUnit.WattPerSquareMeter) => new Irradiance(_value * 10000, IrradianceUnit.WattPerSquareMeter), // BaseUnit -> IrradianceUnit - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.KilowattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e3d, IrradianceUnit.KilowattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.KilowattPerSquareMeter) => new Irradiance((_value) / 1e3d, IrradianceUnit.KilowattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MegawattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e6d, IrradianceUnit.MegawattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MegawattPerSquareMeter) => new Irradiance((_value) / 1e6d, IrradianceUnit.MegawattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MicrowattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e-6d, IrradianceUnit.MicrowattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MicrowattPerSquareMeter) => new Irradiance((_value) / 1e-6d, IrradianceUnit.MicrowattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MilliwattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e-3d, IrradianceUnit.MilliwattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MilliwattPerSquareMeter) => new Irradiance((_value) / 1e-3d, IrradianceUnit.MilliwattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.NanowattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e-9d, IrradianceUnit.NanowattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.NanowattPerSquareMeter) => new Irradiance((_value) / 1e-9d, IrradianceUnit.NanowattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareCentimeter) => new Irradiance((_value * 0.0001) / 1e-12d, IrradianceUnit.PicowattPerSquareCentimeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareMeter) => new Irradiance((_value) / 1e-12d, IrradianceUnit.PicowattPerSquareMeter), - (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.WattPerSquareCentimeter) => new Irradiance(_value * 0.0001, IrradianceUnit.WattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.KilowattPerSquareCentimeter) => new Irradiance(_value / 10000000, IrradianceUnit.KilowattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.KilowattPerSquareMeter) => new Irradiance(_value / 1000, IrradianceUnit.KilowattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MegawattPerSquareCentimeter) => new Irradiance(_value / 10000000000, IrradianceUnit.MegawattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MegawattPerSquareMeter) => new Irradiance(_value / 1000000, IrradianceUnit.MegawattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MicrowattPerSquareCentimeter) => new Irradiance(_value * 100, IrradianceUnit.MicrowattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MicrowattPerSquareMeter) => new Irradiance(_value * 1000000, IrradianceUnit.MicrowattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MilliwattPerSquareCentimeter) => new Irradiance(_value / 10, IrradianceUnit.MilliwattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.MilliwattPerSquareMeter) => new Irradiance(_value * 1000, IrradianceUnit.MilliwattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.NanowattPerSquareCentimeter) => new Irradiance(_value * 100000, IrradianceUnit.NanowattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.NanowattPerSquareMeter) => new Irradiance(_value * 1000000000, IrradianceUnit.NanowattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareCentimeter) => new Irradiance(_value * 100000000, IrradianceUnit.PicowattPerSquareCentimeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareMeter) => new Irradiance(_value * 1000000000000, IrradianceUnit.PicowattPerSquareMeter), + (IrradianceUnit.WattPerSquareMeter, IrradianceUnit.WattPerSquareCentimeter) => new Irradiance(_value / 10000, IrradianceUnit.WattPerSquareCentimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 1fb1b3c03c..4f0a9058d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -68,9 +69,11 @@ static Irradiation() Info = new QuantityInfo("Irradiation", new UnitInfo[] { + new UnitInfo(IrradiationUnit.BtuPerSquareFoot, "BtusPerSquareFoot", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.JoulePerSquareCentimeter, "JoulesPerSquareCentimeter", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.JoulePerSquareMeter, "JoulesPerSquareMeter", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.JoulePerSquareMillimeter, "JoulesPerSquareMillimeter", BaseUnits.Undefined, "Irradiation"), + new UnitInfo(IrradiationUnit.KilobtuPerSquareFoot, "KilobtusPerSquareFoot", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.KilojoulePerSquareMeter, "KilojoulesPerSquareMeter", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.KilowattHourPerSquareMeter, "KilowattHoursPerSquareMeter", BaseUnits.Undefined, "Irradiation"), new UnitInfo(IrradiationUnit.MillijoulePerSquareCentimeter, "MillijoulesPerSquareCentimeter", BaseUnits.Undefined, "Irradiation"), @@ -87,7 +90,7 @@ static Irradiation() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Irradiation(double value, IrradiationUnit unit) + public Irradiation(QuantityValue value, IrradiationUnit unit) { _value = value; _unit = unit; @@ -101,7 +104,7 @@ public Irradiation(double value, IrradiationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiation(double value, UnitSystem unitSystem) + public Irradiation(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -152,10 +155,10 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,40 +180,50 @@ public Irradiation(double value, UnitSystem unitSystem) #region Conversion Properties + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue BtusPerSquareFoot => As(IrradiationUnit.BtuPerSquareFoot); + /// /// Gets a value of this quantity converted into /// - public double JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); + public QuantityValue JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); + public QuantityValue JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + public QuantityValue JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue KilobtusPerSquareFoot => As(IrradiationUnit.KilobtuPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); + public QuantityValue KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); + public QuantityValue KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); + public QuantityValue MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); + public QuantityValue WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); #endregion @@ -223,8 +236,10 @@ public Irradiation(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: IrradiationUnit -> BaseUnit + unitConverter.SetConversionFunction(IrradiationUnit.BtuPerSquareFoot, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMillimeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); + unitConverter.SetConversionFunction(IrradiationUnit.KilobtuPerSquareFoot, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.KilojoulePerSquareMeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.KilowattHourPerSquareMeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.MillijoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMeter)); @@ -234,8 +249,10 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity); // Register in unit converter: BaseUnit -> IrradiationUnit + unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.BtuPerSquareFoot, quantity => quantity.ToUnit(IrradiationUnit.BtuPerSquareFoot)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareCentimeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareCentimeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareMillimeter, quantity => quantity.ToUnit(IrradiationUnit.JoulePerSquareMillimeter)); + unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilobtuPerSquareFoot, quantity => quantity.ToUnit(IrradiationUnit.KilobtuPerSquareFoot)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilojoulePerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.KilojoulePerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilowattHourPerSquareMeter, quantity => quantity.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.MillijoulePerSquareCentimeter, quantity => quantity.ToUnit(IrradiationUnit.MillijoulePerSquareCentimeter)); @@ -267,10 +284,18 @@ public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? prov #region Static Factory Methods + /// + /// Creates a from . + /// + public static Irradiation FromBtusPerSquareFoot(QuantityValue value) + { + return new Irradiation(value, IrradiationUnit.BtuPerSquareFoot); + } + /// /// Creates a from . /// - public static Irradiation FromJoulesPerSquareCentimeter(double value) + public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.JoulePerSquareCentimeter); } @@ -278,7 +303,7 @@ public static Irradiation FromJoulesPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiation FromJoulesPerSquareMeter(double value) + public static Irradiation FromJoulesPerSquareMeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter); } @@ -286,15 +311,23 @@ public static Irradiation FromJoulesPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiation FromJoulesPerSquareMillimeter(double value) + public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.JoulePerSquareMillimeter); } + /// + /// Creates a from . + /// + public static Irradiation FromKilobtusPerSquareFoot(QuantityValue value) + { + return new Irradiation(value, IrradiationUnit.KilobtuPerSquareFoot); + } + /// /// Creates a from . /// - public static Irradiation FromKilojoulesPerSquareMeter(double value) + public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.KilojoulePerSquareMeter); } @@ -302,7 +335,7 @@ public static Irradiation FromKilojoulesPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiation FromKilowattHoursPerSquareMeter(double value) + public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter); } @@ -310,7 +343,7 @@ public static Irradiation FromKilowattHoursPerSquareMeter(double value) /// /// Creates a from . /// - public static Irradiation FromMillijoulesPerSquareCentimeter(double value) + public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.MillijoulePerSquareCentimeter); } @@ -318,7 +351,7 @@ public static Irradiation FromMillijoulesPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Irradiation FromWattHoursPerSquareMeter(double value) + public static Irradiation FromWattHoursPerSquareMeter(QuantityValue value) { return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter); } @@ -329,7 +362,7 @@ public static Irradiation FromWattHoursPerSquareMeter(double value) /// Value to convert from. /// Unit to convert from. /// Irradiation unit value. - public static Irradiation From(double value, IrradiationUnit fromUnit) + public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit) { return new Irradiation(value, fromUnit); } @@ -501,25 +534,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiation operator *(double left, Irradiation right) + public static Irradiation operator *(QuantityValue left, Irradiation right) { return new Irradiation(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiation operator *(Irradiation left, double right) + public static Irradiation operator *(Irradiation left, QuantityValue right) { return new Irradiation(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiation operator /(Irradiation left, double right) + public static Irradiation operator /(Irradiation left, QuantityValue right) { return new Irradiation(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Irradiation left, Irradiation right) + public static QuantityValue operator /(Irradiation left, Irradiation right) { return left.JoulesPerSquareMeter / right.JoulesPerSquareMeter; } @@ -552,27 +585,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Irradiation left, Irradiation right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Irradiation other, Irradiation tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Irradiation left, Irradiation right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Irradiation otherQuantity)) @@ -582,15 +608,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Irradiation other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -673,10 +696,10 @@ public bool Equals(Irradiation other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -693,7 +716,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Irradiation other, Irradiation tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -706,7 +729,12 @@ public bool Equals(Irradiation other, Irradiation tolerance) /// A hash code for the current Irradiation. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -717,7 +745,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradiationUnit unit) + public QuantityValue As(IrradiationUnit unit) { if (Unit == unit) return Value; @@ -726,7 +754,7 @@ public double As(IrradiationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -741,7 +769,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); @@ -807,20 +835,24 @@ private bool TryToUnit(IrradiationUnit unit, [NotNullWhen(true)] out Irradiation Irradiation? convertedOrNull = (Unit, unit) switch { // IrradiationUnit -> BaseUnit - (IrradiationUnit.JoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 1e4, IrradiationUnit.JoulePerSquareMeter), - (IrradiationUnit.JoulePerSquareMillimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 1e6, IrradiationUnit.JoulePerSquareMeter), - (IrradiationUnit.KilojoulePerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation((_value) * 1e3d, IrradiationUnit.JoulePerSquareMeter), - (IrradiationUnit.KilowattHourPerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation((_value * 3600d) * 1e3d, IrradiationUnit.JoulePerSquareMeter), - (IrradiationUnit.MillijoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation((_value * 1e4) * 1e-3d, IrradiationUnit.JoulePerSquareMeter), - (IrradiationUnit.WattHourPerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 3600d, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.BtuPerSquareFoot, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * new QuantityValue(52752792631, 4645152, false), IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.JoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 10000, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.JoulePerSquareMillimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 1000000, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.KilobtuPerSquareFoot, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * new QuantityValue(6594099078875, 580644, false), IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.KilojoulePerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 1000, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.KilowattHourPerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 3600000, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.MillijoulePerSquareCentimeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 10, IrradiationUnit.JoulePerSquareMeter), + (IrradiationUnit.WattHourPerSquareMeter, IrradiationUnit.JoulePerSquareMeter) => new Irradiation(_value * 3600, IrradiationUnit.JoulePerSquareMeter), // BaseUnit -> IrradiationUnit - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareCentimeter) => new Irradiation(_value / 1e4, IrradiationUnit.JoulePerSquareCentimeter), - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareMillimeter) => new Irradiation(_value / 1e6, IrradiationUnit.JoulePerSquareMillimeter), - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilojoulePerSquareMeter) => new Irradiation((_value) / 1e3d, IrradiationUnit.KilojoulePerSquareMeter), - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilowattHourPerSquareMeter) => new Irradiation((_value / 3600d) / 1e3d, IrradiationUnit.KilowattHourPerSquareMeter), - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.MillijoulePerSquareCentimeter) => new Irradiation((_value / 1e4) / 1e-3d, IrradiationUnit.MillijoulePerSquareCentimeter), - (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.WattHourPerSquareMeter) => new Irradiation(_value / 3600d, IrradiationUnit.WattHourPerSquareMeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.BtuPerSquareFoot) => new Irradiation(_value * new QuantityValue(4645152, 52752792631, false), IrradiationUnit.BtuPerSquareFoot), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareCentimeter) => new Irradiation(_value / 10000, IrradiationUnit.JoulePerSquareCentimeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareMillimeter) => new Irradiation(_value / 1000000, IrradiationUnit.JoulePerSquareMillimeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilobtuPerSquareFoot) => new Irradiation(_value * new QuantityValue(580644, 6594099078875, false), IrradiationUnit.KilobtuPerSquareFoot), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilojoulePerSquareMeter) => new Irradiation(_value / 1000, IrradiationUnit.KilojoulePerSquareMeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilowattHourPerSquareMeter) => new Irradiation(_value / 3600000, IrradiationUnit.KilowattHourPerSquareMeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.MillijoulePerSquareCentimeter) => new Irradiation(_value / 10, IrradiationUnit.MillijoulePerSquareCentimeter), + (IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.WattHourPerSquareMeter) => new Irradiation(_value / 3600, IrradiationUnit.WattHourPerSquareMeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 657f51c33d..91c73a3abc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -94,7 +92,7 @@ static Jerk() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Jerk(double value, JerkUnit unit) + public Jerk(QuantityValue value, JerkUnit unit) { _value = value; _unit = unit; @@ -108,7 +106,7 @@ public Jerk(double value, JerkUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Jerk(double value, UnitSystem unitSystem) + public Jerk(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,10 +157,10 @@ public Jerk(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -187,57 +185,57 @@ public Jerk(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); + public QuantityValue CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); + public QuantityValue DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); + public QuantityValue FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); + public QuantityValue InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); + public QuantityValue KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); + public QuantityValue MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); + public QuantityValue MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); + public QuantityValue MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); + public QuantityValue MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); + public QuantityValue NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); /// /// Gets a value of this quantity converted into /// - public double StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); + public QuantityValue StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); #endregion @@ -305,7 +303,7 @@ public static string GetAbbreviation(JerkUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Jerk FromCentimetersPerSecondCubed(double value) + public static Jerk FromCentimetersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.CentimeterPerSecondCubed); } @@ -313,7 +311,7 @@ public static Jerk FromCentimetersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromDecimetersPerSecondCubed(double value) + public static Jerk FromDecimetersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.DecimeterPerSecondCubed); } @@ -321,7 +319,7 @@ public static Jerk FromDecimetersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromFeetPerSecondCubed(double value) + public static Jerk FromFeetPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.FootPerSecondCubed); } @@ -329,7 +327,7 @@ public static Jerk FromFeetPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromInchesPerSecondCubed(double value) + public static Jerk FromInchesPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.InchPerSecondCubed); } @@ -337,7 +335,7 @@ public static Jerk FromInchesPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromKilometersPerSecondCubed(double value) + public static Jerk FromKilometersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.KilometerPerSecondCubed); } @@ -345,7 +343,7 @@ public static Jerk FromKilometersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromMetersPerSecondCubed(double value) + public static Jerk FromMetersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.MeterPerSecondCubed); } @@ -353,7 +351,7 @@ public static Jerk FromMetersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromMicrometersPerSecondCubed(double value) + public static Jerk FromMicrometersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.MicrometerPerSecondCubed); } @@ -361,7 +359,7 @@ public static Jerk FromMicrometersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromMillimetersPerSecondCubed(double value) + public static Jerk FromMillimetersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.MillimeterPerSecondCubed); } @@ -369,7 +367,7 @@ public static Jerk FromMillimetersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromMillistandardGravitiesPerSecond(double value) + public static Jerk FromMillistandardGravitiesPerSecond(QuantityValue value) { return new Jerk(value, JerkUnit.MillistandardGravitiesPerSecond); } @@ -377,7 +375,7 @@ public static Jerk FromMillistandardGravitiesPerSecond(double value) /// /// Creates a from . /// - public static Jerk FromNanometersPerSecondCubed(double value) + public static Jerk FromNanometersPerSecondCubed(QuantityValue value) { return new Jerk(value, JerkUnit.NanometerPerSecondCubed); } @@ -385,7 +383,7 @@ public static Jerk FromNanometersPerSecondCubed(double value) /// /// Creates a from . /// - public static Jerk FromStandardGravitiesPerSecond(double value) + public static Jerk FromStandardGravitiesPerSecond(QuantityValue value) { return new Jerk(value, JerkUnit.StandardGravitiesPerSecond); } @@ -396,7 +394,7 @@ public static Jerk FromStandardGravitiesPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// Jerk unit value. - public static Jerk From(double value, JerkUnit fromUnit) + public static Jerk From(QuantityValue value, JerkUnit fromUnit) { return new Jerk(value, fromUnit); } @@ -568,25 +566,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU } /// Get from multiplying value and . - public static Jerk operator *(double left, Jerk right) + public static Jerk operator *(QuantityValue left, Jerk right) { return new Jerk(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Jerk operator *(Jerk left, double right) + public static Jerk operator *(Jerk left, QuantityValue right) { return new Jerk(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Jerk operator /(Jerk left, double right) + public static Jerk operator /(Jerk left, QuantityValue right) { return new Jerk(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Jerk left, Jerk right) + public static QuantityValue operator /(Jerk left, Jerk right) { return left.MetersPerSecondCubed / right.MetersPerSecondCubed; } @@ -629,27 +627,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Jerk left, Jerk right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Jerk other, Jerk tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Jerk left, Jerk right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Jerk otherQuantity)) @@ -659,15 +650,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Jerk other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +738,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -770,7 +758,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Jerk other, Jerk tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -783,7 +771,12 @@ public bool Equals(Jerk other, Jerk tolerance) /// A hash code for the current Jerk. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -794,7 +787,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(JerkUnit unit) + public QuantityValue As(JerkUnit unit) { if (Unit == unit) return Value; @@ -803,7 +796,7 @@ public double As(JerkUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -818,7 +811,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); @@ -884,28 +877,28 @@ private bool TryToUnit(JerkUnit unit, [NotNullWhen(true)] out Jerk? converted) Jerk? convertedOrNull = (Unit, unit) switch { // JerkUnit -> BaseUnit - (JerkUnit.CentimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e-2d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.DecimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e-1d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.FootPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * 0.304800, JerkUnit.MeterPerSecondCubed), - (JerkUnit.InchPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * 0.0254, JerkUnit.MeterPerSecondCubed), - (JerkUnit.KilometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e3d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.MicrometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e-6d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.MillimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e-3d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.MillistandardGravitiesPerSecond, JerkUnit.MeterPerSecondCubed) => new Jerk((_value * 9.80665) * 1e-3d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.NanometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk((_value) * 1e-9d, JerkUnit.MeterPerSecondCubed), - (JerkUnit.StandardGravitiesPerSecond, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * 9.80665, JerkUnit.MeterPerSecondCubed), + (JerkUnit.CentimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value / 100, JerkUnit.MeterPerSecondCubed), + (JerkUnit.DecimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value / 10, JerkUnit.MeterPerSecondCubed), + (JerkUnit.FootPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * new QuantityValue(381, 1250, false), JerkUnit.MeterPerSecondCubed), + (JerkUnit.InchPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * new QuantityValue(127, 5000, false), JerkUnit.MeterPerSecondCubed), + (JerkUnit.KilometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * 1000, JerkUnit.MeterPerSecondCubed), + (JerkUnit.MicrometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value / 1000000, JerkUnit.MeterPerSecondCubed), + (JerkUnit.MillimeterPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value / 1000, JerkUnit.MeterPerSecondCubed), + (JerkUnit.MillistandardGravitiesPerSecond, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * new QuantityValue(196133, 20000000, false), JerkUnit.MeterPerSecondCubed), + (JerkUnit.NanometerPerSecondCubed, JerkUnit.MeterPerSecondCubed) => new Jerk(_value / 1000000000, JerkUnit.MeterPerSecondCubed), + (JerkUnit.StandardGravitiesPerSecond, JerkUnit.MeterPerSecondCubed) => new Jerk(_value * new QuantityValue(196133, 20000, false), JerkUnit.MeterPerSecondCubed), // BaseUnit -> JerkUnit - (JerkUnit.MeterPerSecondCubed, JerkUnit.CentimeterPerSecondCubed) => new Jerk((_value) / 1e-2d, JerkUnit.CentimeterPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.DecimeterPerSecondCubed) => new Jerk((_value) / 1e-1d, JerkUnit.DecimeterPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.FootPerSecondCubed) => new Jerk(_value / 0.304800, JerkUnit.FootPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.InchPerSecondCubed) => new Jerk(_value / 0.0254, JerkUnit.InchPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.KilometerPerSecondCubed) => new Jerk((_value) / 1e3d, JerkUnit.KilometerPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.MicrometerPerSecondCubed) => new Jerk((_value) / 1e-6d, JerkUnit.MicrometerPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.MillimeterPerSecondCubed) => new Jerk((_value) / 1e-3d, JerkUnit.MillimeterPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.MillistandardGravitiesPerSecond) => new Jerk((_value / 9.80665) / 1e-3d, JerkUnit.MillistandardGravitiesPerSecond), - (JerkUnit.MeterPerSecondCubed, JerkUnit.NanometerPerSecondCubed) => new Jerk((_value) / 1e-9d, JerkUnit.NanometerPerSecondCubed), - (JerkUnit.MeterPerSecondCubed, JerkUnit.StandardGravitiesPerSecond) => new Jerk(_value / 9.80665, JerkUnit.StandardGravitiesPerSecond), + (JerkUnit.MeterPerSecondCubed, JerkUnit.CentimeterPerSecondCubed) => new Jerk(_value * 100, JerkUnit.CentimeterPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.DecimeterPerSecondCubed) => new Jerk(_value * 10, JerkUnit.DecimeterPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.FootPerSecondCubed) => new Jerk(_value * new QuantityValue(1250, 381, false), JerkUnit.FootPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.InchPerSecondCubed) => new Jerk(_value * new QuantityValue(5000, 127, false), JerkUnit.InchPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.KilometerPerSecondCubed) => new Jerk(_value / 1000, JerkUnit.KilometerPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.MicrometerPerSecondCubed) => new Jerk(_value * 1000000, JerkUnit.MicrometerPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.MillimeterPerSecondCubed) => new Jerk(_value * 1000, JerkUnit.MillimeterPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.MillistandardGravitiesPerSecond) => new Jerk(_value * new QuantityValue(20000000, 196133, false), JerkUnit.MillistandardGravitiesPerSecond), + (JerkUnit.MeterPerSecondCubed, JerkUnit.NanometerPerSecondCubed) => new Jerk(_value * 1000000000, JerkUnit.NanometerPerSecondCubed), + (JerkUnit.MeterPerSecondCubed, JerkUnit.StandardGravitiesPerSecond) => new Jerk(_value * new QuantityValue(20000, 196133, false), JerkUnit.StandardGravitiesPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 19dc50df99..db9820cef8 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -60,7 +58,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,7 +96,7 @@ static KinematicViscosity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public KinematicViscosity(double value, KinematicViscosityUnit unit) + public KinematicViscosity(QuantityValue value, KinematicViscosityUnit unit) { _value = value; _unit = unit; @@ -112,7 +110,7 @@ public KinematicViscosity(double value, KinematicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public KinematicViscosity(double value, UnitSystem unitSystem) + public KinematicViscosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -163,10 +161,10 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,47 +189,47 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Centistokes => As(KinematicViscosityUnit.Centistokes); + public QuantityValue Centistokes => As(KinematicViscosityUnit.Centistokes); /// /// Gets a value of this quantity converted into /// - public double Decistokes => As(KinematicViscosityUnit.Decistokes); + public QuantityValue Decistokes => As(KinematicViscosityUnit.Decistokes); /// /// Gets a value of this quantity converted into /// - public double Kilostokes => As(KinematicViscosityUnit.Kilostokes); + public QuantityValue Kilostokes => As(KinematicViscosityUnit.Kilostokes); /// /// Gets a value of this quantity converted into /// - public double Microstokes => As(KinematicViscosityUnit.Microstokes); + public QuantityValue Microstokes => As(KinematicViscosityUnit.Microstokes); /// /// Gets a value of this quantity converted into /// - public double Millistokes => As(KinematicViscosityUnit.Millistokes); + public QuantityValue Millistokes => As(KinematicViscosityUnit.Millistokes); /// /// Gets a value of this quantity converted into /// - public double Nanostokes => As(KinematicViscosityUnit.Nanostokes); + public QuantityValue Nanostokes => As(KinematicViscosityUnit.Nanostokes); /// /// Gets a value of this quantity converted into /// - public double SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); + public QuantityValue SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); + public QuantityValue SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double Stokes => As(KinematicViscosityUnit.Stokes); + public QuantityValue Stokes => As(KinematicViscosityUnit.Stokes); #endregion @@ -295,7 +293,7 @@ public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvide /// /// Creates a from . /// - public static KinematicViscosity FromCentistokes(double value) + public static KinematicViscosity FromCentistokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes); } @@ -303,7 +301,7 @@ public static KinematicViscosity FromCentistokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromDecistokes(double value) + public static KinematicViscosity FromDecistokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes); } @@ -311,7 +309,7 @@ public static KinematicViscosity FromDecistokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromKilostokes(double value) + public static KinematicViscosity FromKilostokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes); } @@ -319,7 +317,7 @@ public static KinematicViscosity FromKilostokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromMicrostokes(double value) + public static KinematicViscosity FromMicrostokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes); } @@ -327,7 +325,7 @@ public static KinematicViscosity FromMicrostokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromMillistokes(double value) + public static KinematicViscosity FromMillistokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes); } @@ -335,7 +333,7 @@ public static KinematicViscosity FromMillistokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromNanostokes(double value) + public static KinematicViscosity FromNanostokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes); } @@ -343,7 +341,7 @@ public static KinematicViscosity FromNanostokes(double value) /// /// Creates a from . /// - public static KinematicViscosity FromSquareFeetPerSecond(double value) + public static KinematicViscosity FromSquareFeetPerSecond(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.SquareFootPerSecond); } @@ -351,7 +349,7 @@ public static KinematicViscosity FromSquareFeetPerSecond(double value) /// /// Creates a from . /// - public static KinematicViscosity FromSquareMetersPerSecond(double value) + public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond); } @@ -359,7 +357,7 @@ public static KinematicViscosity FromSquareMetersPerSecond(double value) /// /// Creates a from . /// - public static KinematicViscosity FromStokes(double value) + public static KinematicViscosity FromStokes(QuantityValue value) { return new KinematicViscosity(value, KinematicViscosityUnit.Stokes); } @@ -370,7 +368,7 @@ public static KinematicViscosity FromStokes(double value) /// Value to convert from. /// Unit to convert from. /// KinematicViscosity unit value. - public static KinematicViscosity From(double value, KinematicViscosityUnit fromUnit) + public static KinematicViscosity From(QuantityValue value, KinematicViscosityUnit fromUnit) { return new KinematicViscosity(value, fromUnit); } @@ -542,25 +540,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem } /// Get from multiplying value and . - public static KinematicViscosity operator *(double left, KinematicViscosity right) + public static KinematicViscosity operator *(QuantityValue left, KinematicViscosity right) { return new KinematicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static KinematicViscosity operator *(KinematicViscosity left, double right) + public static KinematicViscosity operator *(KinematicViscosity left, QuantityValue right) { return new KinematicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static KinematicViscosity operator /(KinematicViscosity left, double right) + public static KinematicViscosity operator /(KinematicViscosity left, QuantityValue right) { return new KinematicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(KinematicViscosity left, KinematicViscosity right) + public static QuantityValue operator /(KinematicViscosity left, KinematicViscosity right) { return left.SquareMetersPerSecond / right.SquareMetersPerSecond; } @@ -621,27 +619,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(KinematicViscosity left, KinematicViscosity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(KinematicViscosity other, KinematicViscosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(KinematicViscosity left, KinematicViscosity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is KinematicViscosity otherQuantity)) @@ -651,15 +642,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(KinematicViscosity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +730,10 @@ public bool Equals(KinematicViscosity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -762,7 +750,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(KinematicViscosity other, KinematicViscosity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -775,7 +763,12 @@ public bool Equals(KinematicViscosity other, KinematicViscosity tolerance) /// A hash code for the current KinematicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -786,7 +779,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(KinematicViscosityUnit unit) + public QuantityValue As(KinematicViscosityUnit unit) { if (Unit == unit) return Value; @@ -795,7 +788,7 @@ public double As(KinematicViscosityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -810,7 +803,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); @@ -876,24 +869,24 @@ private bool TryToUnit(KinematicViscosityUnit unit, [NotNullWhen(true)] out Kine KinematicViscosity? convertedOrNull = (Unit, unit) switch { // KinematicViscosityUnit -> BaseUnit - (KinematicViscosityUnit.Centistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e-2d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Decistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e-1d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Kilostokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e3d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Microstokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e-6d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Millistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e-3d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Nanostokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity((_value / 1e4) * 1e-9d, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.SquareFootPerSecond, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10.7639, KinematicViscosityUnit.SquareMeterPerSecond), - (KinematicViscosityUnit.Stokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 1e4, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Centistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 1000000, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Decistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 100000, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Kilostokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Microstokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10000000000, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Millistokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10000000, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Nanostokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10000000000000, KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.SquareFootPerSecond, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value * new QuantityValue(10000, 107639, false), KinematicViscosityUnit.SquareMeterPerSecond), + (KinematicViscosityUnit.Stokes, KinematicViscosityUnit.SquareMeterPerSecond) => new KinematicViscosity(_value / 10000, KinematicViscosityUnit.SquareMeterPerSecond), // BaseUnit -> KinematicViscosityUnit - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Centistokes) => new KinematicViscosity((_value * 1e4) / 1e-2d, KinematicViscosityUnit.Centistokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Decistokes) => new KinematicViscosity((_value * 1e4) / 1e-1d, KinematicViscosityUnit.Decistokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Kilostokes) => new KinematicViscosity((_value * 1e4) / 1e3d, KinematicViscosityUnit.Kilostokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Microstokes) => new KinematicViscosity((_value * 1e4) / 1e-6d, KinematicViscosityUnit.Microstokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Millistokes) => new KinematicViscosity((_value * 1e4) / 1e-3d, KinematicViscosityUnit.Millistokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Nanostokes) => new KinematicViscosity((_value * 1e4) / 1e-9d, KinematicViscosityUnit.Nanostokes), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.SquareFootPerSecond) => new KinematicViscosity(_value * 10.7639, KinematicViscosityUnit.SquareFootPerSecond), - (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Stokes) => new KinematicViscosity(_value * 1e4, KinematicViscosityUnit.Stokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Centistokes) => new KinematicViscosity(_value * 1000000, KinematicViscosityUnit.Centistokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Decistokes) => new KinematicViscosity(_value * 100000, KinematicViscosityUnit.Decistokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Kilostokes) => new KinematicViscosity(_value * 10, KinematicViscosityUnit.Kilostokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Microstokes) => new KinematicViscosity(_value * 10000000000, KinematicViscosityUnit.Microstokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Millistokes) => new KinematicViscosity(_value * 10000000, KinematicViscosityUnit.Millistokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Nanostokes) => new KinematicViscosity(_value * 10000000000000, KinematicViscosityUnit.Nanostokes), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.SquareFootPerSecond) => new KinematicViscosity(_value * new QuantityValue(107639, 10000, false), KinematicViscosityUnit.SquareFootPerSecond), + (KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Stokes) => new KinematicViscosity(_value * 10000, KinematicViscosityUnit.Stokes), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs index ea2711d882..d9c8b5bc54 100644 --- a/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LeakRate.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static LeakRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public LeakRate(double value, LeakRateUnit unit) + public LeakRate(QuantityValue value, LeakRateUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public LeakRate(double value, LeakRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LeakRate(double value, UnitSystem unitSystem) + public LeakRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public LeakRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,17 +177,17 @@ public LeakRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double MillibarLitersPerSecond => As(LeakRateUnit.MillibarLiterPerSecond); + public QuantityValue MillibarLitersPerSecond => As(LeakRateUnit.MillibarLiterPerSecond); /// /// Gets a value of this quantity converted into /// - public double PascalCubicMetersPerSecond => As(LeakRateUnit.PascalCubicMeterPerSecond); + public QuantityValue PascalCubicMetersPerSecond => As(LeakRateUnit.PascalCubicMeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double TorrLitersPerSecond => As(LeakRateUnit.TorrLiterPerSecond); + public QuantityValue TorrLitersPerSecond => As(LeakRateUnit.TorrLiterPerSecond); #endregion @@ -238,7 +239,7 @@ public static string GetAbbreviation(LeakRateUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static LeakRate FromMillibarLitersPerSecond(double value) + public static LeakRate FromMillibarLitersPerSecond(QuantityValue value) { return new LeakRate(value, LeakRateUnit.MillibarLiterPerSecond); } @@ -246,7 +247,7 @@ public static LeakRate FromMillibarLitersPerSecond(double value) /// /// Creates a from . /// - public static LeakRate FromPascalCubicMetersPerSecond(double value) + public static LeakRate FromPascalCubicMetersPerSecond(QuantityValue value) { return new LeakRate(value, LeakRateUnit.PascalCubicMeterPerSecond); } @@ -254,7 +255,7 @@ public static LeakRate FromPascalCubicMetersPerSecond(double value) /// /// Creates a from . /// - public static LeakRate FromTorrLitersPerSecond(double value) + public static LeakRate FromTorrLitersPerSecond(QuantityValue value) { return new LeakRate(value, LeakRateUnit.TorrLiterPerSecond); } @@ -265,7 +266,7 @@ public static LeakRate FromTorrLitersPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// LeakRate unit value. - public static LeakRate From(double value, LeakRateUnit fromUnit) + public static LeakRate From(QuantityValue value, LeakRateUnit fromUnit) { return new LeakRate(value, fromUnit); } @@ -437,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out LeakR } /// Get from multiplying value and . - public static LeakRate operator *(double left, LeakRate right) + public static LeakRate operator *(QuantityValue left, LeakRate right) { return new LeakRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LeakRate operator *(LeakRate left, double right) + public static LeakRate operator *(LeakRate left, QuantityValue right) { return new LeakRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LeakRate operator /(LeakRate left, double right) + public static LeakRate operator /(LeakRate left, QuantityValue right) { return new LeakRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LeakRate left, LeakRate right) + public static QuantityValue operator /(LeakRate left, LeakRate right) { return left.PascalCubicMetersPerSecond / right.PascalCubicMetersPerSecond; } @@ -488,27 +489,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out LeakR return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(LeakRate left, LeakRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LeakRate other, LeakRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(LeakRate left, LeakRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is LeakRate otherQuantity)) @@ -518,15 +512,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(LeakRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -609,10 +600,10 @@ public bool Equals(LeakRate other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -629,7 +620,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LeakRate other, LeakRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -642,7 +633,12 @@ public bool Equals(LeakRate other, LeakRate tolerance) /// A hash code for the current LeakRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -653,7 +649,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LeakRateUnit unit) + public QuantityValue As(LeakRateUnit unit) { if (Unit == unit) return Value; @@ -662,7 +658,7 @@ public double As(LeakRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -677,7 +673,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LeakRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LeakRateUnit)} is supported.", nameof(unit)); @@ -744,11 +740,11 @@ private bool TryToUnit(LeakRateUnit unit, [NotNullWhen(true)] out LeakRate? conv { // LeakRateUnit -> BaseUnit (LeakRateUnit.MillibarLiterPerSecond, LeakRateUnit.PascalCubicMeterPerSecond) => new LeakRate(_value / 10, LeakRateUnit.PascalCubicMeterPerSecond), - (LeakRateUnit.TorrLiterPerSecond, LeakRateUnit.PascalCubicMeterPerSecond) => new LeakRate(_value / 7.5, LeakRateUnit.PascalCubicMeterPerSecond), + (LeakRateUnit.TorrLiterPerSecond, LeakRateUnit.PascalCubicMeterPerSecond) => new LeakRate(_value * new QuantityValue(2, 15, false), LeakRateUnit.PascalCubicMeterPerSecond), // BaseUnit -> LeakRateUnit (LeakRateUnit.PascalCubicMeterPerSecond, LeakRateUnit.MillibarLiterPerSecond) => new LeakRate(_value * 10, LeakRateUnit.MillibarLiterPerSecond), - (LeakRateUnit.PascalCubicMeterPerSecond, LeakRateUnit.TorrLiterPerSecond) => new LeakRate(_value * 7.5, LeakRateUnit.TorrLiterPerSecond), + (LeakRateUnit.PascalCubicMeterPerSecond, LeakRateUnit.TorrLiterPerSecond) => new LeakRate(_value * new QuantityValue(15, 2, false), LeakRateUnit.TorrLiterPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 6e4ae98f80..d8a6bb16e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -43,6 +41,7 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, IDivisionOperators, IMultiplyOperators, @@ -50,12 +49,15 @@ namespace UnitsNet IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, + IDivisionOperators, IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, + IDivisionOperators, #endif IComparable, IComparable, @@ -67,7 +69,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -138,7 +140,7 @@ static Length() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Length(double value, LengthUnit unit) + public Length(QuantityValue value, LengthUnit unit) { _value = value; _unit = unit; @@ -152,7 +154,7 @@ public Length(double value, LengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Length(double value, UnitSystem unitSystem) + public Length(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -203,10 +205,10 @@ public Length(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -231,212 +233,212 @@ public Length(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Angstroms => As(LengthUnit.Angstrom); + public QuantityValue Angstroms => As(LengthUnit.Angstrom); /// /// Gets a value of this quantity converted into /// - public double AstronomicalUnits => As(LengthUnit.AstronomicalUnit); + public QuantityValue AstronomicalUnits => As(LengthUnit.AstronomicalUnit); /// /// Gets a value of this quantity converted into /// - public double Centimeters => As(LengthUnit.Centimeter); + public QuantityValue Centimeters => As(LengthUnit.Centimeter); /// /// Gets a value of this quantity converted into /// - public double Chains => As(LengthUnit.Chain); + public QuantityValue Chains => As(LengthUnit.Chain); /// /// Gets a value of this quantity converted into /// - public double DataMiles => As(LengthUnit.DataMile); + public QuantityValue DataMiles => As(LengthUnit.DataMile); /// /// Gets a value of this quantity converted into /// - public double Decameters => As(LengthUnit.Decameter); + public QuantityValue Decameters => As(LengthUnit.Decameter); /// /// Gets a value of this quantity converted into /// - public double Decimeters => As(LengthUnit.Decimeter); + public QuantityValue Decimeters => As(LengthUnit.Decimeter); /// /// Gets a value of this quantity converted into /// - public double DtpPicas => As(LengthUnit.DtpPica); + public QuantityValue DtpPicas => As(LengthUnit.DtpPica); /// /// Gets a value of this quantity converted into /// - public double DtpPoints => As(LengthUnit.DtpPoint); + public QuantityValue DtpPoints => As(LengthUnit.DtpPoint); /// /// Gets a value of this quantity converted into /// - public double Fathoms => As(LengthUnit.Fathom); + public QuantityValue Fathoms => As(LengthUnit.Fathom); /// /// Gets a value of this quantity converted into /// - public double Femtometers => As(LengthUnit.Femtometer); + public QuantityValue Femtometers => As(LengthUnit.Femtometer); /// /// Gets a value of this quantity converted into /// - public double Feet => As(LengthUnit.Foot); + public QuantityValue Feet => As(LengthUnit.Foot); /// /// Gets a value of this quantity converted into /// - public double Gigameters => As(LengthUnit.Gigameter); + public QuantityValue Gigameters => As(LengthUnit.Gigameter); /// /// Gets a value of this quantity converted into /// - public double Hands => As(LengthUnit.Hand); + public QuantityValue Hands => As(LengthUnit.Hand); /// /// Gets a value of this quantity converted into /// - public double Hectometers => As(LengthUnit.Hectometer); + public QuantityValue Hectometers => As(LengthUnit.Hectometer); /// /// Gets a value of this quantity converted into /// - public double Inches => As(LengthUnit.Inch); + public QuantityValue Inches => As(LengthUnit.Inch); /// /// Gets a value of this quantity converted into /// - public double Kilofeet => As(LengthUnit.Kilofoot); + public QuantityValue Kilofeet => As(LengthUnit.Kilofoot); /// /// Gets a value of this quantity converted into /// - public double KilolightYears => As(LengthUnit.KilolightYear); + public QuantityValue KilolightYears => As(LengthUnit.KilolightYear); /// /// Gets a value of this quantity converted into /// - public double Kilometers => As(LengthUnit.Kilometer); + public QuantityValue Kilometers => As(LengthUnit.Kilometer); /// /// Gets a value of this quantity converted into /// - public double Kiloparsecs => As(LengthUnit.Kiloparsec); + public QuantityValue Kiloparsecs => As(LengthUnit.Kiloparsec); /// /// Gets a value of this quantity converted into /// - public double Kiloyards => As(LengthUnit.Kiloyard); + public QuantityValue Kiloyards => As(LengthUnit.Kiloyard); /// /// Gets a value of this quantity converted into /// - public double LightYears => As(LengthUnit.LightYear); + public QuantityValue LightYears => As(LengthUnit.LightYear); /// /// Gets a value of this quantity converted into /// - public double MegalightYears => As(LengthUnit.MegalightYear); + public QuantityValue MegalightYears => As(LengthUnit.MegalightYear); /// /// Gets a value of this quantity converted into /// - public double Megameters => As(LengthUnit.Megameter); + public QuantityValue Megameters => As(LengthUnit.Megameter); /// /// Gets a value of this quantity converted into /// - public double Megaparsecs => As(LengthUnit.Megaparsec); + public QuantityValue Megaparsecs => As(LengthUnit.Megaparsec); /// /// Gets a value of this quantity converted into /// - public double Meters => As(LengthUnit.Meter); + public QuantityValue Meters => As(LengthUnit.Meter); /// /// Gets a value of this quantity converted into /// - public double Microinches => As(LengthUnit.Microinch); + public QuantityValue Microinches => As(LengthUnit.Microinch); /// /// Gets a value of this quantity converted into /// - public double Micrometers => As(LengthUnit.Micrometer); + public QuantityValue Micrometers => As(LengthUnit.Micrometer); /// /// Gets a value of this quantity converted into /// - public double Mils => As(LengthUnit.Mil); + public QuantityValue Mils => As(LengthUnit.Mil); /// /// Gets a value of this quantity converted into /// - public double Miles => As(LengthUnit.Mile); + public QuantityValue Miles => As(LengthUnit.Mile); /// /// Gets a value of this quantity converted into /// - public double Millimeters => As(LengthUnit.Millimeter); + public QuantityValue Millimeters => As(LengthUnit.Millimeter); /// /// Gets a value of this quantity converted into /// - public double Nanometers => As(LengthUnit.Nanometer); + public QuantityValue Nanometers => As(LengthUnit.Nanometer); /// /// Gets a value of this quantity converted into /// - public double NauticalMiles => As(LengthUnit.NauticalMile); + public QuantityValue NauticalMiles => As(LengthUnit.NauticalMile); /// /// Gets a value of this quantity converted into /// - public double Parsecs => As(LengthUnit.Parsec); + public QuantityValue Parsecs => As(LengthUnit.Parsec); /// /// Gets a value of this quantity converted into /// - public double Picometers => As(LengthUnit.Picometer); + public QuantityValue Picometers => As(LengthUnit.Picometer); /// /// Gets a value of this quantity converted into /// - public double PrinterPicas => As(LengthUnit.PrinterPica); + public QuantityValue PrinterPicas => As(LengthUnit.PrinterPica); /// /// Gets a value of this quantity converted into /// - public double PrinterPoints => As(LengthUnit.PrinterPoint); + public QuantityValue PrinterPoints => As(LengthUnit.PrinterPoint); /// /// Gets a value of this quantity converted into /// - public double Shackles => As(LengthUnit.Shackle); + public QuantityValue Shackles => As(LengthUnit.Shackle); /// /// Gets a value of this quantity converted into /// - public double SolarRadiuses => As(LengthUnit.SolarRadius); + public QuantityValue SolarRadiuses => As(LengthUnit.SolarRadius); /// /// Gets a value of this quantity converted into /// - public double Twips => As(LengthUnit.Twip); + public QuantityValue Twips => As(LengthUnit.Twip); /// /// Gets a value of this quantity converted into /// - public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot); + public QuantityValue UsSurveyFeet => As(LengthUnit.UsSurveyFoot); /// /// Gets a value of this quantity converted into /// - public double Yards => As(LengthUnit.Yard); + public QuantityValue Yards => As(LengthUnit.Yard); #endregion @@ -566,7 +568,7 @@ public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Length FromAngstroms(double value) + public static Length FromAngstroms(QuantityValue value) { return new Length(value, LengthUnit.Angstrom); } @@ -574,7 +576,7 @@ public static Length FromAngstroms(double value) /// /// Creates a from . /// - public static Length FromAstronomicalUnits(double value) + public static Length FromAstronomicalUnits(QuantityValue value) { return new Length(value, LengthUnit.AstronomicalUnit); } @@ -582,7 +584,7 @@ public static Length FromAstronomicalUnits(double value) /// /// Creates a from . /// - public static Length FromCentimeters(double value) + public static Length FromCentimeters(QuantityValue value) { return new Length(value, LengthUnit.Centimeter); } @@ -590,7 +592,7 @@ public static Length FromCentimeters(double value) /// /// Creates a from . /// - public static Length FromChains(double value) + public static Length FromChains(QuantityValue value) { return new Length(value, LengthUnit.Chain); } @@ -598,7 +600,7 @@ public static Length FromChains(double value) /// /// Creates a from . /// - public static Length FromDataMiles(double value) + public static Length FromDataMiles(QuantityValue value) { return new Length(value, LengthUnit.DataMile); } @@ -606,7 +608,7 @@ public static Length FromDataMiles(double value) /// /// Creates a from . /// - public static Length FromDecameters(double value) + public static Length FromDecameters(QuantityValue value) { return new Length(value, LengthUnit.Decameter); } @@ -614,7 +616,7 @@ public static Length FromDecameters(double value) /// /// Creates a from . /// - public static Length FromDecimeters(double value) + public static Length FromDecimeters(QuantityValue value) { return new Length(value, LengthUnit.Decimeter); } @@ -622,7 +624,7 @@ public static Length FromDecimeters(double value) /// /// Creates a from . /// - public static Length FromDtpPicas(double value) + public static Length FromDtpPicas(QuantityValue value) { return new Length(value, LengthUnit.DtpPica); } @@ -630,7 +632,7 @@ public static Length FromDtpPicas(double value) /// /// Creates a from . /// - public static Length FromDtpPoints(double value) + public static Length FromDtpPoints(QuantityValue value) { return new Length(value, LengthUnit.DtpPoint); } @@ -638,7 +640,7 @@ public static Length FromDtpPoints(double value) /// /// Creates a from . /// - public static Length FromFathoms(double value) + public static Length FromFathoms(QuantityValue value) { return new Length(value, LengthUnit.Fathom); } @@ -646,7 +648,7 @@ public static Length FromFathoms(double value) /// /// Creates a from . /// - public static Length FromFemtometers(double value) + public static Length FromFemtometers(QuantityValue value) { return new Length(value, LengthUnit.Femtometer); } @@ -654,7 +656,7 @@ public static Length FromFemtometers(double value) /// /// Creates a from . /// - public static Length FromFeet(double value) + public static Length FromFeet(QuantityValue value) { return new Length(value, LengthUnit.Foot); } @@ -662,7 +664,7 @@ public static Length FromFeet(double value) /// /// Creates a from . /// - public static Length FromGigameters(double value) + public static Length FromGigameters(QuantityValue value) { return new Length(value, LengthUnit.Gigameter); } @@ -670,7 +672,7 @@ public static Length FromGigameters(double value) /// /// Creates a from . /// - public static Length FromHands(double value) + public static Length FromHands(QuantityValue value) { return new Length(value, LengthUnit.Hand); } @@ -678,7 +680,7 @@ public static Length FromHands(double value) /// /// Creates a from . /// - public static Length FromHectometers(double value) + public static Length FromHectometers(QuantityValue value) { return new Length(value, LengthUnit.Hectometer); } @@ -686,7 +688,7 @@ public static Length FromHectometers(double value) /// /// Creates a from . /// - public static Length FromInches(double value) + public static Length FromInches(QuantityValue value) { return new Length(value, LengthUnit.Inch); } @@ -694,7 +696,7 @@ public static Length FromInches(double value) /// /// Creates a from . /// - public static Length FromKilofeet(double value) + public static Length FromKilofeet(QuantityValue value) { return new Length(value, LengthUnit.Kilofoot); } @@ -702,7 +704,7 @@ public static Length FromKilofeet(double value) /// /// Creates a from . /// - public static Length FromKilolightYears(double value) + public static Length FromKilolightYears(QuantityValue value) { return new Length(value, LengthUnit.KilolightYear); } @@ -710,7 +712,7 @@ public static Length FromKilolightYears(double value) /// /// Creates a from . /// - public static Length FromKilometers(double value) + public static Length FromKilometers(QuantityValue value) { return new Length(value, LengthUnit.Kilometer); } @@ -718,7 +720,7 @@ public static Length FromKilometers(double value) /// /// Creates a from . /// - public static Length FromKiloparsecs(double value) + public static Length FromKiloparsecs(QuantityValue value) { return new Length(value, LengthUnit.Kiloparsec); } @@ -726,7 +728,7 @@ public static Length FromKiloparsecs(double value) /// /// Creates a from . /// - public static Length FromKiloyards(double value) + public static Length FromKiloyards(QuantityValue value) { return new Length(value, LengthUnit.Kiloyard); } @@ -734,7 +736,7 @@ public static Length FromKiloyards(double value) /// /// Creates a from . /// - public static Length FromLightYears(double value) + public static Length FromLightYears(QuantityValue value) { return new Length(value, LengthUnit.LightYear); } @@ -742,7 +744,7 @@ public static Length FromLightYears(double value) /// /// Creates a from . /// - public static Length FromMegalightYears(double value) + public static Length FromMegalightYears(QuantityValue value) { return new Length(value, LengthUnit.MegalightYear); } @@ -750,7 +752,7 @@ public static Length FromMegalightYears(double value) /// /// Creates a from . /// - public static Length FromMegameters(double value) + public static Length FromMegameters(QuantityValue value) { return new Length(value, LengthUnit.Megameter); } @@ -758,7 +760,7 @@ public static Length FromMegameters(double value) /// /// Creates a from . /// - public static Length FromMegaparsecs(double value) + public static Length FromMegaparsecs(QuantityValue value) { return new Length(value, LengthUnit.Megaparsec); } @@ -766,7 +768,7 @@ public static Length FromMegaparsecs(double value) /// /// Creates a from . /// - public static Length FromMeters(double value) + public static Length FromMeters(QuantityValue value) { return new Length(value, LengthUnit.Meter); } @@ -774,7 +776,7 @@ public static Length FromMeters(double value) /// /// Creates a from . /// - public static Length FromMicroinches(double value) + public static Length FromMicroinches(QuantityValue value) { return new Length(value, LengthUnit.Microinch); } @@ -782,7 +784,7 @@ public static Length FromMicroinches(double value) /// /// Creates a from . /// - public static Length FromMicrometers(double value) + public static Length FromMicrometers(QuantityValue value) { return new Length(value, LengthUnit.Micrometer); } @@ -790,7 +792,7 @@ public static Length FromMicrometers(double value) /// /// Creates a from . /// - public static Length FromMils(double value) + public static Length FromMils(QuantityValue value) { return new Length(value, LengthUnit.Mil); } @@ -798,7 +800,7 @@ public static Length FromMils(double value) /// /// Creates a from . /// - public static Length FromMiles(double value) + public static Length FromMiles(QuantityValue value) { return new Length(value, LengthUnit.Mile); } @@ -806,7 +808,7 @@ public static Length FromMiles(double value) /// /// Creates a from . /// - public static Length FromMillimeters(double value) + public static Length FromMillimeters(QuantityValue value) { return new Length(value, LengthUnit.Millimeter); } @@ -814,7 +816,7 @@ public static Length FromMillimeters(double value) /// /// Creates a from . /// - public static Length FromNanometers(double value) + public static Length FromNanometers(QuantityValue value) { return new Length(value, LengthUnit.Nanometer); } @@ -822,7 +824,7 @@ public static Length FromNanometers(double value) /// /// Creates a from . /// - public static Length FromNauticalMiles(double value) + public static Length FromNauticalMiles(QuantityValue value) { return new Length(value, LengthUnit.NauticalMile); } @@ -830,7 +832,7 @@ public static Length FromNauticalMiles(double value) /// /// Creates a from . /// - public static Length FromParsecs(double value) + public static Length FromParsecs(QuantityValue value) { return new Length(value, LengthUnit.Parsec); } @@ -838,7 +840,7 @@ public static Length FromParsecs(double value) /// /// Creates a from . /// - public static Length FromPicometers(double value) + public static Length FromPicometers(QuantityValue value) { return new Length(value, LengthUnit.Picometer); } @@ -846,7 +848,7 @@ public static Length FromPicometers(double value) /// /// Creates a from . /// - public static Length FromPrinterPicas(double value) + public static Length FromPrinterPicas(QuantityValue value) { return new Length(value, LengthUnit.PrinterPica); } @@ -854,7 +856,7 @@ public static Length FromPrinterPicas(double value) /// /// Creates a from . /// - public static Length FromPrinterPoints(double value) + public static Length FromPrinterPoints(QuantityValue value) { return new Length(value, LengthUnit.PrinterPoint); } @@ -862,7 +864,7 @@ public static Length FromPrinterPoints(double value) /// /// Creates a from . /// - public static Length FromShackles(double value) + public static Length FromShackles(QuantityValue value) { return new Length(value, LengthUnit.Shackle); } @@ -870,7 +872,7 @@ public static Length FromShackles(double value) /// /// Creates a from . /// - public static Length FromSolarRadiuses(double value) + public static Length FromSolarRadiuses(QuantityValue value) { return new Length(value, LengthUnit.SolarRadius); } @@ -878,7 +880,7 @@ public static Length FromSolarRadiuses(double value) /// /// Creates a from . /// - public static Length FromTwips(double value) + public static Length FromTwips(QuantityValue value) { return new Length(value, LengthUnit.Twip); } @@ -886,7 +888,7 @@ public static Length FromTwips(double value) /// /// Creates a from . /// - public static Length FromUsSurveyFeet(double value) + public static Length FromUsSurveyFeet(QuantityValue value) { return new Length(value, LengthUnit.UsSurveyFoot); } @@ -894,7 +896,7 @@ public static Length FromUsSurveyFeet(double value) /// /// Creates a from . /// - public static Length FromYards(double value) + public static Length FromYards(QuantityValue value) { return new Length(value, LengthUnit.Yard); } @@ -905,7 +907,7 @@ public static Length FromYards(double value) /// Value to convert from. /// Unit to convert from. /// Length unit value. - public static Length From(double value, LengthUnit fromUnit) + public static Length From(QuantityValue value, LengthUnit fromUnit) { return new Length(value, fromUnit); } @@ -1077,25 +1079,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt } /// Get from multiplying value and . - public static Length operator *(double left, Length right) + public static Length operator *(QuantityValue left, Length right) { return new Length(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Length operator *(Length left, double right) + public static Length operator *(Length left, QuantityValue right) { return new Length(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Length operator /(Length left, double right) + public static Length operator /(Length left, QuantityValue right) { return new Length(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Length left, Length right) + public static QuantityValue operator /(Length left, Length right) { return left.Meters / right.Meters; } @@ -1108,7 +1110,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt /// The corresponding inverse quantity, . public ReciprocalLength Inverse() { - return Meters == 0.0 ? ReciprocalLength.Zero : ReciprocalLength.FromInverseMeters(1 / Meters); + return ReciprocalLength.FromInverseMeters(QuantityValue.Inverse(Meters)); } /// Get from * . @@ -1117,6 +1119,12 @@ public ReciprocalLength Inverse() return Area.FromSquareMeters(left.Meters * right.Meters); } + /// Get from / . + public static Area operator /(Length length, ReciprocalLength reciprocalLength) + { + return Area.FromSquareMeters(length.Meters / reciprocalLength.InverseMeters); + } + /// Get from * . public static AreaMomentOfInertia operator *(Length length, Volume volume) { @@ -1159,12 +1167,24 @@ public ReciprocalLength Inverse() return Pressure.FromPascals(length.Meters * specificWeight.NewtonsPerCubicMeter); } + /// Get from / . + public static ReciprocalArea operator /(Length length, Volume volume) + { + return ReciprocalArea.FromInverseSquareMeters(length.Meters / volume.CubicMeters); + } + /// Get from * . public static ReciprocalLength operator *(Length length, ReciprocalArea reciprocalArea) { return ReciprocalLength.FromInverseMeters(length.Meters * reciprocalArea.InverseSquareMeters); } + /// Get from / . + public static ReciprocalLength operator /(Length length, Area area) + { + return ReciprocalLength.FromInverseMeters(length.Meters / area.SquareMeters); + } + /// Get from * . public static RotationalStiffness operator *(Length length, RotationalStiffnessPerLength rotationalStiffnessPerLength) { @@ -1195,6 +1215,12 @@ public ReciprocalLength Inverse() return Volume.FromCubicMeters(length.Meters * area.SquareMeters); } + /// Get from / . + public static Volume operator /(Length length, ReciprocalArea reciprocalArea) + { + return Volume.FromCubicMeters(length.Meters / reciprocalArea.InverseSquareMeters); + } + #endregion #region Equality / IComparable @@ -1223,27 +1249,20 @@ public ReciprocalLength Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Length left, Length right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Length other, Length tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Length left, Length right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Length otherQuantity)) @@ -1253,15 +1272,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Length other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1344,10 +1360,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1364,7 +1380,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Length other, Length tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1377,7 +1393,12 @@ public bool Equals(Length other, Length tolerance) /// A hash code for the current Length. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1388,7 +1409,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LengthUnit unit) + public QuantityValue As(LengthUnit unit) { if (Unit == unit) return Value; @@ -1397,7 +1418,7 @@ public double As(LengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1412,7 +1433,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); @@ -1478,90 +1499,90 @@ private bool TryToUnit(LengthUnit unit, [NotNullWhen(true)] out Length? converte Length? convertedOrNull = (Unit, unit) switch { // LengthUnit -> BaseUnit - (LengthUnit.Angstrom, LengthUnit.Meter) => new Length(_value * 1e-10, LengthUnit.Meter), - (LengthUnit.AstronomicalUnit, LengthUnit.Meter) => new Length(_value * 1.4959787070e11, LengthUnit.Meter), - (LengthUnit.Centimeter, LengthUnit.Meter) => new Length((_value) * 1e-2d, LengthUnit.Meter), - (LengthUnit.Chain, LengthUnit.Meter) => new Length(_value * 20.1168, LengthUnit.Meter), - (LengthUnit.DataMile, LengthUnit.Meter) => new Length(_value * 1828.8, LengthUnit.Meter), - (LengthUnit.Decameter, LengthUnit.Meter) => new Length((_value) * 1e1d, LengthUnit.Meter), - (LengthUnit.Decimeter, LengthUnit.Meter) => new Length((_value) * 1e-1d, LengthUnit.Meter), - (LengthUnit.DtpPica, LengthUnit.Meter) => new Length(_value / 236.220472441, LengthUnit.Meter), - (LengthUnit.DtpPoint, LengthUnit.Meter) => new Length((_value / 72) * 2.54e-2, LengthUnit.Meter), - (LengthUnit.Fathom, LengthUnit.Meter) => new Length(_value * 1.8288, LengthUnit.Meter), - (LengthUnit.Femtometer, LengthUnit.Meter) => new Length((_value) * 1e-15d, LengthUnit.Meter), - (LengthUnit.Foot, LengthUnit.Meter) => new Length(_value * 0.3048, LengthUnit.Meter), - (LengthUnit.Gigameter, LengthUnit.Meter) => new Length((_value) * 1e9d, LengthUnit.Meter), - (LengthUnit.Hand, LengthUnit.Meter) => new Length(_value * 1.016e-1, LengthUnit.Meter), - (LengthUnit.Hectometer, LengthUnit.Meter) => new Length((_value) * 1e2d, LengthUnit.Meter), - (LengthUnit.Inch, LengthUnit.Meter) => new Length(_value * 2.54e-2, LengthUnit.Meter), - (LengthUnit.Kilofoot, LengthUnit.Meter) => new Length((_value * 0.3048) * 1e3d, LengthUnit.Meter), - (LengthUnit.KilolightYear, LengthUnit.Meter) => new Length((_value * 9.46073047258e15) * 1e3d, LengthUnit.Meter), - (LengthUnit.Kilometer, LengthUnit.Meter) => new Length((_value) * 1e3d, LengthUnit.Meter), - (LengthUnit.Kiloparsec, LengthUnit.Meter) => new Length((_value * 3.08567758128e16) * 1e3d, LengthUnit.Meter), - (LengthUnit.Kiloyard, LengthUnit.Meter) => new Length((_value * 0.9144) * 1e3d, LengthUnit.Meter), - (LengthUnit.LightYear, LengthUnit.Meter) => new Length(_value * 9.46073047258e15, LengthUnit.Meter), - (LengthUnit.MegalightYear, LengthUnit.Meter) => new Length((_value * 9.46073047258e15) * 1e6d, LengthUnit.Meter), - (LengthUnit.Megameter, LengthUnit.Meter) => new Length((_value) * 1e6d, LengthUnit.Meter), - (LengthUnit.Megaparsec, LengthUnit.Meter) => new Length((_value * 3.08567758128e16) * 1e6d, LengthUnit.Meter), - (LengthUnit.Microinch, LengthUnit.Meter) => new Length(_value * 2.54e-8, LengthUnit.Meter), - (LengthUnit.Micrometer, LengthUnit.Meter) => new Length((_value) * 1e-6d, LengthUnit.Meter), - (LengthUnit.Mil, LengthUnit.Meter) => new Length(_value * 2.54e-5, LengthUnit.Meter), - (LengthUnit.Mile, LengthUnit.Meter) => new Length(_value * 1609.344, LengthUnit.Meter), - (LengthUnit.Millimeter, LengthUnit.Meter) => new Length((_value) * 1e-3d, LengthUnit.Meter), - (LengthUnit.Nanometer, LengthUnit.Meter) => new Length((_value) * 1e-9d, LengthUnit.Meter), + (LengthUnit.Angstrom, LengthUnit.Meter) => new Length(_value / 10000000000, LengthUnit.Meter), + (LengthUnit.AstronomicalUnit, LengthUnit.Meter) => new Length(_value * 149597870700, LengthUnit.Meter), + (LengthUnit.Centimeter, LengthUnit.Meter) => new Length(_value / 100, LengthUnit.Meter), + (LengthUnit.Chain, LengthUnit.Meter) => new Length(_value * new QuantityValue(12573, 625, false), LengthUnit.Meter), + (LengthUnit.DataMile, LengthUnit.Meter) => new Length(_value * new QuantityValue(9144, 5, false), LengthUnit.Meter), + (LengthUnit.Decameter, LengthUnit.Meter) => new Length(_value * 10, LengthUnit.Meter), + (LengthUnit.Decimeter, LengthUnit.Meter) => new Length(_value / 10, LengthUnit.Meter), + (LengthUnit.DtpPica, LengthUnit.Meter) => new Length(_value * new QuantityValue(1000000000, 236220472441, false), LengthUnit.Meter), + (LengthUnit.DtpPoint, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 360000, false), LengthUnit.Meter), + (LengthUnit.Fathom, LengthUnit.Meter) => new Length(_value * new QuantityValue(1143, 625, false), LengthUnit.Meter), + (LengthUnit.Femtometer, LengthUnit.Meter) => new Length(_value / 1000000000000000, LengthUnit.Meter), + (LengthUnit.Foot, LengthUnit.Meter) => new Length(_value * new QuantityValue(381, 1250, false), LengthUnit.Meter), + (LengthUnit.Gigameter, LengthUnit.Meter) => new Length(_value * 1000000000, LengthUnit.Meter), + (LengthUnit.Hand, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 1250, false), LengthUnit.Meter), + (LengthUnit.Hectometer, LengthUnit.Meter) => new Length(_value * 100, LengthUnit.Meter), + (LengthUnit.Inch, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 5000, false), LengthUnit.Meter), + (LengthUnit.Kilofoot, LengthUnit.Meter) => new Length(_value * new QuantityValue(1524, 5, false), LengthUnit.Meter), + (LengthUnit.KilolightYear, LengthUnit.Meter) => new Length(_value * new QuantityValue(473036523629, 500000000000, false) * BigInteger.Pow(10, 19), LengthUnit.Meter), + (LengthUnit.Kilometer, LengthUnit.Meter) => new Length(_value * 1000, LengthUnit.Meter), + (LengthUnit.Kiloparsec, LengthUnit.Meter) => new Length(_value * new QuantityValue(19285484883, 6250000000, false) * BigInteger.Pow(10, 19), LengthUnit.Meter), + (LengthUnit.Kiloyard, LengthUnit.Meter) => new Length(_value * new QuantityValue(4572, 5, false), LengthUnit.Meter), + (LengthUnit.LightYear, LengthUnit.Meter) => new Length(_value * 9460730472580000, LengthUnit.Meter), + (LengthUnit.MegalightYear, LengthUnit.Meter) => new Length(_value * new QuantityValue(473036523629, 500000000, false) * BigInteger.Pow(10, 19), LengthUnit.Meter), + (LengthUnit.Megameter, LengthUnit.Meter) => new Length(_value * 1000000, LengthUnit.Meter), + (LengthUnit.Megaparsec, LengthUnit.Meter) => new Length(_value * new QuantityValue(19285484883, 6250000, false) * BigInteger.Pow(10, 19), LengthUnit.Meter), + (LengthUnit.Microinch, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 5000000000, false), LengthUnit.Meter), + (LengthUnit.Micrometer, LengthUnit.Meter) => new Length(_value / 1000000, LengthUnit.Meter), + (LengthUnit.Mil, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 5000000, false), LengthUnit.Meter), + (LengthUnit.Mile, LengthUnit.Meter) => new Length(_value * new QuantityValue(201168, 125, false), LengthUnit.Meter), + (LengthUnit.Millimeter, LengthUnit.Meter) => new Length(_value / 1000, LengthUnit.Meter), + (LengthUnit.Nanometer, LengthUnit.Meter) => new Length(_value / 1000000000, LengthUnit.Meter), (LengthUnit.NauticalMile, LengthUnit.Meter) => new Length(_value * 1852, LengthUnit.Meter), - (LengthUnit.Parsec, LengthUnit.Meter) => new Length(_value * 3.08567758128e16, LengthUnit.Meter), - (LengthUnit.Picometer, LengthUnit.Meter) => new Length((_value) * 1e-12d, LengthUnit.Meter), - (LengthUnit.PrinterPica, LengthUnit.Meter) => new Length(_value / 237.106301584, LengthUnit.Meter), - (LengthUnit.PrinterPoint, LengthUnit.Meter) => new Length((_value / 72.27) * 2.54e-2, LengthUnit.Meter), - (LengthUnit.Shackle, LengthUnit.Meter) => new Length(_value * 27.432, LengthUnit.Meter), - (LengthUnit.SolarRadius, LengthUnit.Meter) => new Length(_value * 6.95510000E+08, LengthUnit.Meter), - (LengthUnit.Twip, LengthUnit.Meter) => new Length(_value / 56692.913385826, LengthUnit.Meter), - (LengthUnit.UsSurveyFoot, LengthUnit.Meter) => new Length(_value * 1200 / 3937, LengthUnit.Meter), - (LengthUnit.Yard, LengthUnit.Meter) => new Length(_value * 0.9144, LengthUnit.Meter), + (LengthUnit.Parsec, LengthUnit.Meter) => new Length(_value * 30856775812800000, LengthUnit.Meter), + (LengthUnit.Picometer, LengthUnit.Meter) => new Length(_value / 1000000000000, LengthUnit.Meter), + (LengthUnit.PrinterPica, LengthUnit.Meter) => new Length(_value * new QuantityValue(62500000, 14819143849, false), LengthUnit.Meter), + (LengthUnit.PrinterPoint, LengthUnit.Meter) => new Length(_value * new QuantityValue(127, 361350, false), LengthUnit.Meter), + (LengthUnit.Shackle, LengthUnit.Meter) => new Length(_value * new QuantityValue(3429, 125, false), LengthUnit.Meter), + (LengthUnit.SolarRadius, LengthUnit.Meter) => new Length(_value * 695510000, LengthUnit.Meter), + (LengthUnit.Twip, LengthUnit.Meter) => new Length(_value * new QuantityValue(500000000, 28346456692913, false), LengthUnit.Meter), + (LengthUnit.UsSurveyFoot, LengthUnit.Meter) => new Length(_value * new QuantityValue(1200, 3937, false), LengthUnit.Meter), + (LengthUnit.Yard, LengthUnit.Meter) => new Length(_value * new QuantityValue(1143, 1250, false), LengthUnit.Meter), // BaseUnit -> LengthUnit - (LengthUnit.Meter, LengthUnit.Angstrom) => new Length(_value / 1e-10, LengthUnit.Angstrom), - (LengthUnit.Meter, LengthUnit.AstronomicalUnit) => new Length(_value / 1.4959787070e11, LengthUnit.AstronomicalUnit), - (LengthUnit.Meter, LengthUnit.Centimeter) => new Length((_value) / 1e-2d, LengthUnit.Centimeter), - (LengthUnit.Meter, LengthUnit.Chain) => new Length(_value / 20.1168, LengthUnit.Chain), - (LengthUnit.Meter, LengthUnit.DataMile) => new Length(_value / 1828.8, LengthUnit.DataMile), - (LengthUnit.Meter, LengthUnit.Decameter) => new Length((_value) / 1e1d, LengthUnit.Decameter), - (LengthUnit.Meter, LengthUnit.Decimeter) => new Length((_value) / 1e-1d, LengthUnit.Decimeter), - (LengthUnit.Meter, LengthUnit.DtpPica) => new Length(_value * 236.220472441, LengthUnit.DtpPica), - (LengthUnit.Meter, LengthUnit.DtpPoint) => new Length((_value / 2.54e-2) * 72, LengthUnit.DtpPoint), - (LengthUnit.Meter, LengthUnit.Fathom) => new Length(_value / 1.8288, LengthUnit.Fathom), - (LengthUnit.Meter, LengthUnit.Femtometer) => new Length((_value) / 1e-15d, LengthUnit.Femtometer), - (LengthUnit.Meter, LengthUnit.Foot) => new Length(_value / 0.3048, LengthUnit.Foot), - (LengthUnit.Meter, LengthUnit.Gigameter) => new Length((_value) / 1e9d, LengthUnit.Gigameter), - (LengthUnit.Meter, LengthUnit.Hand) => new Length(_value / 1.016e-1, LengthUnit.Hand), - (LengthUnit.Meter, LengthUnit.Hectometer) => new Length((_value) / 1e2d, LengthUnit.Hectometer), - (LengthUnit.Meter, LengthUnit.Inch) => new Length(_value / 2.54e-2, LengthUnit.Inch), - (LengthUnit.Meter, LengthUnit.Kilofoot) => new Length((_value / 0.3048) / 1e3d, LengthUnit.Kilofoot), - (LengthUnit.Meter, LengthUnit.KilolightYear) => new Length((_value / 9.46073047258e15) / 1e3d, LengthUnit.KilolightYear), - (LengthUnit.Meter, LengthUnit.Kilometer) => new Length((_value) / 1e3d, LengthUnit.Kilometer), - (LengthUnit.Meter, LengthUnit.Kiloparsec) => new Length((_value / 3.08567758128e16) / 1e3d, LengthUnit.Kiloparsec), - (LengthUnit.Meter, LengthUnit.Kiloyard) => new Length((_value / 0.9144) / 1e3d, LengthUnit.Kiloyard), - (LengthUnit.Meter, LengthUnit.LightYear) => new Length(_value / 9.46073047258e15, LengthUnit.LightYear), - (LengthUnit.Meter, LengthUnit.MegalightYear) => new Length((_value / 9.46073047258e15) / 1e6d, LengthUnit.MegalightYear), - (LengthUnit.Meter, LengthUnit.Megameter) => new Length((_value) / 1e6d, LengthUnit.Megameter), - (LengthUnit.Meter, LengthUnit.Megaparsec) => new Length((_value / 3.08567758128e16) / 1e6d, LengthUnit.Megaparsec), - (LengthUnit.Meter, LengthUnit.Microinch) => new Length(_value / 2.54e-8, LengthUnit.Microinch), - (LengthUnit.Meter, LengthUnit.Micrometer) => new Length((_value) / 1e-6d, LengthUnit.Micrometer), - (LengthUnit.Meter, LengthUnit.Mil) => new Length(_value / 2.54e-5, LengthUnit.Mil), - (LengthUnit.Meter, LengthUnit.Mile) => new Length(_value / 1609.344, LengthUnit.Mile), - (LengthUnit.Meter, LengthUnit.Millimeter) => new Length((_value) / 1e-3d, LengthUnit.Millimeter), - (LengthUnit.Meter, LengthUnit.Nanometer) => new Length((_value) / 1e-9d, LengthUnit.Nanometer), + (LengthUnit.Meter, LengthUnit.Angstrom) => new Length(_value * 10000000000, LengthUnit.Angstrom), + (LengthUnit.Meter, LengthUnit.AstronomicalUnit) => new Length(_value / 149597870700, LengthUnit.AstronomicalUnit), + (LengthUnit.Meter, LengthUnit.Centimeter) => new Length(_value * 100, LengthUnit.Centimeter), + (LengthUnit.Meter, LengthUnit.Chain) => new Length(_value * new QuantityValue(625, 12573, false), LengthUnit.Chain), + (LengthUnit.Meter, LengthUnit.DataMile) => new Length(_value * new QuantityValue(5, 9144, false), LengthUnit.DataMile), + (LengthUnit.Meter, LengthUnit.Decameter) => new Length(_value / 10, LengthUnit.Decameter), + (LengthUnit.Meter, LengthUnit.Decimeter) => new Length(_value * 10, LengthUnit.Decimeter), + (LengthUnit.Meter, LengthUnit.DtpPica) => new Length(_value * new QuantityValue(236220472441, 1000000000, false), LengthUnit.DtpPica), + (LengthUnit.Meter, LengthUnit.DtpPoint) => new Length(_value * new QuantityValue(360000, 127, false), LengthUnit.DtpPoint), + (LengthUnit.Meter, LengthUnit.Fathom) => new Length(_value * new QuantityValue(625, 1143, false), LengthUnit.Fathom), + (LengthUnit.Meter, LengthUnit.Femtometer) => new Length(_value * 1000000000000000, LengthUnit.Femtometer), + (LengthUnit.Meter, LengthUnit.Foot) => new Length(_value * new QuantityValue(1250, 381, false), LengthUnit.Foot), + (LengthUnit.Meter, LengthUnit.Gigameter) => new Length(_value / 1000000000, LengthUnit.Gigameter), + (LengthUnit.Meter, LengthUnit.Hand) => new Length(_value * new QuantityValue(1250, 127, false), LengthUnit.Hand), + (LengthUnit.Meter, LengthUnit.Hectometer) => new Length(_value / 100, LengthUnit.Hectometer), + (LengthUnit.Meter, LengthUnit.Inch) => new Length(_value * new QuantityValue(5000, 127, false), LengthUnit.Inch), + (LengthUnit.Meter, LengthUnit.Kilofoot) => new Length(_value * new QuantityValue(5, 1524, false), LengthUnit.Kilofoot), + (LengthUnit.Meter, LengthUnit.KilolightYear) => new Length(_value * new QuantityValue(500000000000, 473036523629, false) / BigInteger.Pow(10, 19), LengthUnit.KilolightYear), + (LengthUnit.Meter, LengthUnit.Kilometer) => new Length(_value / 1000, LengthUnit.Kilometer), + (LengthUnit.Meter, LengthUnit.Kiloparsec) => new Length(_value * new QuantityValue(6250000000, 19285484883, false) / BigInteger.Pow(10, 19), LengthUnit.Kiloparsec), + (LengthUnit.Meter, LengthUnit.Kiloyard) => new Length(_value * new QuantityValue(5, 4572, false), LengthUnit.Kiloyard), + (LengthUnit.Meter, LengthUnit.LightYear) => new Length(_value / 9460730472580000, LengthUnit.LightYear), + (LengthUnit.Meter, LengthUnit.MegalightYear) => new Length(_value * new QuantityValue(500000000, 473036523629, false) / BigInteger.Pow(10, 19), LengthUnit.MegalightYear), + (LengthUnit.Meter, LengthUnit.Megameter) => new Length(_value / 1000000, LengthUnit.Megameter), + (LengthUnit.Meter, LengthUnit.Megaparsec) => new Length(_value * new QuantityValue(6250000, 19285484883, false) / BigInteger.Pow(10, 19), LengthUnit.Megaparsec), + (LengthUnit.Meter, LengthUnit.Microinch) => new Length(_value * new QuantityValue(5000000000, 127, false), LengthUnit.Microinch), + (LengthUnit.Meter, LengthUnit.Micrometer) => new Length(_value * 1000000, LengthUnit.Micrometer), + (LengthUnit.Meter, LengthUnit.Mil) => new Length(_value * new QuantityValue(5000000, 127, false), LengthUnit.Mil), + (LengthUnit.Meter, LengthUnit.Mile) => new Length(_value * new QuantityValue(125, 201168, false), LengthUnit.Mile), + (LengthUnit.Meter, LengthUnit.Millimeter) => new Length(_value * 1000, LengthUnit.Millimeter), + (LengthUnit.Meter, LengthUnit.Nanometer) => new Length(_value * 1000000000, LengthUnit.Nanometer), (LengthUnit.Meter, LengthUnit.NauticalMile) => new Length(_value / 1852, LengthUnit.NauticalMile), - (LengthUnit.Meter, LengthUnit.Parsec) => new Length(_value / 3.08567758128e16, LengthUnit.Parsec), - (LengthUnit.Meter, LengthUnit.Picometer) => new Length((_value) / 1e-12d, LengthUnit.Picometer), - (LengthUnit.Meter, LengthUnit.PrinterPica) => new Length(_value * 237.106301584, LengthUnit.PrinterPica), - (LengthUnit.Meter, LengthUnit.PrinterPoint) => new Length((_value / 2.54e-2) * 72.27, LengthUnit.PrinterPoint), - (LengthUnit.Meter, LengthUnit.Shackle) => new Length(_value / 27.432, LengthUnit.Shackle), - (LengthUnit.Meter, LengthUnit.SolarRadius) => new Length(_value / 6.95510000E+08, LengthUnit.SolarRadius), - (LengthUnit.Meter, LengthUnit.Twip) => new Length(_value * 56692.913385826, LengthUnit.Twip), - (LengthUnit.Meter, LengthUnit.UsSurveyFoot) => new Length(_value * 3937 / 1200, LengthUnit.UsSurveyFoot), - (LengthUnit.Meter, LengthUnit.Yard) => new Length(_value / 0.9144, LengthUnit.Yard), + (LengthUnit.Meter, LengthUnit.Parsec) => new Length(_value / 30856775812800000, LengthUnit.Parsec), + (LengthUnit.Meter, LengthUnit.Picometer) => new Length(_value * 1000000000000, LengthUnit.Picometer), + (LengthUnit.Meter, LengthUnit.PrinterPica) => new Length(_value * new QuantityValue(14819143849, 62500000, false), LengthUnit.PrinterPica), + (LengthUnit.Meter, LengthUnit.PrinterPoint) => new Length(_value * new QuantityValue(361350, 127, false), LengthUnit.PrinterPoint), + (LengthUnit.Meter, LengthUnit.Shackle) => new Length(_value * new QuantityValue(125, 3429, false), LengthUnit.Shackle), + (LengthUnit.Meter, LengthUnit.SolarRadius) => new Length(_value / 695510000, LengthUnit.SolarRadius), + (LengthUnit.Meter, LengthUnit.Twip) => new Length(_value * new QuantityValue(28346456692913, 500000000, false), LengthUnit.Twip), + (LengthUnit.Meter, LengthUnit.UsSurveyFoot) => new Length(_value * new QuantityValue(3937, 1200, false), LengthUnit.UsSurveyFoot), + (LengthUnit.Meter, LengthUnit.Yard) => new Length(_value * new QuantityValue(1250, 1143, false), LengthUnit.Yard), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 42decb4540..5760e8dc5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,7 +80,7 @@ static Level() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Level(double value, LevelUnit unit) + public Level(QuantityValue value, LevelUnit unit) { _value = value; _unit = unit; @@ -93,7 +94,7 @@ public Level(double value, LevelUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Level(double value, UnitSystem unitSystem) + public Level(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -144,10 +145,10 @@ public Level(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -172,12 +173,12 @@ public Level(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Decibels => As(LevelUnit.Decibel); + public QuantityValue Decibels => As(LevelUnit.Decibel); /// /// Gets a value of this quantity converted into /// - public double Nepers => As(LevelUnit.Neper); + public QuantityValue Nepers => As(LevelUnit.Neper); #endregion @@ -227,7 +228,7 @@ public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Level FromDecibels(double value) + public static Level FromDecibels(QuantityValue value) { return new Level(value, LevelUnit.Decibel); } @@ -235,7 +236,7 @@ public static Level FromDecibels(double value) /// /// Creates a from . /// - public static Level FromNepers(double value) + public static Level FromNepers(QuantityValue value) { return new Level(value, LevelUnit.Neper); } @@ -246,7 +247,7 @@ public static Level FromNepers(double value) /// Value to convert from. /// Unit to convert from. /// Level unit value. - public static Level From(double value, LevelUnit fromUnit) + public static Level From(QuantityValue value, LevelUnit fromUnit) { return new Level(value, fromUnit); } @@ -410,7 +411,10 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, left.Value / 10) + Math.Pow(10, right.ToUnit(left.Unit).Value / 10)), left.Unit); + // TODO see if we can switch to operating in linear space: left + right.ToUnit(left.Unit) + return new Level(10 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 10).ToDouble()) + Math.Pow(10, (right.ToUnit(left.Unit).Value / 10).ToDouble()))), + left.Unit); } /// Get from logarithmic subtraction of two . @@ -418,35 +422,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, left.Value / 10) - Math.Pow(10, right.ToUnit(left.Unit).Value / 10)), left.Unit); + // TODO see if we can switch to operating in linear space: left - right.ToUnit(left.Unit) + return new Level(10 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 10).ToDouble()) - Math.Pow(10, (right.ToUnit(left.Unit).Value / 10).ToDouble()))), + left.Unit); } /// Get from logarithmic multiplication of value and . - public static Level operator *(double left, Level right) + public static Level operator *(QuantityValue left, Level right) { // Logarithmic multiplication = addition + // TODO see if we can switch to operating in linear space: left * right.ToUnit(left.Unit) return new Level(left + right.Value, right.Unit); } /// Get from logarithmic multiplication of value and . - public static Level operator *(Level left, double right) + public static Level operator *(Level left, QuantityValue right) { // Logarithmic multiplication = addition return new Level(left.Value + right, left.Unit); } /// Get from logarithmic division of by value. - public static Level operator /(Level left, double right) + public static Level operator /(Level left, QuantityValue right) { // Logarithmic division = subtraction return new Level(left.Value - right, left.Unit); } /// Get ratio value from logarithmic division of by . - public static double operator /(Level left, Level right) + public static QuantityValue operator /(Level left, Level right) { // Logarithmic division = subtraction - return Convert.ToDouble(left.Value - right.ToUnit(left.Unit).Value); + return left.Value - right.ToUnit(left.Unit).Value; } #endregion @@ -477,27 +485,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Level left, Level right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Level other, Level tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Level left, Level right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Level otherQuantity)) @@ -507,15 +508,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Level other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -598,10 +596,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -618,7 +616,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Level other, Level tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -631,7 +629,12 @@ public bool Equals(Level other, Level tolerance) /// A hash code for the current Level. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -642,7 +645,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LevelUnit unit) + public QuantityValue As(LevelUnit unit) { if (Unit == unit) return Value; @@ -651,7 +654,7 @@ public double As(LevelUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -666,7 +669,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); @@ -732,10 +735,10 @@ private bool TryToUnit(LevelUnit unit, [NotNullWhen(true)] out Level? converted) Level? convertedOrNull = (Unit, unit) switch { // LevelUnit -> BaseUnit - (LevelUnit.Neper, LevelUnit.Decibel) => new Level((1 / 0.115129254) * _value, LevelUnit.Decibel), + (LevelUnit.Neper, LevelUnit.Decibel) => new Level(_value * new QuantityValue(500000000, 57564627, false), LevelUnit.Decibel), // BaseUnit -> LevelUnit - (LevelUnit.Decibel, LevelUnit.Neper) => new Level(0.115129254 * _value, LevelUnit.Neper), + (LevelUnit.Decibel, LevelUnit.Neper) => new Level(_value * new QuantityValue(57564627, 500000000, false), LevelUnit.Neper), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 026370d388..fb32a0f57a 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -59,7 +57,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -102,7 +100,7 @@ static LinearDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public LinearDensity(double value, LinearDensityUnit unit) + public LinearDensity(QuantityValue value, LinearDensityUnit unit) { _value = value; _unit = unit; @@ -116,7 +114,7 @@ public LinearDensity(double value, LinearDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearDensity(double value, UnitSystem unitSystem) + public LinearDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -167,10 +165,10 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -195,72 +193,72 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); + public QuantityValue GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter); + public QuantityValue GramsPerMeter => As(LinearDensityUnit.GramPerMeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); + public QuantityValue GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); + public QuantityValue KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); + public QuantityValue KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); + public QuantityValue KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); + public QuantityValue MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); + public QuantityValue MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); + public QuantityValue MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); + public QuantityValue MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); + public QuantityValue MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); + public QuantityValue MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); + public QuantityValue PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsPerInch => As(LinearDensityUnit.PoundPerInch); + public QuantityValue PoundsPerInch => As(LinearDensityUnit.PoundPerInch); #endregion @@ -334,7 +332,7 @@ public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static LinearDensity FromGramsPerCentimeter(double value) + public static LinearDensity FromGramsPerCentimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.GramPerCentimeter); } @@ -342,7 +340,7 @@ public static LinearDensity FromGramsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromGramsPerMeter(double value) + public static LinearDensity FromGramsPerMeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.GramPerMeter); } @@ -350,7 +348,7 @@ public static LinearDensity FromGramsPerMeter(double value) /// /// Creates a from . /// - public static LinearDensity FromGramsPerMillimeter(double value) + public static LinearDensity FromGramsPerMillimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.GramPerMillimeter); } @@ -358,7 +356,7 @@ public static LinearDensity FromGramsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromKilogramsPerCentimeter(double value) + public static LinearDensity FromKilogramsPerCentimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.KilogramPerCentimeter); } @@ -366,7 +364,7 @@ public static LinearDensity FromKilogramsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromKilogramsPerMeter(double value) + public static LinearDensity FromKilogramsPerMeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter); } @@ -374,7 +372,7 @@ public static LinearDensity FromKilogramsPerMeter(double value) /// /// Creates a from . /// - public static LinearDensity FromKilogramsPerMillimeter(double value) + public static LinearDensity FromKilogramsPerMillimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.KilogramPerMillimeter); } @@ -382,7 +380,7 @@ public static LinearDensity FromKilogramsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMicrogramsPerCentimeter(double value) + public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MicrogramPerCentimeter); } @@ -390,7 +388,7 @@ public static LinearDensity FromMicrogramsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMicrogramsPerMeter(double value) + public static LinearDensity FromMicrogramsPerMeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MicrogramPerMeter); } @@ -398,7 +396,7 @@ public static LinearDensity FromMicrogramsPerMeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMicrogramsPerMillimeter(double value) + public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MicrogramPerMillimeter); } @@ -406,7 +404,7 @@ public static LinearDensity FromMicrogramsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMilligramsPerCentimeter(double value) + public static LinearDensity FromMilligramsPerCentimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MilligramPerCentimeter); } @@ -414,7 +412,7 @@ public static LinearDensity FromMilligramsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMilligramsPerMeter(double value) + public static LinearDensity FromMilligramsPerMeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MilligramPerMeter); } @@ -422,7 +420,7 @@ public static LinearDensity FromMilligramsPerMeter(double value) /// /// Creates a from . /// - public static LinearDensity FromMilligramsPerMillimeter(double value) + public static LinearDensity FromMilligramsPerMillimeter(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.MilligramPerMillimeter); } @@ -430,7 +428,7 @@ public static LinearDensity FromMilligramsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearDensity FromPoundsPerFoot(double value) + public static LinearDensity FromPoundsPerFoot(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.PoundPerFoot); } @@ -438,7 +436,7 @@ public static LinearDensity FromPoundsPerFoot(double value) /// /// Creates a from . /// - public static LinearDensity FromPoundsPerInch(double value) + public static LinearDensity FromPoundsPerInch(QuantityValue value) { return new LinearDensity(value, LinearDensityUnit.PoundPerInch); } @@ -449,7 +447,7 @@ public static LinearDensity FromPoundsPerInch(double value) /// Value to convert from. /// Unit to convert from. /// LinearDensity unit value. - public static LinearDensity From(double value, LinearDensityUnit fromUnit) + public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit) { return new LinearDensity(value, fromUnit); } @@ -621,25 +619,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearDensity operator *(double left, LinearDensity right) + public static LinearDensity operator *(QuantityValue left, LinearDensity right) { return new LinearDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearDensity operator *(LinearDensity left, double right) + public static LinearDensity operator *(LinearDensity left, QuantityValue right) { return new LinearDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearDensity operator /(LinearDensity left, double right) + public static LinearDensity operator /(LinearDensity left, QuantityValue right) { return new LinearDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LinearDensity left, LinearDensity right) + public static QuantityValue operator /(LinearDensity left, LinearDensity right) { return left.KilogramsPerMeter / right.KilogramsPerMeter; } @@ -694,27 +692,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(LinearDensity left, LinearDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearDensity other, LinearDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(LinearDensity left, LinearDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is LinearDensity otherQuantity)) @@ -724,15 +715,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(LinearDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -815,10 +803,10 @@ public bool Equals(LinearDensity other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -835,7 +823,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LinearDensity other, LinearDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -848,7 +836,12 @@ public bool Equals(LinearDensity other, LinearDensity tolerance) /// A hash code for the current LinearDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -859,7 +852,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearDensityUnit unit) + public QuantityValue As(LinearDensityUnit unit) { if (Unit == unit) return Value; @@ -868,7 +861,7 @@ public double As(LinearDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -883,7 +876,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); @@ -949,34 +942,34 @@ private bool TryToUnit(LinearDensityUnit unit, [NotNullWhen(true)] out LinearDen LinearDensity? convertedOrNull = (Unit, unit) switch { // LinearDensityUnit -> BaseUnit - (LinearDensityUnit.GramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * 1e-1, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.GramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * 1e-3, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.GramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 10, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.GramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 1000, LinearDensityUnit.KilogramPerMeter), (LinearDensityUnit.GramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.KilogramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value * 1e-1) * 1e3d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.KilogramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value) * 1e3d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MicrogramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value * 1e-1) * 1e-6d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MicrogramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value * 1e-3) * 1e-6d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MicrogramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value) * 1e-6d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MilligramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value * 1e-1) * 1e-3d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MilligramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value * 1e-3) * 1e-3d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.MilligramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity((_value) * 1e-3d, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.PoundPerFoot, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * 1.48816394, LinearDensityUnit.KilogramPerMeter), - (LinearDensityUnit.PoundPerInch, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 5.5997415e-2, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.KilogramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * 100, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.KilogramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * 1000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MicrogramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 10000000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MicrogramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 1000000000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MicrogramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 1000000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MilligramPerCentimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 10000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MilligramPerMeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 1000000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.MilligramPerMillimeter, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value / 1000, LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.PoundPerFoot, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * new QuantityValue(74408197, 50000000, false), LinearDensityUnit.KilogramPerMeter), + (LinearDensityUnit.PoundPerInch, LinearDensityUnit.KilogramPerMeter) => new LinearDensity(_value * new QuantityValue(200000000, 11199483, false), LinearDensityUnit.KilogramPerMeter), // BaseUnit -> LinearDensityUnit - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.GramPerCentimeter) => new LinearDensity(_value / 1e-1, LinearDensityUnit.GramPerCentimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.GramPerMeter) => new LinearDensity(_value / 1e-3, LinearDensityUnit.GramPerMeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.GramPerCentimeter) => new LinearDensity(_value * 10, LinearDensityUnit.GramPerCentimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.GramPerMeter) => new LinearDensity(_value * 1000, LinearDensityUnit.GramPerMeter), (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.GramPerMillimeter) => new LinearDensity(_value, LinearDensityUnit.GramPerMillimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.KilogramPerCentimeter) => new LinearDensity((_value / 1e-1) / 1e3d, LinearDensityUnit.KilogramPerCentimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.KilogramPerMillimeter) => new LinearDensity((_value) / 1e3d, LinearDensityUnit.KilogramPerMillimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerCentimeter) => new LinearDensity((_value / 1e-1) / 1e-6d, LinearDensityUnit.MicrogramPerCentimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerMeter) => new LinearDensity((_value / 1e-3) / 1e-6d, LinearDensityUnit.MicrogramPerMeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerMillimeter) => new LinearDensity((_value) / 1e-6d, LinearDensityUnit.MicrogramPerMillimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerCentimeter) => new LinearDensity((_value / 1e-1) / 1e-3d, LinearDensityUnit.MilligramPerCentimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerMeter) => new LinearDensity((_value / 1e-3) / 1e-3d, LinearDensityUnit.MilligramPerMeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerMillimeter) => new LinearDensity((_value) / 1e-3d, LinearDensityUnit.MilligramPerMillimeter), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerFoot) => new LinearDensity(_value / 1.48816394, LinearDensityUnit.PoundPerFoot), - (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerInch) => new LinearDensity(_value * 5.5997415e-2, LinearDensityUnit.PoundPerInch), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.KilogramPerCentimeter) => new LinearDensity(_value / 100, LinearDensityUnit.KilogramPerCentimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.KilogramPerMillimeter) => new LinearDensity(_value / 1000, LinearDensityUnit.KilogramPerMillimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerCentimeter) => new LinearDensity(_value * 10000000, LinearDensityUnit.MicrogramPerCentimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerMeter) => new LinearDensity(_value * 1000000000, LinearDensityUnit.MicrogramPerMeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MicrogramPerMillimeter) => new LinearDensity(_value * 1000000, LinearDensityUnit.MicrogramPerMillimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerCentimeter) => new LinearDensity(_value * 10000, LinearDensityUnit.MilligramPerCentimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerMeter) => new LinearDensity(_value * 1000000, LinearDensityUnit.MilligramPerMeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerMillimeter) => new LinearDensity(_value * 1000, LinearDensityUnit.MilligramPerMillimeter), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerFoot) => new LinearDensity(_value * new QuantityValue(50000000, 74408197, false), LinearDensityUnit.PoundPerFoot), + (LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerInch) => new LinearDensity(_value * new QuantityValue(11199483, 200000000, false), LinearDensityUnit.PoundPerInch), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index b7de57dfc0..a55bbbb803 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -105,7 +106,7 @@ static LinearPowerDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public LinearPowerDensity(double value, LinearPowerDensityUnit unit) + public LinearPowerDensity(QuantityValue value, LinearPowerDensityUnit unit) { _value = value; _unit = unit; @@ -119,7 +120,7 @@ public LinearPowerDensity(double value, LinearPowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearPowerDensity(double value, UnitSystem unitSystem) + public LinearPowerDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -170,10 +171,10 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -198,127 +199,127 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); + public QuantityValue GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); + public QuantityValue GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); + public QuantityValue GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); + public QuantityValue GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); + public QuantityValue GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); + public QuantityValue KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); + public QuantityValue KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); + public QuantityValue KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); + public QuantityValue KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); + public QuantityValue KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); + public QuantityValue MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); + public QuantityValue MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); + public QuantityValue MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); + public QuantityValue MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); + public QuantityValue MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); + public QuantityValue MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); + public QuantityValue MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); + public QuantityValue MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); + public QuantityValue MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); + public QuantityValue MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); + public QuantityValue WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); + public QuantityValue WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); /// /// Gets a value of this quantity converted into /// - public double WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); + public QuantityValue WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); /// /// Gets a value of this quantity converted into /// - public double WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); + public QuantityValue WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); + public QuantityValue WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); #endregion @@ -414,7 +415,7 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvide /// /// Creates a from . /// - public static LinearPowerDensity FromGigawattsPerCentimeter(double value) + public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerCentimeter); } @@ -422,7 +423,7 @@ public static LinearPowerDensity FromGigawattsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromGigawattsPerFoot(double value) + public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerFoot); } @@ -430,7 +431,7 @@ public static LinearPowerDensity FromGigawattsPerFoot(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromGigawattsPerInch(double value) + public static LinearPowerDensity FromGigawattsPerInch(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerInch); } @@ -438,7 +439,7 @@ public static LinearPowerDensity FromGigawattsPerInch(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromGigawattsPerMeter(double value) + public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMeter); } @@ -446,7 +447,7 @@ public static LinearPowerDensity FromGigawattsPerMeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromGigawattsPerMillimeter(double value) + public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMillimeter); } @@ -454,7 +455,7 @@ public static LinearPowerDensity FromGigawattsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromKilowattsPerCentimeter(double value) + public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerCentimeter); } @@ -462,7 +463,7 @@ public static LinearPowerDensity FromKilowattsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromKilowattsPerFoot(double value) + public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerFoot); } @@ -470,7 +471,7 @@ public static LinearPowerDensity FromKilowattsPerFoot(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromKilowattsPerInch(double value) + public static LinearPowerDensity FromKilowattsPerInch(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerInch); } @@ -478,7 +479,7 @@ public static LinearPowerDensity FromKilowattsPerInch(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromKilowattsPerMeter(double value) + public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMeter); } @@ -486,7 +487,7 @@ public static LinearPowerDensity FromKilowattsPerMeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromKilowattsPerMillimeter(double value) + public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMillimeter); } @@ -494,7 +495,7 @@ public static LinearPowerDensity FromKilowattsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMegawattsPerCentimeter(double value) + public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerCentimeter); } @@ -502,7 +503,7 @@ public static LinearPowerDensity FromMegawattsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMegawattsPerFoot(double value) + public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerFoot); } @@ -510,7 +511,7 @@ public static LinearPowerDensity FromMegawattsPerFoot(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMegawattsPerInch(double value) + public static LinearPowerDensity FromMegawattsPerInch(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerInch); } @@ -518,7 +519,7 @@ public static LinearPowerDensity FromMegawattsPerInch(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMegawattsPerMeter(double value) + public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMeter); } @@ -526,7 +527,7 @@ public static LinearPowerDensity FromMegawattsPerMeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMegawattsPerMillimeter(double value) + public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMillimeter); } @@ -534,7 +535,7 @@ public static LinearPowerDensity FromMegawattsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMilliwattsPerCentimeter(double value) + public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerCentimeter); } @@ -542,7 +543,7 @@ public static LinearPowerDensity FromMilliwattsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMilliwattsPerFoot(double value) + public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerFoot); } @@ -550,7 +551,7 @@ public static LinearPowerDensity FromMilliwattsPerFoot(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMilliwattsPerInch(double value) + public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerInch); } @@ -558,7 +559,7 @@ public static LinearPowerDensity FromMilliwattsPerInch(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMilliwattsPerMeter(double value) + public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMeter); } @@ -566,7 +567,7 @@ public static LinearPowerDensity FromMilliwattsPerMeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromMilliwattsPerMillimeter(double value) + public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMillimeter); } @@ -574,7 +575,7 @@ public static LinearPowerDensity FromMilliwattsPerMillimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromWattsPerCentimeter(double value) + public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerCentimeter); } @@ -582,7 +583,7 @@ public static LinearPowerDensity FromWattsPerCentimeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromWattsPerFoot(double value) + public static LinearPowerDensity FromWattsPerFoot(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerFoot); } @@ -590,7 +591,7 @@ public static LinearPowerDensity FromWattsPerFoot(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromWattsPerInch(double value) + public static LinearPowerDensity FromWattsPerInch(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerInch); } @@ -598,7 +599,7 @@ public static LinearPowerDensity FromWattsPerInch(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromWattsPerMeter(double value) + public static LinearPowerDensity FromWattsPerMeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMeter); } @@ -606,7 +607,7 @@ public static LinearPowerDensity FromWattsPerMeter(double value) /// /// Creates a from . /// - public static LinearPowerDensity FromWattsPerMillimeter(double value) + public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue value) { return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMillimeter); } @@ -617,7 +618,7 @@ public static LinearPowerDensity FromWattsPerMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// LinearPowerDensity unit value. - public static LinearPowerDensity From(double value, LinearPowerDensityUnit fromUnit) + public static LinearPowerDensity From(QuantityValue value, LinearPowerDensityUnit fromUnit) { return new LinearPowerDensity(value, fromUnit); } @@ -789,25 +790,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearPowerDensity operator *(double left, LinearPowerDensity right) + public static LinearPowerDensity operator *(QuantityValue left, LinearPowerDensity right) { return new LinearPowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearPowerDensity operator *(LinearPowerDensity left, double right) + public static LinearPowerDensity operator *(LinearPowerDensity left, QuantityValue right) { return new LinearPowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearPowerDensity operator /(LinearPowerDensity left, double right) + public static LinearPowerDensity operator /(LinearPowerDensity left, QuantityValue right) { return new LinearPowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LinearPowerDensity left, LinearPowerDensity right) + public static QuantityValue operator /(LinearPowerDensity left, LinearPowerDensity right) { return left.WattsPerMeter / right.WattsPerMeter; } @@ -840,27 +841,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LinearPowerDensity other, LinearPowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is LinearPowerDensity otherQuantity)) @@ -870,15 +864,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(LinearPowerDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -961,10 +952,10 @@ public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -981,7 +972,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LinearPowerDensity other, LinearPowerDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -994,7 +985,12 @@ public bool Equals(LinearPowerDensity other, LinearPowerDensity tolerance) /// A hash code for the current LinearPowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1005,7 +1001,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearPowerDensityUnit unit) + public QuantityValue As(LinearPowerDensityUnit unit) { if (Unit == unit) return Value; @@ -1014,7 +1010,7 @@ public double As(LinearPowerDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1029,7 +1025,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); @@ -1095,56 +1091,56 @@ private bool TryToUnit(LinearPowerDensityUnit unit, [NotNullWhen(true)] out Line LinearPowerDensity? convertedOrNull = (Unit, unit) switch { // LinearPowerDensityUnit -> BaseUnit - (LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e2) * 1e9d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 3.280839895) * 1e9d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 39.37007874) * 1e9d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value) * 1e9d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e3) * 1e9d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e2) * 1e3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 3.280839895) * 1e3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 39.37007874) * 1e3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value) * 1e3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e3) * 1e3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e2) * 1e6d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 3.280839895) * 1e6d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 39.37007874) * 1e6d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value) * 1e6d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e3) * 1e6d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e2) * 1e-3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 3.280839895) * 1e-3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 39.37007874) * 1e-3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value) * 1e-3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity((_value * 1e3) * 1e-3d, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1e2, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.WattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 3.280839895, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.WattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 39.37007874, LinearPowerDensityUnit.WattPerMeter), - (LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1e3, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 100000000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 3280839895, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 39370078740, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000000000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 100000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(656167979, 200000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(1968503937, 50000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 100000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(656167979, 200, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(1968503937, 50, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000000000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value / 10, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(656167979, 200000000000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(1968503937, 50000000000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value / 1000, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 100, LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.WattPerFoot, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(656167979, 200000000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.WattPerInch, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * new QuantityValue(1968503937, 50000000, false), LinearPowerDensityUnit.WattPerMeter), + (LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensityUnit.WattPerMeter) => new LinearPowerDensity(_value * 1000, LinearPowerDensityUnit.WattPerMeter), // BaseUnit -> LinearPowerDensityUnit - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerCentimeter) => new LinearPowerDensity((_value / 1e2) / 1e9d, LinearPowerDensityUnit.GigawattPerCentimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerFoot) => new LinearPowerDensity((_value / 3.280839895) / 1e9d, LinearPowerDensityUnit.GigawattPerFoot), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerInch) => new LinearPowerDensity((_value / 39.37007874) / 1e9d, LinearPowerDensityUnit.GigawattPerInch), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerMeter) => new LinearPowerDensity((_value) / 1e9d, LinearPowerDensityUnit.GigawattPerMeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerMillimeter) => new LinearPowerDensity((_value / 1e3) / 1e9d, LinearPowerDensityUnit.GigawattPerMillimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerCentimeter) => new LinearPowerDensity((_value / 1e2) / 1e3d, LinearPowerDensityUnit.KilowattPerCentimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerFoot) => new LinearPowerDensity((_value / 3.280839895) / 1e3d, LinearPowerDensityUnit.KilowattPerFoot), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerInch) => new LinearPowerDensity((_value / 39.37007874) / 1e3d, LinearPowerDensityUnit.KilowattPerInch), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerMeter) => new LinearPowerDensity((_value) / 1e3d, LinearPowerDensityUnit.KilowattPerMeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerMillimeter) => new LinearPowerDensity((_value / 1e3) / 1e3d, LinearPowerDensityUnit.KilowattPerMillimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerCentimeter) => new LinearPowerDensity((_value / 1e2) / 1e6d, LinearPowerDensityUnit.MegawattPerCentimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerFoot) => new LinearPowerDensity((_value / 3.280839895) / 1e6d, LinearPowerDensityUnit.MegawattPerFoot), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerInch) => new LinearPowerDensity((_value / 39.37007874) / 1e6d, LinearPowerDensityUnit.MegawattPerInch), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerMeter) => new LinearPowerDensity((_value) / 1e6d, LinearPowerDensityUnit.MegawattPerMeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerMillimeter) => new LinearPowerDensity((_value / 1e3) / 1e6d, LinearPowerDensityUnit.MegawattPerMillimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerCentimeter) => new LinearPowerDensity((_value / 1e2) / 1e-3d, LinearPowerDensityUnit.MilliwattPerCentimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerFoot) => new LinearPowerDensity((_value / 3.280839895) / 1e-3d, LinearPowerDensityUnit.MilliwattPerFoot), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerInch) => new LinearPowerDensity((_value / 39.37007874) / 1e-3d, LinearPowerDensityUnit.MilliwattPerInch), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerMeter) => new LinearPowerDensity((_value) / 1e-3d, LinearPowerDensityUnit.MilliwattPerMeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerMillimeter) => new LinearPowerDensity((_value / 1e3) / 1e-3d, LinearPowerDensityUnit.MilliwattPerMillimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerCentimeter) => new LinearPowerDensity(_value / 1e2, LinearPowerDensityUnit.WattPerCentimeter), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerFoot) => new LinearPowerDensity(_value / 3.280839895, LinearPowerDensityUnit.WattPerFoot), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerInch) => new LinearPowerDensity(_value / 39.37007874, LinearPowerDensityUnit.WattPerInch), - (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerMillimeter) => new LinearPowerDensity(_value / 1e3, LinearPowerDensityUnit.WattPerMillimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerCentimeter) => new LinearPowerDensity(_value / 100000000000, LinearPowerDensityUnit.GigawattPerCentimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerFoot) => new LinearPowerDensity(_value / 3280839895, LinearPowerDensityUnit.GigawattPerFoot), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerInch) => new LinearPowerDensity(_value / 39370078740, LinearPowerDensityUnit.GigawattPerInch), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerMeter) => new LinearPowerDensity(_value / 1000000000, LinearPowerDensityUnit.GigawattPerMeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.GigawattPerMillimeter) => new LinearPowerDensity(_value / 1000000000000, LinearPowerDensityUnit.GigawattPerMillimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerCentimeter) => new LinearPowerDensity(_value / 100000, LinearPowerDensityUnit.KilowattPerCentimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerFoot) => new LinearPowerDensity(_value * new QuantityValue(200000, 656167979, false), LinearPowerDensityUnit.KilowattPerFoot), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerInch) => new LinearPowerDensity(_value * new QuantityValue(50000, 1968503937, false), LinearPowerDensityUnit.KilowattPerInch), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerMeter) => new LinearPowerDensity(_value / 1000, LinearPowerDensityUnit.KilowattPerMeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.KilowattPerMillimeter) => new LinearPowerDensity(_value / 1000000, LinearPowerDensityUnit.KilowattPerMillimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerCentimeter) => new LinearPowerDensity(_value / 100000000, LinearPowerDensityUnit.MegawattPerCentimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerFoot) => new LinearPowerDensity(_value * new QuantityValue(200, 656167979, false), LinearPowerDensityUnit.MegawattPerFoot), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerInch) => new LinearPowerDensity(_value * new QuantityValue(50, 1968503937, false), LinearPowerDensityUnit.MegawattPerInch), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerMeter) => new LinearPowerDensity(_value / 1000000, LinearPowerDensityUnit.MegawattPerMeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MegawattPerMillimeter) => new LinearPowerDensity(_value / 1000000000, LinearPowerDensityUnit.MegawattPerMillimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerCentimeter) => new LinearPowerDensity(_value * 10, LinearPowerDensityUnit.MilliwattPerCentimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerFoot) => new LinearPowerDensity(_value * new QuantityValue(200000000000, 656167979, false), LinearPowerDensityUnit.MilliwattPerFoot), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerInch) => new LinearPowerDensity(_value * new QuantityValue(50000000000, 1968503937, false), LinearPowerDensityUnit.MilliwattPerInch), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerMeter) => new LinearPowerDensity(_value * 1000, LinearPowerDensityUnit.MilliwattPerMeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.MilliwattPerMillimeter) => new LinearPowerDensity(_value, LinearPowerDensityUnit.MilliwattPerMillimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerCentimeter) => new LinearPowerDensity(_value / 100, LinearPowerDensityUnit.WattPerCentimeter), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerFoot) => new LinearPowerDensity(_value * new QuantityValue(200000000, 656167979, false), LinearPowerDensityUnit.WattPerFoot), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerInch) => new LinearPowerDensity(_value * new QuantityValue(50000000, 1968503937, false), LinearPowerDensityUnit.WattPerInch), + (LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerMillimeter) => new LinearPowerDensity(_value / 1000, LinearPowerDensityUnit.WattPerMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs index 80487fba93..b14caac78c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminance.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -57,7 +55,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,7 +94,7 @@ static Luminance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Luminance(double value, LuminanceUnit unit) + public Luminance(QuantityValue value, LuminanceUnit unit) { _value = value; _unit = unit; @@ -110,7 +108,7 @@ public Luminance(double value, LuminanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Luminance(double value, UnitSystem unitSystem) + public Luminance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -161,10 +159,10 @@ public Luminance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,52 +187,52 @@ public Luminance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CandelasPerSquareFoot => As(LuminanceUnit.CandelaPerSquareFoot); + public QuantityValue CandelasPerSquareFoot => As(LuminanceUnit.CandelaPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double CandelasPerSquareInch => As(LuminanceUnit.CandelaPerSquareInch); + public QuantityValue CandelasPerSquareInch => As(LuminanceUnit.CandelaPerSquareInch); /// /// Gets a value of this quantity converted into /// - public double CandelasPerSquareMeter => As(LuminanceUnit.CandelaPerSquareMeter); + public QuantityValue CandelasPerSquareMeter => As(LuminanceUnit.CandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double CenticandelasPerSquareMeter => As(LuminanceUnit.CenticandelaPerSquareMeter); + public QuantityValue CenticandelasPerSquareMeter => As(LuminanceUnit.CenticandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double DecicandelasPerSquareMeter => As(LuminanceUnit.DecicandelaPerSquareMeter); + public QuantityValue DecicandelasPerSquareMeter => As(LuminanceUnit.DecicandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilocandelasPerSquareMeter => As(LuminanceUnit.KilocandelaPerSquareMeter); + public QuantityValue KilocandelasPerSquareMeter => As(LuminanceUnit.KilocandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MicrocandelasPerSquareMeter => As(LuminanceUnit.MicrocandelaPerSquareMeter); + public QuantityValue MicrocandelasPerSquareMeter => As(LuminanceUnit.MicrocandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MillicandelasPerSquareMeter => As(LuminanceUnit.MillicandelaPerSquareMeter); + public QuantityValue MillicandelasPerSquareMeter => As(LuminanceUnit.MillicandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double NanocandelasPerSquareMeter => As(LuminanceUnit.NanocandelaPerSquareMeter); + public QuantityValue NanocandelasPerSquareMeter => As(LuminanceUnit.NanocandelaPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double Nits => As(LuminanceUnit.Nit); + public QuantityValue Nits => As(LuminanceUnit.Nit); #endregion @@ -300,7 +298,7 @@ public static string GetAbbreviation(LuminanceUnit unit, IFormatProvider? provid /// /// Creates a from . /// - public static Luminance FromCandelasPerSquareFoot(double value) + public static Luminance FromCandelasPerSquareFoot(QuantityValue value) { return new Luminance(value, LuminanceUnit.CandelaPerSquareFoot); } @@ -308,7 +306,7 @@ public static Luminance FromCandelasPerSquareFoot(double value) /// /// Creates a from . /// - public static Luminance FromCandelasPerSquareInch(double value) + public static Luminance FromCandelasPerSquareInch(QuantityValue value) { return new Luminance(value, LuminanceUnit.CandelaPerSquareInch); } @@ -316,7 +314,7 @@ public static Luminance FromCandelasPerSquareInch(double value) /// /// Creates a from . /// - public static Luminance FromCandelasPerSquareMeter(double value) + public static Luminance FromCandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.CandelaPerSquareMeter); } @@ -324,7 +322,7 @@ public static Luminance FromCandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromCenticandelasPerSquareMeter(double value) + public static Luminance FromCenticandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.CenticandelaPerSquareMeter); } @@ -332,7 +330,7 @@ public static Luminance FromCenticandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromDecicandelasPerSquareMeter(double value) + public static Luminance FromDecicandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.DecicandelaPerSquareMeter); } @@ -340,7 +338,7 @@ public static Luminance FromDecicandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromKilocandelasPerSquareMeter(double value) + public static Luminance FromKilocandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.KilocandelaPerSquareMeter); } @@ -348,7 +346,7 @@ public static Luminance FromKilocandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromMicrocandelasPerSquareMeter(double value) + public static Luminance FromMicrocandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.MicrocandelaPerSquareMeter); } @@ -356,7 +354,7 @@ public static Luminance FromMicrocandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromMillicandelasPerSquareMeter(double value) + public static Luminance FromMillicandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.MillicandelaPerSquareMeter); } @@ -364,7 +362,7 @@ public static Luminance FromMillicandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromNanocandelasPerSquareMeter(double value) + public static Luminance FromNanocandelasPerSquareMeter(QuantityValue value) { return new Luminance(value, LuminanceUnit.NanocandelaPerSquareMeter); } @@ -372,7 +370,7 @@ public static Luminance FromNanocandelasPerSquareMeter(double value) /// /// Creates a from . /// - public static Luminance FromNits(double value) + public static Luminance FromNits(QuantityValue value) { return new Luminance(value, LuminanceUnit.Nit); } @@ -383,7 +381,7 @@ public static Luminance FromNits(double value) /// Value to convert from. /// Unit to convert from. /// Luminance unit value. - public static Luminance From(double value, LuminanceUnit fromUnit) + public static Luminance From(QuantityValue value, LuminanceUnit fromUnit) { return new Luminance(value, fromUnit); } @@ -555,25 +553,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static Luminance operator *(double left, Luminance right) + public static Luminance operator *(QuantityValue left, Luminance right) { return new Luminance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Luminance operator *(Luminance left, double right) + public static Luminance operator *(Luminance left, QuantityValue right) { return new Luminance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Luminance operator /(Luminance left, double right) + public static Luminance operator /(Luminance left, QuantityValue right) { return new Luminance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Luminance left, Luminance right) + public static QuantityValue operator /(Luminance left, Luminance right) { return left.CandelasPerSquareMeter / right.CandelasPerSquareMeter; } @@ -616,27 +614,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Luminance left, Luminance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminance other, Luminance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Luminance left, Luminance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Luminance otherQuantity)) @@ -646,15 +637,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Luminance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -737,10 +725,10 @@ public bool Equals(Luminance other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -757,7 +745,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Luminance other, Luminance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -770,7 +758,12 @@ public bool Equals(Luminance other, Luminance tolerance) /// A hash code for the current Luminance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -781,7 +774,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminanceUnit unit) + public QuantityValue As(LuminanceUnit unit) { if (Unit == unit) return Value; @@ -790,7 +783,7 @@ public double As(LuminanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -805,7 +798,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LuminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminanceUnit)} is supported.", nameof(unit)); @@ -871,25 +864,25 @@ private bool TryToUnit(LuminanceUnit unit, [NotNullWhen(true)] out Luminance? co Luminance? convertedOrNull = (Unit, unit) switch { // LuminanceUnit -> BaseUnit - (LuminanceUnit.CandelaPerSquareFoot, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value* 1.07639e1, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareInch, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value* 1.5500031e3, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.CenticandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e-2d, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.DecicandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e-1d, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.KilocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e3d, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.MicrocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e-6d, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.MillicandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e-3d, LuminanceUnit.CandelaPerSquareMeter), - (LuminanceUnit.NanocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance((_value) * 1e-9d, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareFoot, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value * new QuantityValue(107639, 10000, false), LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareInch, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value * new QuantityValue(15500031, 10000, false), LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.CenticandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value / 100, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.DecicandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value / 10, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.KilocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value * 1000, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.MicrocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value / 1000000, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.MillicandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value / 1000, LuminanceUnit.CandelaPerSquareMeter), + (LuminanceUnit.NanocandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value / 1000000000, LuminanceUnit.CandelaPerSquareMeter), (LuminanceUnit.Nit, LuminanceUnit.CandelaPerSquareMeter) => new Luminance(_value, LuminanceUnit.CandelaPerSquareMeter), // BaseUnit -> LuminanceUnit - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareFoot) => new Luminance(_value/ 1.07639e1, LuminanceUnit.CandelaPerSquareFoot), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareInch) => new Luminance(_value/ 1.5500031e3, LuminanceUnit.CandelaPerSquareInch), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CenticandelaPerSquareMeter) => new Luminance((_value) / 1e-2d, LuminanceUnit.CenticandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.DecicandelaPerSquareMeter) => new Luminance((_value) / 1e-1d, LuminanceUnit.DecicandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.KilocandelaPerSquareMeter) => new Luminance((_value) / 1e3d, LuminanceUnit.KilocandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.MicrocandelaPerSquareMeter) => new Luminance((_value) / 1e-6d, LuminanceUnit.MicrocandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.MillicandelaPerSquareMeter) => new Luminance((_value) / 1e-3d, LuminanceUnit.MillicandelaPerSquareMeter), - (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.NanocandelaPerSquareMeter) => new Luminance((_value) / 1e-9d, LuminanceUnit.NanocandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareFoot) => new Luminance(_value * new QuantityValue(10000, 107639, false), LuminanceUnit.CandelaPerSquareFoot), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CandelaPerSquareInch) => new Luminance(_value * new QuantityValue(10000, 15500031, false), LuminanceUnit.CandelaPerSquareInch), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.CenticandelaPerSquareMeter) => new Luminance(_value * 100, LuminanceUnit.CenticandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.DecicandelaPerSquareMeter) => new Luminance(_value * 10, LuminanceUnit.DecicandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.KilocandelaPerSquareMeter) => new Luminance(_value / 1000, LuminanceUnit.KilocandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.MicrocandelaPerSquareMeter) => new Luminance(_value * 1000000, LuminanceUnit.MicrocandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.MillicandelaPerSquareMeter) => new Luminance(_value * 1000, LuminanceUnit.MillicandelaPerSquareMeter), + (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.NanocandelaPerSquareMeter) => new Luminance(_value * 1000000000, LuminanceUnit.NanocandelaPerSquareMeter), (LuminanceUnit.CandelaPerSquareMeter, LuminanceUnit.Nit) => new Luminance(_value, LuminanceUnit.Nit), _ => null diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index db55fc52e1..2fc6777f21 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -94,7 +95,7 @@ static Luminosity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Luminosity(double value, LuminosityUnit unit) + public Luminosity(QuantityValue value, LuminosityUnit unit) { _value = value; _unit = unit; @@ -108,7 +109,7 @@ public Luminosity(double value, LuminosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Luminosity(double value, UnitSystem unitSystem) + public Luminosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,10 +160,10 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -187,72 +188,72 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Decawatts => As(LuminosityUnit.Decawatt); + public QuantityValue Decawatts => As(LuminosityUnit.Decawatt); /// /// Gets a value of this quantity converted into /// - public double Deciwatts => As(LuminosityUnit.Deciwatt); + public QuantityValue Deciwatts => As(LuminosityUnit.Deciwatt); /// /// Gets a value of this quantity converted into /// - public double Femtowatts => As(LuminosityUnit.Femtowatt); + public QuantityValue Femtowatts => As(LuminosityUnit.Femtowatt); /// /// Gets a value of this quantity converted into /// - public double Gigawatts => As(LuminosityUnit.Gigawatt); + public QuantityValue Gigawatts => As(LuminosityUnit.Gigawatt); /// /// Gets a value of this quantity converted into /// - public double Kilowatts => As(LuminosityUnit.Kilowatt); + public QuantityValue Kilowatts => As(LuminosityUnit.Kilowatt); /// /// Gets a value of this quantity converted into /// - public double Megawatts => As(LuminosityUnit.Megawatt); + public QuantityValue Megawatts => As(LuminosityUnit.Megawatt); /// /// Gets a value of this quantity converted into /// - public double Microwatts => As(LuminosityUnit.Microwatt); + public QuantityValue Microwatts => As(LuminosityUnit.Microwatt); /// /// Gets a value of this quantity converted into /// - public double Milliwatts => As(LuminosityUnit.Milliwatt); + public QuantityValue Milliwatts => As(LuminosityUnit.Milliwatt); /// /// Gets a value of this quantity converted into /// - public double Nanowatts => As(LuminosityUnit.Nanowatt); + public QuantityValue Nanowatts => As(LuminosityUnit.Nanowatt); /// /// Gets a value of this quantity converted into /// - public double Petawatts => As(LuminosityUnit.Petawatt); + public QuantityValue Petawatts => As(LuminosityUnit.Petawatt); /// /// Gets a value of this quantity converted into /// - public double Picowatts => As(LuminosityUnit.Picowatt); + public QuantityValue Picowatts => As(LuminosityUnit.Picowatt); /// /// Gets a value of this quantity converted into /// - public double SolarLuminosities => As(LuminosityUnit.SolarLuminosity); + public QuantityValue SolarLuminosities => As(LuminosityUnit.SolarLuminosity); /// /// Gets a value of this quantity converted into /// - public double Terawatts => As(LuminosityUnit.Terawatt); + public QuantityValue Terawatts => As(LuminosityUnit.Terawatt); /// /// Gets a value of this quantity converted into /// - public double Watts => As(LuminosityUnit.Watt); + public QuantityValue Watts => As(LuminosityUnit.Watt); #endregion @@ -326,7 +327,7 @@ public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provi /// /// Creates a from . /// - public static Luminosity FromDecawatts(double value) + public static Luminosity FromDecawatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Decawatt); } @@ -334,7 +335,7 @@ public static Luminosity FromDecawatts(double value) /// /// Creates a from . /// - public static Luminosity FromDeciwatts(double value) + public static Luminosity FromDeciwatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Deciwatt); } @@ -342,7 +343,7 @@ public static Luminosity FromDeciwatts(double value) /// /// Creates a from . /// - public static Luminosity FromFemtowatts(double value) + public static Luminosity FromFemtowatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Femtowatt); } @@ -350,7 +351,7 @@ public static Luminosity FromFemtowatts(double value) /// /// Creates a from . /// - public static Luminosity FromGigawatts(double value) + public static Luminosity FromGigawatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Gigawatt); } @@ -358,7 +359,7 @@ public static Luminosity FromGigawatts(double value) /// /// Creates a from . /// - public static Luminosity FromKilowatts(double value) + public static Luminosity FromKilowatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Kilowatt); } @@ -366,7 +367,7 @@ public static Luminosity FromKilowatts(double value) /// /// Creates a from . /// - public static Luminosity FromMegawatts(double value) + public static Luminosity FromMegawatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Megawatt); } @@ -374,7 +375,7 @@ public static Luminosity FromMegawatts(double value) /// /// Creates a from . /// - public static Luminosity FromMicrowatts(double value) + public static Luminosity FromMicrowatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Microwatt); } @@ -382,7 +383,7 @@ public static Luminosity FromMicrowatts(double value) /// /// Creates a from . /// - public static Luminosity FromMilliwatts(double value) + public static Luminosity FromMilliwatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Milliwatt); } @@ -390,7 +391,7 @@ public static Luminosity FromMilliwatts(double value) /// /// Creates a from . /// - public static Luminosity FromNanowatts(double value) + public static Luminosity FromNanowatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Nanowatt); } @@ -398,7 +399,7 @@ public static Luminosity FromNanowatts(double value) /// /// Creates a from . /// - public static Luminosity FromPetawatts(double value) + public static Luminosity FromPetawatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Petawatt); } @@ -406,7 +407,7 @@ public static Luminosity FromPetawatts(double value) /// /// Creates a from . /// - public static Luminosity FromPicowatts(double value) + public static Luminosity FromPicowatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Picowatt); } @@ -414,7 +415,7 @@ public static Luminosity FromPicowatts(double value) /// /// Creates a from . /// - public static Luminosity FromSolarLuminosities(double value) + public static Luminosity FromSolarLuminosities(QuantityValue value) { return new Luminosity(value, LuminosityUnit.SolarLuminosity); } @@ -422,7 +423,7 @@ public static Luminosity FromSolarLuminosities(double value) /// /// Creates a from . /// - public static Luminosity FromTerawatts(double value) + public static Luminosity FromTerawatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Terawatt); } @@ -430,7 +431,7 @@ public static Luminosity FromTerawatts(double value) /// /// Creates a from . /// - public static Luminosity FromWatts(double value) + public static Luminosity FromWatts(QuantityValue value) { return new Luminosity(value, LuminosityUnit.Watt); } @@ -441,7 +442,7 @@ public static Luminosity FromWatts(double value) /// Value to convert from. /// Unit to convert from. /// Luminosity unit value. - public static Luminosity From(double value, LuminosityUnit fromUnit) + public static Luminosity From(QuantityValue value, LuminosityUnit fromUnit) { return new Luminosity(value, fromUnit); } @@ -613,25 +614,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static Luminosity operator *(double left, Luminosity right) + public static Luminosity operator *(QuantityValue left, Luminosity right) { return new Luminosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Luminosity operator *(Luminosity left, double right) + public static Luminosity operator *(Luminosity left, QuantityValue right) { return new Luminosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Luminosity operator /(Luminosity left, double right) + public static Luminosity operator /(Luminosity left, QuantityValue right) { return new Luminosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Luminosity left, Luminosity right) + public static QuantityValue operator /(Luminosity left, Luminosity right) { return left.Watts / right.Watts; } @@ -664,27 +665,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Luminosity left, Luminosity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Luminosity other, Luminosity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Luminosity left, Luminosity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Luminosity otherQuantity)) @@ -694,15 +688,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Luminosity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -785,10 +776,10 @@ public bool Equals(Luminosity other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -805,7 +796,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Luminosity other, Luminosity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -818,7 +809,12 @@ public bool Equals(Luminosity other, Luminosity tolerance) /// A hash code for the current Luminosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -829,7 +825,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminosityUnit unit) + public QuantityValue As(LuminosityUnit unit) { if (Unit == unit) return Value; @@ -838,7 +834,7 @@ public double As(LuminosityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -853,7 +849,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); @@ -919,34 +915,34 @@ private bool TryToUnit(LuminosityUnit unit, [NotNullWhen(true)] out Luminosity? Luminosity? convertedOrNull = (Unit, unit) switch { // LuminosityUnit -> BaseUnit - (LuminosityUnit.Decawatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e1d, LuminosityUnit.Watt), - (LuminosityUnit.Deciwatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-1d, LuminosityUnit.Watt), - (LuminosityUnit.Femtowatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-15d, LuminosityUnit.Watt), - (LuminosityUnit.Gigawatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e9d, LuminosityUnit.Watt), - (LuminosityUnit.Kilowatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e3d, LuminosityUnit.Watt), - (LuminosityUnit.Megawatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e6d, LuminosityUnit.Watt), - (LuminosityUnit.Microwatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-6d, LuminosityUnit.Watt), - (LuminosityUnit.Milliwatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-3d, LuminosityUnit.Watt), - (LuminosityUnit.Nanowatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-9d, LuminosityUnit.Watt), - (LuminosityUnit.Petawatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e15d, LuminosityUnit.Watt), - (LuminosityUnit.Picowatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e-12d, LuminosityUnit.Watt), - (LuminosityUnit.SolarLuminosity, LuminosityUnit.Watt) => new Luminosity(_value * 3.846e26, LuminosityUnit.Watt), - (LuminosityUnit.Terawatt, LuminosityUnit.Watt) => new Luminosity((_value) * 1e12d, LuminosityUnit.Watt), + (LuminosityUnit.Decawatt, LuminosityUnit.Watt) => new Luminosity(_value * 10, LuminosityUnit.Watt), + (LuminosityUnit.Deciwatt, LuminosityUnit.Watt) => new Luminosity(_value / 10, LuminosityUnit.Watt), + (LuminosityUnit.Femtowatt, LuminosityUnit.Watt) => new Luminosity(_value / 1000000000000000, LuminosityUnit.Watt), + (LuminosityUnit.Gigawatt, LuminosityUnit.Watt) => new Luminosity(_value * 1000000000, LuminosityUnit.Watt), + (LuminosityUnit.Kilowatt, LuminosityUnit.Watt) => new Luminosity(_value * 1000, LuminosityUnit.Watt), + (LuminosityUnit.Megawatt, LuminosityUnit.Watt) => new Luminosity(_value * 1000000, LuminosityUnit.Watt), + (LuminosityUnit.Microwatt, LuminosityUnit.Watt) => new Luminosity(_value / 1000000, LuminosityUnit.Watt), + (LuminosityUnit.Milliwatt, LuminosityUnit.Watt) => new Luminosity(_value / 1000, LuminosityUnit.Watt), + (LuminosityUnit.Nanowatt, LuminosityUnit.Watt) => new Luminosity(_value / 1000000000, LuminosityUnit.Watt), + (LuminosityUnit.Petawatt, LuminosityUnit.Watt) => new Luminosity(_value * 1000000000000000, LuminosityUnit.Watt), + (LuminosityUnit.Picowatt, LuminosityUnit.Watt) => new Luminosity(_value / 1000000000000, LuminosityUnit.Watt), + (LuminosityUnit.SolarLuminosity, LuminosityUnit.Watt) => new Luminosity(_value * 38460000 * BigInteger.Pow(10, 19), LuminosityUnit.Watt), + (LuminosityUnit.Terawatt, LuminosityUnit.Watt) => new Luminosity(_value * 1000000000000, LuminosityUnit.Watt), // BaseUnit -> LuminosityUnit - (LuminosityUnit.Watt, LuminosityUnit.Decawatt) => new Luminosity((_value) / 1e1d, LuminosityUnit.Decawatt), - (LuminosityUnit.Watt, LuminosityUnit.Deciwatt) => new Luminosity((_value) / 1e-1d, LuminosityUnit.Deciwatt), - (LuminosityUnit.Watt, LuminosityUnit.Femtowatt) => new Luminosity((_value) / 1e-15d, LuminosityUnit.Femtowatt), - (LuminosityUnit.Watt, LuminosityUnit.Gigawatt) => new Luminosity((_value) / 1e9d, LuminosityUnit.Gigawatt), - (LuminosityUnit.Watt, LuminosityUnit.Kilowatt) => new Luminosity((_value) / 1e3d, LuminosityUnit.Kilowatt), - (LuminosityUnit.Watt, LuminosityUnit.Megawatt) => new Luminosity((_value) / 1e6d, LuminosityUnit.Megawatt), - (LuminosityUnit.Watt, LuminosityUnit.Microwatt) => new Luminosity((_value) / 1e-6d, LuminosityUnit.Microwatt), - (LuminosityUnit.Watt, LuminosityUnit.Milliwatt) => new Luminosity((_value) / 1e-3d, LuminosityUnit.Milliwatt), - (LuminosityUnit.Watt, LuminosityUnit.Nanowatt) => new Luminosity((_value) / 1e-9d, LuminosityUnit.Nanowatt), - (LuminosityUnit.Watt, LuminosityUnit.Petawatt) => new Luminosity((_value) / 1e15d, LuminosityUnit.Petawatt), - (LuminosityUnit.Watt, LuminosityUnit.Picowatt) => new Luminosity((_value) / 1e-12d, LuminosityUnit.Picowatt), - (LuminosityUnit.Watt, LuminosityUnit.SolarLuminosity) => new Luminosity(_value / 3.846e26, LuminosityUnit.SolarLuminosity), - (LuminosityUnit.Watt, LuminosityUnit.Terawatt) => new Luminosity((_value) / 1e12d, LuminosityUnit.Terawatt), + (LuminosityUnit.Watt, LuminosityUnit.Decawatt) => new Luminosity(_value / 10, LuminosityUnit.Decawatt), + (LuminosityUnit.Watt, LuminosityUnit.Deciwatt) => new Luminosity(_value * 10, LuminosityUnit.Deciwatt), + (LuminosityUnit.Watt, LuminosityUnit.Femtowatt) => new Luminosity(_value * 1000000000000000, LuminosityUnit.Femtowatt), + (LuminosityUnit.Watt, LuminosityUnit.Gigawatt) => new Luminosity(_value / 1000000000, LuminosityUnit.Gigawatt), + (LuminosityUnit.Watt, LuminosityUnit.Kilowatt) => new Luminosity(_value / 1000, LuminosityUnit.Kilowatt), + (LuminosityUnit.Watt, LuminosityUnit.Megawatt) => new Luminosity(_value / 1000000, LuminosityUnit.Megawatt), + (LuminosityUnit.Watt, LuminosityUnit.Microwatt) => new Luminosity(_value * 1000000, LuminosityUnit.Microwatt), + (LuminosityUnit.Watt, LuminosityUnit.Milliwatt) => new Luminosity(_value * 1000, LuminosityUnit.Milliwatt), + (LuminosityUnit.Watt, LuminosityUnit.Nanowatt) => new Luminosity(_value * 1000000000, LuminosityUnit.Nanowatt), + (LuminosityUnit.Watt, LuminosityUnit.Petawatt) => new Luminosity(_value / 1000000000000000, LuminosityUnit.Petawatt), + (LuminosityUnit.Watt, LuminosityUnit.Picowatt) => new Luminosity(_value * 1000000000000, LuminosityUnit.Picowatt), + (LuminosityUnit.Watt, LuminosityUnit.SolarLuminosity) => new Luminosity(_value / 38460000 / BigInteger.Pow(10, 19), LuminosityUnit.SolarLuminosity), + (LuminosityUnit.Watt, LuminosityUnit.Terawatt) => new Luminosity(_value / 1000000000000, LuminosityUnit.Terawatt), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 8b7466ecbc..fd1c83fa21 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static LuminousFlux() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public LuminousFlux(double value, LuminousFluxUnit unit) + public LuminousFlux(QuantityValue value, LuminousFluxUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public LuminousFlux(double value, LuminousFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousFlux(double value, UnitSystem unitSystem) + public LuminousFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Lumens => As(LuminousFluxUnit.Lumen); + public QuantityValue Lumens => As(LuminousFluxUnit.Lumen); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static LuminousFlux FromLumens(double value) + public static LuminousFlux FromLumens(QuantityValue value) { return new LuminousFlux(value, LuminousFluxUnit.Lumen); } @@ -233,7 +234,7 @@ public static LuminousFlux FromLumens(double value) /// Value to convert from. /// Unit to convert from. /// LuminousFlux unit value. - public static LuminousFlux From(double value, LuminousFluxUnit fromUnit) + public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit) { return new LuminousFlux(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousFlux operator *(double left, LuminousFlux right) + public static LuminousFlux operator *(QuantityValue left, LuminousFlux right) { return new LuminousFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousFlux operator *(LuminousFlux left, double right) + public static LuminousFlux operator *(LuminousFlux left, QuantityValue right) { return new LuminousFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousFlux operator /(LuminousFlux left, double right) + public static LuminousFlux operator /(LuminousFlux left, QuantityValue right) { return new LuminousFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LuminousFlux left, LuminousFlux right) + public static QuantityValue operator /(LuminousFlux left, LuminousFlux right) { return left.Lumens / right.Lumens; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(LuminousFlux left, LuminousFlux right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousFlux other, LuminousFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(LuminousFlux left, LuminousFlux right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is LuminousFlux otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(LuminousFlux other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LuminousFlux other, LuminousFlux tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(LuminousFlux other, LuminousFlux tolerance) /// A hash code for the current LuminousFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousFluxUnit unit) + public QuantityValue As(LuminousFluxUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(LuminousFluxUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 6b395a0909..c09369a097 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -88,7 +86,7 @@ static LuminousIntensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public LuminousIntensity(double value, LuminousIntensityUnit unit) + public LuminousIntensity(QuantityValue value, LuminousIntensityUnit unit) { _value = value; _unit = unit; @@ -102,7 +100,7 @@ public LuminousIntensity(double value, LuminousIntensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousIntensity(double value, UnitSystem unitSystem) + public LuminousIntensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -153,10 +151,10 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -181,7 +179,7 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Candela => As(LuminousIntensityUnit.Candela); + public QuantityValue Candela => As(LuminousIntensityUnit.Candela); #endregion @@ -229,7 +227,7 @@ public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider /// /// Creates a from . /// - public static LuminousIntensity FromCandela(double value) + public static LuminousIntensity FromCandela(QuantityValue value) { return new LuminousIntensity(value, LuminousIntensityUnit.Candela); } @@ -240,7 +238,7 @@ public static LuminousIntensity FromCandela(double value) /// Value to convert from. /// Unit to convert from. /// LuminousIntensity unit value. - public static LuminousIntensity From(double value, LuminousIntensityUnit fromUnit) + public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit fromUnit) { return new LuminousIntensity(value, fromUnit); } @@ -412,25 +410,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousIntensity operator *(double left, LuminousIntensity right) + public static LuminousIntensity operator *(QuantityValue left, LuminousIntensity right) { return new LuminousIntensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousIntensity operator *(LuminousIntensity left, double right) + public static LuminousIntensity operator *(LuminousIntensity left, QuantityValue right) { return new LuminousIntensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousIntensity operator /(LuminousIntensity left, double right) + public static LuminousIntensity operator /(LuminousIntensity left, QuantityValue right) { return new LuminousIntensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LuminousIntensity left, LuminousIntensity right) + public static QuantityValue operator /(LuminousIntensity left, LuminousIntensity right) { return left.Candela / right.Candela; } @@ -479,27 +477,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(LuminousIntensity left, LuminousIntensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(LuminousIntensity other, LuminousIntensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(LuminousIntensity left, LuminousIntensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is LuminousIntensity otherQuantity)) @@ -509,15 +500,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(LuminousIntensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -600,10 +588,10 @@ public bool Equals(LuminousIntensity other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -620,7 +608,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(LuminousIntensity other, LuminousIntensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -633,7 +621,12 @@ public bool Equals(LuminousIntensity other, LuminousIntensity tolerance) /// A hash code for the current LuminousIntensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -644,7 +637,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousIntensityUnit unit) + public QuantityValue As(LuminousIntensityUnit unit) { if (Unit == unit) return Value; @@ -653,7 +646,7 @@ public double As(LuminousIntensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -668,7 +661,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 4b6d8b63fd..7158e3e1a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,7 +87,7 @@ static MagneticField() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MagneticField(double value, MagneticFieldUnit unit) + public MagneticField(QuantityValue value, MagneticFieldUnit unit) { _value = value; _unit = unit; @@ -100,7 +101,7 @@ public MagneticField(double value, MagneticFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticField(double value, UnitSystem unitSystem) + public MagneticField(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -151,10 +152,10 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,32 +180,32 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Gausses => As(MagneticFieldUnit.Gauss); + public QuantityValue Gausses => As(MagneticFieldUnit.Gauss); /// /// Gets a value of this quantity converted into /// - public double Microteslas => As(MagneticFieldUnit.Microtesla); + public QuantityValue Microteslas => As(MagneticFieldUnit.Microtesla); /// /// Gets a value of this quantity converted into /// - public double Milligausses => As(MagneticFieldUnit.Milligauss); + public QuantityValue Milligausses => As(MagneticFieldUnit.Milligauss); /// /// Gets a value of this quantity converted into /// - public double Milliteslas => As(MagneticFieldUnit.Millitesla); + public QuantityValue Milliteslas => As(MagneticFieldUnit.Millitesla); /// /// Gets a value of this quantity converted into /// - public double Nanoteslas => As(MagneticFieldUnit.Nanotesla); + public QuantityValue Nanoteslas => As(MagneticFieldUnit.Nanotesla); /// /// Gets a value of this quantity converted into /// - public double Teslas => As(MagneticFieldUnit.Tesla); + public QuantityValue Teslas => As(MagneticFieldUnit.Tesla); #endregion @@ -262,7 +263,7 @@ public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static MagneticField FromGausses(double value) + public static MagneticField FromGausses(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Gauss); } @@ -270,7 +271,7 @@ public static MagneticField FromGausses(double value) /// /// Creates a from . /// - public static MagneticField FromMicroteslas(double value) + public static MagneticField FromMicroteslas(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Microtesla); } @@ -278,7 +279,7 @@ public static MagneticField FromMicroteslas(double value) /// /// Creates a from . /// - public static MagneticField FromMilligausses(double value) + public static MagneticField FromMilligausses(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Milligauss); } @@ -286,7 +287,7 @@ public static MagneticField FromMilligausses(double value) /// /// Creates a from . /// - public static MagneticField FromMilliteslas(double value) + public static MagneticField FromMilliteslas(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Millitesla); } @@ -294,7 +295,7 @@ public static MagneticField FromMilliteslas(double value) /// /// Creates a from . /// - public static MagneticField FromNanoteslas(double value) + public static MagneticField FromNanoteslas(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Nanotesla); } @@ -302,7 +303,7 @@ public static MagneticField FromNanoteslas(double value) /// /// Creates a from . /// - public static MagneticField FromTeslas(double value) + public static MagneticField FromTeslas(QuantityValue value) { return new MagneticField(value, MagneticFieldUnit.Tesla); } @@ -313,7 +314,7 @@ public static MagneticField FromTeslas(double value) /// Value to convert from. /// Unit to convert from. /// MagneticField unit value. - public static MagneticField From(double value, MagneticFieldUnit fromUnit) + public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit) { return new MagneticField(value, fromUnit); } @@ -485,25 +486,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticField operator *(double left, MagneticField right) + public static MagneticField operator *(QuantityValue left, MagneticField right) { return new MagneticField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticField operator *(MagneticField left, double right) + public static MagneticField operator *(MagneticField left, QuantityValue right) { return new MagneticField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticField operator /(MagneticField left, double right) + public static MagneticField operator /(MagneticField left, QuantityValue right) { return new MagneticField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MagneticField left, MagneticField right) + public static QuantityValue operator /(MagneticField left, MagneticField right) { return left.Teslas / right.Teslas; } @@ -536,27 +537,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MagneticField left, MagneticField right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticField other, MagneticField tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MagneticField left, MagneticField right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MagneticField otherQuantity)) @@ -566,15 +560,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MagneticField other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -657,10 +648,10 @@ public bool Equals(MagneticField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -677,7 +668,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MagneticField other, MagneticField tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -690,7 +681,12 @@ public bool Equals(MagneticField other, MagneticField tolerance) /// A hash code for the current MagneticField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -701,7 +697,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFieldUnit unit) + public QuantityValue As(MagneticFieldUnit unit) { if (Unit == unit) return Value; @@ -710,7 +706,7 @@ public double As(MagneticFieldUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -725,7 +721,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); @@ -791,18 +787,18 @@ private bool TryToUnit(MagneticFieldUnit unit, [NotNullWhen(true)] out MagneticF MagneticField? convertedOrNull = (Unit, unit) switch { // MagneticFieldUnit -> BaseUnit - (MagneticFieldUnit.Gauss, MagneticFieldUnit.Tesla) => new MagneticField(_value / 1e4, MagneticFieldUnit.Tesla), - (MagneticFieldUnit.Microtesla, MagneticFieldUnit.Tesla) => new MagneticField((_value) * 1e-6d, MagneticFieldUnit.Tesla), - (MagneticFieldUnit.Milligauss, MagneticFieldUnit.Tesla) => new MagneticField((_value / 1e4) * 1e-3d, MagneticFieldUnit.Tesla), - (MagneticFieldUnit.Millitesla, MagneticFieldUnit.Tesla) => new MagneticField((_value) * 1e-3d, MagneticFieldUnit.Tesla), - (MagneticFieldUnit.Nanotesla, MagneticFieldUnit.Tesla) => new MagneticField((_value) * 1e-9d, MagneticFieldUnit.Tesla), + (MagneticFieldUnit.Gauss, MagneticFieldUnit.Tesla) => new MagneticField(_value / 10000, MagneticFieldUnit.Tesla), + (MagneticFieldUnit.Microtesla, MagneticFieldUnit.Tesla) => new MagneticField(_value / 1000000, MagneticFieldUnit.Tesla), + (MagneticFieldUnit.Milligauss, MagneticFieldUnit.Tesla) => new MagneticField(_value / 10000000, MagneticFieldUnit.Tesla), + (MagneticFieldUnit.Millitesla, MagneticFieldUnit.Tesla) => new MagneticField(_value / 1000, MagneticFieldUnit.Tesla), + (MagneticFieldUnit.Nanotesla, MagneticFieldUnit.Tesla) => new MagneticField(_value / 1000000000, MagneticFieldUnit.Tesla), // BaseUnit -> MagneticFieldUnit - (MagneticFieldUnit.Tesla, MagneticFieldUnit.Gauss) => new MagneticField(_value * 1e4, MagneticFieldUnit.Gauss), - (MagneticFieldUnit.Tesla, MagneticFieldUnit.Microtesla) => new MagneticField((_value) / 1e-6d, MagneticFieldUnit.Microtesla), - (MagneticFieldUnit.Tesla, MagneticFieldUnit.Milligauss) => new MagneticField((_value * 1e4) / 1e-3d, MagneticFieldUnit.Milligauss), - (MagneticFieldUnit.Tesla, MagneticFieldUnit.Millitesla) => new MagneticField((_value) / 1e-3d, MagneticFieldUnit.Millitesla), - (MagneticFieldUnit.Tesla, MagneticFieldUnit.Nanotesla) => new MagneticField((_value) / 1e-9d, MagneticFieldUnit.Nanotesla), + (MagneticFieldUnit.Tesla, MagneticFieldUnit.Gauss) => new MagneticField(_value * 10000, MagneticFieldUnit.Gauss), + (MagneticFieldUnit.Tesla, MagneticFieldUnit.Microtesla) => new MagneticField(_value * 1000000, MagneticFieldUnit.Microtesla), + (MagneticFieldUnit.Tesla, MagneticFieldUnit.Milligauss) => new MagneticField(_value * 10000000, MagneticFieldUnit.Milligauss), + (MagneticFieldUnit.Tesla, MagneticFieldUnit.Millitesla) => new MagneticField(_value * 1000, MagneticFieldUnit.Millitesla), + (MagneticFieldUnit.Tesla, MagneticFieldUnit.Nanotesla) => new MagneticField(_value * 1000000000, MagneticFieldUnit.Nanotesla), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 9085a21c70..925e1958c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static MagneticFlux() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MagneticFlux(double value, MagneticFluxUnit unit) + public MagneticFlux(QuantityValue value, MagneticFluxUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public MagneticFlux(double value, MagneticFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticFlux(double value, UnitSystem unitSystem) + public MagneticFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Webers => As(MagneticFluxUnit.Weber); + public QuantityValue Webers => As(MagneticFluxUnit.Weber); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static MagneticFlux FromWebers(double value) + public static MagneticFlux FromWebers(QuantityValue value) { return new MagneticFlux(value, MagneticFluxUnit.Weber); } @@ -233,7 +234,7 @@ public static MagneticFlux FromWebers(double value) /// Value to convert from. /// Unit to convert from. /// MagneticFlux unit value. - public static MagneticFlux From(double value, MagneticFluxUnit fromUnit) + public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit) { return new MagneticFlux(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticFlux operator *(double left, MagneticFlux right) + public static MagneticFlux operator *(QuantityValue left, MagneticFlux right) { return new MagneticFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticFlux operator *(MagneticFlux left, double right) + public static MagneticFlux operator *(MagneticFlux left, QuantityValue right) { return new MagneticFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticFlux operator /(MagneticFlux left, double right) + public static MagneticFlux operator /(MagneticFlux left, QuantityValue right) { return new MagneticFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MagneticFlux left, MagneticFlux right) + public static QuantityValue operator /(MagneticFlux left, MagneticFlux right) { return left.Webers / right.Webers; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MagneticFlux left, MagneticFlux right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MagneticFlux other, MagneticFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MagneticFlux left, MagneticFlux right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MagneticFlux otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MagneticFlux other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MagneticFlux other, MagneticFlux tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(MagneticFlux other, MagneticFlux tolerance) /// A hash code for the current MagneticFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFluxUnit unit) + public QuantityValue As(MagneticFluxUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(MagneticFluxUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 9fc28818fc..4f13c56300 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static Magnetization() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Magnetization(double value, MagnetizationUnit unit) + public Magnetization(QuantityValue value, MagnetizationUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public Magnetization(double value, MagnetizationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Magnetization(double value, UnitSystem unitSystem) + public Magnetization(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); + public QuantityValue AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static Magnetization FromAmperesPerMeter(double value) + public static Magnetization FromAmperesPerMeter(QuantityValue value) { return new Magnetization(value, MagnetizationUnit.AmperePerMeter); } @@ -233,7 +234,7 @@ public static Magnetization FromAmperesPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// Magnetization unit value. - public static Magnetization From(double value, MagnetizationUnit fromUnit) + public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit) { return new Magnetization(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static Magnetization operator *(double left, Magnetization right) + public static Magnetization operator *(QuantityValue left, Magnetization right) { return new Magnetization(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Magnetization operator *(Magnetization left, double right) + public static Magnetization operator *(Magnetization left, QuantityValue right) { return new Magnetization(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Magnetization operator /(Magnetization left, double right) + public static Magnetization operator /(Magnetization left, QuantityValue right) { return new Magnetization(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Magnetization left, Magnetization right) + public static QuantityValue operator /(Magnetization left, Magnetization right) { return left.AmperesPerMeter / right.AmperesPerMeter; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Magnetization left, Magnetization right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Magnetization other, Magnetization tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Magnetization left, Magnetization right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Magnetization otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Magnetization other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(Magnetization other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Magnetization other, Magnetization tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(Magnetization other, Magnetization tolerance) /// A hash code for the current Magnetization. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagnetizationUnit unit) + public QuantityValue As(MagnetizationUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(MagnetizationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 6c8463810c..aa974b2979 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -69,7 +67,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -125,7 +123,7 @@ static Mass() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Mass(double value, MassUnit unit) + public Mass(QuantityValue value, MassUnit unit) { _value = value; _unit = unit; @@ -139,7 +137,7 @@ public Mass(double value, MassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Mass(double value, UnitSystem unitSystem) + public Mass(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -190,10 +188,10 @@ public Mass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -218,137 +216,137 @@ public Mass(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Centigrams => As(MassUnit.Centigram); + public QuantityValue Centigrams => As(MassUnit.Centigram); /// /// Gets a value of this quantity converted into /// - public double Decagrams => As(MassUnit.Decagram); + public QuantityValue Decagrams => As(MassUnit.Decagram); /// /// Gets a value of this quantity converted into /// - public double Decigrams => As(MassUnit.Decigram); + public QuantityValue Decigrams => As(MassUnit.Decigram); /// /// Gets a value of this quantity converted into /// - public double EarthMasses => As(MassUnit.EarthMass); + public QuantityValue EarthMasses => As(MassUnit.EarthMass); /// /// Gets a value of this quantity converted into /// - public double Femtograms => As(MassUnit.Femtogram); + public QuantityValue Femtograms => As(MassUnit.Femtogram); /// /// Gets a value of this quantity converted into /// - public double Grains => As(MassUnit.Grain); + public QuantityValue Grains => As(MassUnit.Grain); /// /// Gets a value of this quantity converted into /// - public double Grams => As(MassUnit.Gram); + public QuantityValue Grams => As(MassUnit.Gram); /// /// Gets a value of this quantity converted into /// - public double Hectograms => As(MassUnit.Hectogram); + public QuantityValue Hectograms => As(MassUnit.Hectogram); /// /// Gets a value of this quantity converted into /// - public double Kilograms => As(MassUnit.Kilogram); + public QuantityValue Kilograms => As(MassUnit.Kilogram); /// /// Gets a value of this quantity converted into /// - public double Kilopounds => As(MassUnit.Kilopound); + public QuantityValue Kilopounds => As(MassUnit.Kilopound); /// /// Gets a value of this quantity converted into /// - public double Kilotonnes => As(MassUnit.Kilotonne); + public QuantityValue Kilotonnes => As(MassUnit.Kilotonne); /// /// Gets a value of this quantity converted into /// - public double LongHundredweight => As(MassUnit.LongHundredweight); + public QuantityValue LongHundredweight => As(MassUnit.LongHundredweight); /// /// Gets a value of this quantity converted into /// - public double LongTons => As(MassUnit.LongTon); + public QuantityValue LongTons => As(MassUnit.LongTon); /// /// Gets a value of this quantity converted into /// - public double Megapounds => As(MassUnit.Megapound); + public QuantityValue Megapounds => As(MassUnit.Megapound); /// /// Gets a value of this quantity converted into /// - public double Megatonnes => As(MassUnit.Megatonne); + public QuantityValue Megatonnes => As(MassUnit.Megatonne); /// /// Gets a value of this quantity converted into /// - public double Micrograms => As(MassUnit.Microgram); + public QuantityValue Micrograms => As(MassUnit.Microgram); /// /// Gets a value of this quantity converted into /// - public double Milligrams => As(MassUnit.Milligram); + public QuantityValue Milligrams => As(MassUnit.Milligram); /// /// Gets a value of this quantity converted into /// - public double Nanograms => As(MassUnit.Nanogram); + public QuantityValue Nanograms => As(MassUnit.Nanogram); /// /// Gets a value of this quantity converted into /// - public double Ounces => As(MassUnit.Ounce); + public QuantityValue Ounces => As(MassUnit.Ounce); /// /// Gets a value of this quantity converted into /// - public double Picograms => As(MassUnit.Picogram); + public QuantityValue Picograms => As(MassUnit.Picogram); /// /// Gets a value of this quantity converted into /// - public double Pounds => As(MassUnit.Pound); + public QuantityValue Pounds => As(MassUnit.Pound); /// /// Gets a value of this quantity converted into /// - public double ShortHundredweight => As(MassUnit.ShortHundredweight); + public QuantityValue ShortHundredweight => As(MassUnit.ShortHundredweight); /// /// Gets a value of this quantity converted into /// - public double ShortTons => As(MassUnit.ShortTon); + public QuantityValue ShortTons => As(MassUnit.ShortTon); /// /// Gets a value of this quantity converted into /// - public double Slugs => As(MassUnit.Slug); + public QuantityValue Slugs => As(MassUnit.Slug); /// /// Gets a value of this quantity converted into /// - public double SolarMasses => As(MassUnit.SolarMass); + public QuantityValue SolarMasses => As(MassUnit.SolarMass); /// /// Gets a value of this quantity converted into /// - public double Stone => As(MassUnit.Stone); + public QuantityValue Stone => As(MassUnit.Stone); /// /// Gets a value of this quantity converted into /// - public double Tonnes => As(MassUnit.Tonne); + public QuantityValue Tonnes => As(MassUnit.Tonne); #endregion @@ -448,7 +446,7 @@ public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Mass FromCentigrams(double value) + public static Mass FromCentigrams(QuantityValue value) { return new Mass(value, MassUnit.Centigram); } @@ -456,7 +454,7 @@ public static Mass FromCentigrams(double value) /// /// Creates a from . /// - public static Mass FromDecagrams(double value) + public static Mass FromDecagrams(QuantityValue value) { return new Mass(value, MassUnit.Decagram); } @@ -464,7 +462,7 @@ public static Mass FromDecagrams(double value) /// /// Creates a from . /// - public static Mass FromDecigrams(double value) + public static Mass FromDecigrams(QuantityValue value) { return new Mass(value, MassUnit.Decigram); } @@ -472,7 +470,7 @@ public static Mass FromDecigrams(double value) /// /// Creates a from . /// - public static Mass FromEarthMasses(double value) + public static Mass FromEarthMasses(QuantityValue value) { return new Mass(value, MassUnit.EarthMass); } @@ -480,7 +478,7 @@ public static Mass FromEarthMasses(double value) /// /// Creates a from . /// - public static Mass FromFemtograms(double value) + public static Mass FromFemtograms(QuantityValue value) { return new Mass(value, MassUnit.Femtogram); } @@ -488,7 +486,7 @@ public static Mass FromFemtograms(double value) /// /// Creates a from . /// - public static Mass FromGrains(double value) + public static Mass FromGrains(QuantityValue value) { return new Mass(value, MassUnit.Grain); } @@ -496,7 +494,7 @@ public static Mass FromGrains(double value) /// /// Creates a from . /// - public static Mass FromGrams(double value) + public static Mass FromGrams(QuantityValue value) { return new Mass(value, MassUnit.Gram); } @@ -504,7 +502,7 @@ public static Mass FromGrams(double value) /// /// Creates a from . /// - public static Mass FromHectograms(double value) + public static Mass FromHectograms(QuantityValue value) { return new Mass(value, MassUnit.Hectogram); } @@ -512,7 +510,7 @@ public static Mass FromHectograms(double value) /// /// Creates a from . /// - public static Mass FromKilograms(double value) + public static Mass FromKilograms(QuantityValue value) { return new Mass(value, MassUnit.Kilogram); } @@ -520,7 +518,7 @@ public static Mass FromKilograms(double value) /// /// Creates a from . /// - public static Mass FromKilopounds(double value) + public static Mass FromKilopounds(QuantityValue value) { return new Mass(value, MassUnit.Kilopound); } @@ -528,7 +526,7 @@ public static Mass FromKilopounds(double value) /// /// Creates a from . /// - public static Mass FromKilotonnes(double value) + public static Mass FromKilotonnes(QuantityValue value) { return new Mass(value, MassUnit.Kilotonne); } @@ -536,7 +534,7 @@ public static Mass FromKilotonnes(double value) /// /// Creates a from . /// - public static Mass FromLongHundredweight(double value) + public static Mass FromLongHundredweight(QuantityValue value) { return new Mass(value, MassUnit.LongHundredweight); } @@ -544,7 +542,7 @@ public static Mass FromLongHundredweight(double value) /// /// Creates a from . /// - public static Mass FromLongTons(double value) + public static Mass FromLongTons(QuantityValue value) { return new Mass(value, MassUnit.LongTon); } @@ -552,7 +550,7 @@ public static Mass FromLongTons(double value) /// /// Creates a from . /// - public static Mass FromMegapounds(double value) + public static Mass FromMegapounds(QuantityValue value) { return new Mass(value, MassUnit.Megapound); } @@ -560,7 +558,7 @@ public static Mass FromMegapounds(double value) /// /// Creates a from . /// - public static Mass FromMegatonnes(double value) + public static Mass FromMegatonnes(QuantityValue value) { return new Mass(value, MassUnit.Megatonne); } @@ -568,7 +566,7 @@ public static Mass FromMegatonnes(double value) /// /// Creates a from . /// - public static Mass FromMicrograms(double value) + public static Mass FromMicrograms(QuantityValue value) { return new Mass(value, MassUnit.Microgram); } @@ -576,7 +574,7 @@ public static Mass FromMicrograms(double value) /// /// Creates a from . /// - public static Mass FromMilligrams(double value) + public static Mass FromMilligrams(QuantityValue value) { return new Mass(value, MassUnit.Milligram); } @@ -584,7 +582,7 @@ public static Mass FromMilligrams(double value) /// /// Creates a from . /// - public static Mass FromNanograms(double value) + public static Mass FromNanograms(QuantityValue value) { return new Mass(value, MassUnit.Nanogram); } @@ -592,7 +590,7 @@ public static Mass FromNanograms(double value) /// /// Creates a from . /// - public static Mass FromOunces(double value) + public static Mass FromOunces(QuantityValue value) { return new Mass(value, MassUnit.Ounce); } @@ -600,7 +598,7 @@ public static Mass FromOunces(double value) /// /// Creates a from . /// - public static Mass FromPicograms(double value) + public static Mass FromPicograms(QuantityValue value) { return new Mass(value, MassUnit.Picogram); } @@ -608,7 +606,7 @@ public static Mass FromPicograms(double value) /// /// Creates a from . /// - public static Mass FromPounds(double value) + public static Mass FromPounds(QuantityValue value) { return new Mass(value, MassUnit.Pound); } @@ -616,7 +614,7 @@ public static Mass FromPounds(double value) /// /// Creates a from . /// - public static Mass FromShortHundredweight(double value) + public static Mass FromShortHundredweight(QuantityValue value) { return new Mass(value, MassUnit.ShortHundredweight); } @@ -624,7 +622,7 @@ public static Mass FromShortHundredweight(double value) /// /// Creates a from . /// - public static Mass FromShortTons(double value) + public static Mass FromShortTons(QuantityValue value) { return new Mass(value, MassUnit.ShortTon); } @@ -632,7 +630,7 @@ public static Mass FromShortTons(double value) /// /// Creates a from . /// - public static Mass FromSlugs(double value) + public static Mass FromSlugs(QuantityValue value) { return new Mass(value, MassUnit.Slug); } @@ -640,7 +638,7 @@ public static Mass FromSlugs(double value) /// /// Creates a from . /// - public static Mass FromSolarMasses(double value) + public static Mass FromSolarMasses(QuantityValue value) { return new Mass(value, MassUnit.SolarMass); } @@ -648,7 +646,7 @@ public static Mass FromSolarMasses(double value) /// /// Creates a from . /// - public static Mass FromStone(double value) + public static Mass FromStone(QuantityValue value) { return new Mass(value, MassUnit.Stone); } @@ -656,7 +654,7 @@ public static Mass FromStone(double value) /// /// Creates a from . /// - public static Mass FromTonnes(double value) + public static Mass FromTonnes(QuantityValue value) { return new Mass(value, MassUnit.Tonne); } @@ -667,7 +665,7 @@ public static Mass FromTonnes(double value) /// Value to convert from. /// Unit to convert from. /// Mass unit value. - public static Mass From(double value, MassUnit fromUnit) + public static Mass From(QuantityValue value, MassUnit fromUnit) { return new Mass(value, fromUnit); } @@ -839,25 +837,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU } /// Get from multiplying value and . - public static Mass operator *(double left, Mass right) + public static Mass operator *(QuantityValue left, Mass right) { return new Mass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Mass operator *(Mass left, double right) + public static Mass operator *(Mass left, QuantityValue right) { return new Mass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Mass operator /(Mass left, double right) + public static Mass operator /(Mass left, QuantityValue right) { return new Mass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Mass left, Mass right) + public static QuantityValue operator /(Mass left, Mass right) { return left.Kilograms / right.Kilograms; } @@ -990,27 +988,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Mass left, Mass right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Mass other, Mass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Mass left, Mass right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Mass otherQuantity)) @@ -1020,15 +1011,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Mass other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1111,10 +1099,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1131,7 +1119,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Mass other, Mass tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1144,7 +1132,12 @@ public bool Equals(Mass other, Mass tolerance) /// A hash code for the current Mass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1155,7 +1148,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassUnit unit) + public QuantityValue As(MassUnit unit) { if (Unit == unit) return Value; @@ -1164,7 +1157,7 @@ public double As(MassUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1179,7 +1172,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); @@ -1245,60 +1238,60 @@ private bool TryToUnit(MassUnit unit, [NotNullWhen(true)] out Mass? converted) Mass? convertedOrNull = (Unit, unit) switch { // MassUnit -> BaseUnit - (MassUnit.Centigram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-2d, MassUnit.Kilogram), - (MassUnit.Decagram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e1d, MassUnit.Kilogram), - (MassUnit.Decigram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-1d, MassUnit.Kilogram), - (MassUnit.EarthMass, MassUnit.Kilogram) => new Mass(_value * 5.9722E+24, MassUnit.Kilogram), - (MassUnit.Femtogram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-15d, MassUnit.Kilogram), - (MassUnit.Grain, MassUnit.Kilogram) => new Mass(_value / 15432.358352941431, MassUnit.Kilogram), - (MassUnit.Gram, MassUnit.Kilogram) => new Mass(_value / 1e3, MassUnit.Kilogram), - (MassUnit.Hectogram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e2d, MassUnit.Kilogram), - (MassUnit.Kilopound, MassUnit.Kilogram) => new Mass((_value * 0.45359237) * 1e3d, MassUnit.Kilogram), - (MassUnit.Kilotonne, MassUnit.Kilogram) => new Mass((_value * 1e3) * 1e3d, MassUnit.Kilogram), - (MassUnit.LongHundredweight, MassUnit.Kilogram) => new Mass(_value / 0.01968413055222121, MassUnit.Kilogram), - (MassUnit.LongTon, MassUnit.Kilogram) => new Mass(_value * 1.0160469088e3, MassUnit.Kilogram), - (MassUnit.Megapound, MassUnit.Kilogram) => new Mass((_value * 0.45359237) * 1e6d, MassUnit.Kilogram), - (MassUnit.Megatonne, MassUnit.Kilogram) => new Mass((_value * 1e3) * 1e6d, MassUnit.Kilogram), - (MassUnit.Microgram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-6d, MassUnit.Kilogram), - (MassUnit.Milligram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-3d, MassUnit.Kilogram), - (MassUnit.Nanogram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-9d, MassUnit.Kilogram), - (MassUnit.Ounce, MassUnit.Kilogram) => new Mass(_value * 0.028349523125, MassUnit.Kilogram), - (MassUnit.Picogram, MassUnit.Kilogram) => new Mass((_value / 1e3) * 1e-12d, MassUnit.Kilogram), - (MassUnit.Pound, MassUnit.Kilogram) => new Mass(_value * 0.45359237, MassUnit.Kilogram), - (MassUnit.ShortHundredweight, MassUnit.Kilogram) => new Mass(_value / 0.022046226218487758, MassUnit.Kilogram), - (MassUnit.ShortTon, MassUnit.Kilogram) => new Mass(_value * 9.0718474e2, MassUnit.Kilogram), - (MassUnit.Slug, MassUnit.Kilogram) => new Mass(_value / 6.852176556196105e-2, MassUnit.Kilogram), - (MassUnit.SolarMass, MassUnit.Kilogram) => new Mass(_value * 1.98947e30, MassUnit.Kilogram), - (MassUnit.Stone, MassUnit.Kilogram) => new Mass(_value / 0.1574731728702698, MassUnit.Kilogram), - (MassUnit.Tonne, MassUnit.Kilogram) => new Mass(_value * 1e3, MassUnit.Kilogram), + (MassUnit.Centigram, MassUnit.Kilogram) => new Mass(_value / 100000, MassUnit.Kilogram), + (MassUnit.Decagram, MassUnit.Kilogram) => new Mass(_value / 100, MassUnit.Kilogram), + (MassUnit.Decigram, MassUnit.Kilogram) => new Mass(_value / 10000, MassUnit.Kilogram), + (MassUnit.EarthMass, MassUnit.Kilogram) => new Mass(_value * 597220 * BigInteger.Pow(10, 19), MassUnit.Kilogram), + (MassUnit.Femtogram, MassUnit.Kilogram) => new Mass(_value / 1000000000000000000, MassUnit.Kilogram), + (MassUnit.Grain, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(1000000000000, 15432358352941431, false), MassUnit.Kilogram), + (MassUnit.Gram, MassUnit.Kilogram) => new Mass(_value / 1000, MassUnit.Kilogram), + (MassUnit.Hectogram, MassUnit.Kilogram) => new Mass(_value / 10, MassUnit.Kilogram), + (MassUnit.Kilopound, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(45359237, 100000, false), MassUnit.Kilogram), + (MassUnit.Kilotonne, MassUnit.Kilogram) => new Mass(_value * 1000000, MassUnit.Kilogram), + (MassUnit.LongHundredweight, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(100000000000000000, 1968413055222121, false), MassUnit.Kilogram), + (MassUnit.LongTon, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(317514659, 312500, false), MassUnit.Kilogram), + (MassUnit.Megapound, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(45359237, 100, false), MassUnit.Kilogram), + (MassUnit.Megatonne, MassUnit.Kilogram) => new Mass(_value * 1000000000, MassUnit.Kilogram), + (MassUnit.Microgram, MassUnit.Kilogram) => new Mass(_value / 1000000000, MassUnit.Kilogram), + (MassUnit.Milligram, MassUnit.Kilogram) => new Mass(_value / 1000000, MassUnit.Kilogram), + (MassUnit.Nanogram, MassUnit.Kilogram) => new Mass(_value / 1000000000000, MassUnit.Kilogram), + (MassUnit.Ounce, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(45359237, 1600000000, false), MassUnit.Kilogram), + (MassUnit.Picogram, MassUnit.Kilogram) => new Mass(_value / 1000000000000000, MassUnit.Kilogram), + (MassUnit.Pound, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(45359237, 100000000, false), MassUnit.Kilogram), + (MassUnit.ShortHundredweight, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(500000000000000000, 11023113109243879, false), MassUnit.Kilogram), + (MassUnit.ShortTon, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(45359237, 50000, false), MassUnit.Kilogram), + (MassUnit.Slug, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(20000000000000000, 1370435311239221, false), MassUnit.Kilogram), + (MassUnit.SolarMass, MassUnit.Kilogram) => new Mass(_value * 198947000000 * BigInteger.Pow(10, 19), MassUnit.Kilogram), + (MassUnit.Stone, MassUnit.Kilogram) => new Mass(_value * new QuantityValue(5000000000000000, 787365864351349, false), MassUnit.Kilogram), + (MassUnit.Tonne, MassUnit.Kilogram) => new Mass(_value * 1000, MassUnit.Kilogram), // BaseUnit -> MassUnit - (MassUnit.Kilogram, MassUnit.Centigram) => new Mass((_value * 1e3) / 1e-2d, MassUnit.Centigram), - (MassUnit.Kilogram, MassUnit.Decagram) => new Mass((_value * 1e3) / 1e1d, MassUnit.Decagram), - (MassUnit.Kilogram, MassUnit.Decigram) => new Mass((_value * 1e3) / 1e-1d, MassUnit.Decigram), - (MassUnit.Kilogram, MassUnit.EarthMass) => new Mass(_value / 5.9722E+24, MassUnit.EarthMass), - (MassUnit.Kilogram, MassUnit.Femtogram) => new Mass((_value * 1e3) / 1e-15d, MassUnit.Femtogram), - (MassUnit.Kilogram, MassUnit.Grain) => new Mass(_value * 15432.358352941431, MassUnit.Grain), - (MassUnit.Kilogram, MassUnit.Gram) => new Mass(_value * 1e3, MassUnit.Gram), - (MassUnit.Kilogram, MassUnit.Hectogram) => new Mass((_value * 1e3) / 1e2d, MassUnit.Hectogram), - (MassUnit.Kilogram, MassUnit.Kilopound) => new Mass((_value / 0.45359237) / 1e3d, MassUnit.Kilopound), - (MassUnit.Kilogram, MassUnit.Kilotonne) => new Mass((_value / 1e3) / 1e3d, MassUnit.Kilotonne), - (MassUnit.Kilogram, MassUnit.LongHundredweight) => new Mass(_value * 0.01968413055222121, MassUnit.LongHundredweight), - (MassUnit.Kilogram, MassUnit.LongTon) => new Mass(_value / 1.0160469088e3, MassUnit.LongTon), - (MassUnit.Kilogram, MassUnit.Megapound) => new Mass((_value / 0.45359237) / 1e6d, MassUnit.Megapound), - (MassUnit.Kilogram, MassUnit.Megatonne) => new Mass((_value / 1e3) / 1e6d, MassUnit.Megatonne), - (MassUnit.Kilogram, MassUnit.Microgram) => new Mass((_value * 1e3) / 1e-6d, MassUnit.Microgram), - (MassUnit.Kilogram, MassUnit.Milligram) => new Mass((_value * 1e3) / 1e-3d, MassUnit.Milligram), - (MassUnit.Kilogram, MassUnit.Nanogram) => new Mass((_value * 1e3) / 1e-9d, MassUnit.Nanogram), - (MassUnit.Kilogram, MassUnit.Ounce) => new Mass(_value / 0.028349523125, MassUnit.Ounce), - (MassUnit.Kilogram, MassUnit.Picogram) => new Mass((_value * 1e3) / 1e-12d, MassUnit.Picogram), - (MassUnit.Kilogram, MassUnit.Pound) => new Mass(_value / 0.45359237, MassUnit.Pound), - (MassUnit.Kilogram, MassUnit.ShortHundredweight) => new Mass(_value * 0.022046226218487758, MassUnit.ShortHundredweight), - (MassUnit.Kilogram, MassUnit.ShortTon) => new Mass(_value / 9.0718474e2, MassUnit.ShortTon), - (MassUnit.Kilogram, MassUnit.Slug) => new Mass(_value * 6.852176556196105e-2, MassUnit.Slug), - (MassUnit.Kilogram, MassUnit.SolarMass) => new Mass(_value / 1.98947e30, MassUnit.SolarMass), - (MassUnit.Kilogram, MassUnit.Stone) => new Mass(_value * 0.1574731728702698, MassUnit.Stone), - (MassUnit.Kilogram, MassUnit.Tonne) => new Mass(_value / 1e3, MassUnit.Tonne), + (MassUnit.Kilogram, MassUnit.Centigram) => new Mass(_value * 100000, MassUnit.Centigram), + (MassUnit.Kilogram, MassUnit.Decagram) => new Mass(_value * 100, MassUnit.Decagram), + (MassUnit.Kilogram, MassUnit.Decigram) => new Mass(_value * 10000, MassUnit.Decigram), + (MassUnit.Kilogram, MassUnit.EarthMass) => new Mass(_value / 597220 / BigInteger.Pow(10, 19), MassUnit.EarthMass), + (MassUnit.Kilogram, MassUnit.Femtogram) => new Mass(_value * 1000000000000000000, MassUnit.Femtogram), + (MassUnit.Kilogram, MassUnit.Grain) => new Mass(_value * new QuantityValue(15432358352941431, 1000000000000, false), MassUnit.Grain), + (MassUnit.Kilogram, MassUnit.Gram) => new Mass(_value * 1000, MassUnit.Gram), + (MassUnit.Kilogram, MassUnit.Hectogram) => new Mass(_value * 10, MassUnit.Hectogram), + (MassUnit.Kilogram, MassUnit.Kilopound) => new Mass(_value * new QuantityValue(100000, 45359237, false), MassUnit.Kilopound), + (MassUnit.Kilogram, MassUnit.Kilotonne) => new Mass(_value / 1000000, MassUnit.Kilotonne), + (MassUnit.Kilogram, MassUnit.LongHundredweight) => new Mass(_value * new QuantityValue(1968413055222121, 100000000000000000, false), MassUnit.LongHundredweight), + (MassUnit.Kilogram, MassUnit.LongTon) => new Mass(_value * new QuantityValue(312500, 317514659, false), MassUnit.LongTon), + (MassUnit.Kilogram, MassUnit.Megapound) => new Mass(_value * new QuantityValue(100, 45359237, false), MassUnit.Megapound), + (MassUnit.Kilogram, MassUnit.Megatonne) => new Mass(_value / 1000000000, MassUnit.Megatonne), + (MassUnit.Kilogram, MassUnit.Microgram) => new Mass(_value * 1000000000, MassUnit.Microgram), + (MassUnit.Kilogram, MassUnit.Milligram) => new Mass(_value * 1000000, MassUnit.Milligram), + (MassUnit.Kilogram, MassUnit.Nanogram) => new Mass(_value * 1000000000000, MassUnit.Nanogram), + (MassUnit.Kilogram, MassUnit.Ounce) => new Mass(_value * new QuantityValue(1600000000, 45359237, false), MassUnit.Ounce), + (MassUnit.Kilogram, MassUnit.Picogram) => new Mass(_value * 1000000000000000, MassUnit.Picogram), + (MassUnit.Kilogram, MassUnit.Pound) => new Mass(_value * new QuantityValue(100000000, 45359237, false), MassUnit.Pound), + (MassUnit.Kilogram, MassUnit.ShortHundredweight) => new Mass(_value * new QuantityValue(11023113109243879, 500000000000000000, false), MassUnit.ShortHundredweight), + (MassUnit.Kilogram, MassUnit.ShortTon) => new Mass(_value * new QuantityValue(50000, 45359237, false), MassUnit.ShortTon), + (MassUnit.Kilogram, MassUnit.Slug) => new Mass(_value * new QuantityValue(1370435311239221, 20000000000000000, false), MassUnit.Slug), + (MassUnit.Kilogram, MassUnit.SolarMass) => new Mass(_value / 198947000000 / BigInteger.Pow(10, 19), MassUnit.SolarMass), + (MassUnit.Kilogram, MassUnit.Stone) => new Mass(_value * new QuantityValue(787365864351349, 5000000000000000, false), MassUnit.Stone), + (MassUnit.Kilogram, MassUnit.Tonne) => new Mass(_value / 1000, MassUnit.Tonne), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index b3bd701696..cac07c30cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -61,7 +59,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -139,7 +137,7 @@ static MassConcentration() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MassConcentration(double value, MassConcentrationUnit unit) + public MassConcentration(QuantityValue value, MassConcentrationUnit unit) { _value = value; _unit = unit; @@ -153,7 +151,7 @@ public MassConcentration(double value, MassConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassConcentration(double value, UnitSystem unitSystem) + public MassConcentration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -204,10 +202,10 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -232,247 +230,247 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); + public QuantityValue CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); + public QuantityValue CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); + public QuantityValue CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); + public QuantityValue CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); + public QuantityValue DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); + public QuantityValue DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); + public QuantityValue DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); + public QuantityValue DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); + public QuantityValue GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); + public QuantityValue GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); + public QuantityValue GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); + public QuantityValue GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); + public QuantityValue GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); /// /// Gets a value of this quantity converted into /// - public double GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); + public QuantityValue GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); + public QuantityValue GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); + public QuantityValue KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); + public QuantityValue KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); + public QuantityValue KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); + public QuantityValue KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); + public QuantityValue KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); + public QuantityValue KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); + public QuantityValue MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); + public QuantityValue MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); + public QuantityValue MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); + public QuantityValue MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); + public QuantityValue MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); + public QuantityValue MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); + public QuantityValue MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); + public QuantityValue MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); + public QuantityValue MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); + public QuantityValue MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); + public QuantityValue NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); + public QuantityValue NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); + public QuantityValue NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); + public QuantityValue NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); + public QuantityValue OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); /// /// Gets a value of this quantity converted into /// - public double OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); + public QuantityValue OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); + public QuantityValue PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); + public QuantityValue PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); + public QuantityValue PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); /// /// Gets a value of this quantity converted into /// - public double PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); + public QuantityValue PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); + public QuantityValue PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); + public QuantityValue PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); + public QuantityValue PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); /// /// Gets a value of this quantity converted into /// - public double PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); + public QuantityValue PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); /// /// Gets a value of this quantity converted into /// - public double SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); + public QuantityValue SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); + public QuantityValue TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); + public QuantityValue TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); + public QuantityValue TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); #endregion @@ -616,7 +614,7 @@ public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider /// /// Creates a from . /// - public static MassConcentration FromCentigramsPerDeciliter(double value) + public static MassConcentration FromCentigramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.CentigramPerDeciliter); } @@ -624,7 +622,7 @@ public static MassConcentration FromCentigramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromCentigramsPerLiter(double value) + public static MassConcentration FromCentigramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.CentigramPerLiter); } @@ -632,7 +630,7 @@ public static MassConcentration FromCentigramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromCentigramsPerMicroliter(double value) + public static MassConcentration FromCentigramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.CentigramPerMicroliter); } @@ -640,7 +638,7 @@ public static MassConcentration FromCentigramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromCentigramsPerMilliliter(double value) + public static MassConcentration FromCentigramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.CentigramPerMilliliter); } @@ -648,7 +646,7 @@ public static MassConcentration FromCentigramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromDecigramsPerDeciliter(double value) + public static MassConcentration FromDecigramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.DecigramPerDeciliter); } @@ -656,7 +654,7 @@ public static MassConcentration FromDecigramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromDecigramsPerLiter(double value) + public static MassConcentration FromDecigramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.DecigramPerLiter); } @@ -664,7 +662,7 @@ public static MassConcentration FromDecigramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromDecigramsPerMicroliter(double value) + public static MassConcentration FromDecigramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.DecigramPerMicroliter); } @@ -672,7 +670,7 @@ public static MassConcentration FromDecigramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromDecigramsPerMilliliter(double value) + public static MassConcentration FromDecigramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.DecigramPerMilliliter); } @@ -680,7 +678,7 @@ public static MassConcentration FromDecigramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerCubicCentimeter(double value) + public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerCubicCentimeter); } @@ -688,7 +686,7 @@ public static MassConcentration FromGramsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerCubicMeter(double value) + public static MassConcentration FromGramsPerCubicMeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMeter); } @@ -696,7 +694,7 @@ public static MassConcentration FromGramsPerCubicMeter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerCubicMillimeter(double value) + public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMillimeter); } @@ -704,7 +702,7 @@ public static MassConcentration FromGramsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerDeciliter(double value) + public static MassConcentration FromGramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerDeciliter); } @@ -712,7 +710,7 @@ public static MassConcentration FromGramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerLiter(double value) + public static MassConcentration FromGramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerLiter); } @@ -720,7 +718,7 @@ public static MassConcentration FromGramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerMicroliter(double value) + public static MassConcentration FromGramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerMicroliter); } @@ -728,7 +726,7 @@ public static MassConcentration FromGramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromGramsPerMilliliter(double value) + public static MassConcentration FromGramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.GramPerMilliliter); } @@ -736,7 +734,7 @@ public static MassConcentration FromGramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromKilogramsPerCubicCentimeter(double value) + public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicCentimeter); } @@ -744,7 +742,7 @@ public static MassConcentration FromKilogramsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static MassConcentration FromKilogramsPerCubicMeter(double value) + public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMeter); } @@ -752,7 +750,7 @@ public static MassConcentration FromKilogramsPerCubicMeter(double value) /// /// Creates a from . /// - public static MassConcentration FromKilogramsPerCubicMillimeter(double value) + public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMillimeter); } @@ -760,7 +758,7 @@ public static MassConcentration FromKilogramsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static MassConcentration FromKilogramsPerLiter(double value) + public static MassConcentration FromKilogramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilogramPerLiter); } @@ -768,7 +766,7 @@ public static MassConcentration FromKilogramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromKilopoundsPerCubicFoot(double value) + public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicFoot); } @@ -776,7 +774,7 @@ public static MassConcentration FromKilopoundsPerCubicFoot(double value) /// /// Creates a from . /// - public static MassConcentration FromKilopoundsPerCubicInch(double value) + public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicInch); } @@ -784,7 +782,7 @@ public static MassConcentration FromKilopoundsPerCubicInch(double value) /// /// Creates a from . /// - public static MassConcentration FromMicrogramsPerCubicMeter(double value) + public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MicrogramPerCubicMeter); } @@ -792,7 +790,7 @@ public static MassConcentration FromMicrogramsPerCubicMeter(double value) /// /// Creates a from . /// - public static MassConcentration FromMicrogramsPerDeciliter(double value) + public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MicrogramPerDeciliter); } @@ -800,7 +798,7 @@ public static MassConcentration FromMicrogramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromMicrogramsPerLiter(double value) + public static MassConcentration FromMicrogramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MicrogramPerLiter); } @@ -808,7 +806,7 @@ public static MassConcentration FromMicrogramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromMicrogramsPerMicroliter(double value) + public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMicroliter); } @@ -816,7 +814,7 @@ public static MassConcentration FromMicrogramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromMicrogramsPerMilliliter(double value) + public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMilliliter); } @@ -824,7 +822,7 @@ public static MassConcentration FromMicrogramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromMilligramsPerCubicMeter(double value) + public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MilligramPerCubicMeter); } @@ -832,7 +830,7 @@ public static MassConcentration FromMilligramsPerCubicMeter(double value) /// /// Creates a from . /// - public static MassConcentration FromMilligramsPerDeciliter(double value) + public static MassConcentration FromMilligramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MilligramPerDeciliter); } @@ -840,7 +838,7 @@ public static MassConcentration FromMilligramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromMilligramsPerLiter(double value) + public static MassConcentration FromMilligramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MilligramPerLiter); } @@ -848,7 +846,7 @@ public static MassConcentration FromMilligramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromMilligramsPerMicroliter(double value) + public static MassConcentration FromMilligramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MilligramPerMicroliter); } @@ -856,7 +854,7 @@ public static MassConcentration FromMilligramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromMilligramsPerMilliliter(double value) + public static MassConcentration FromMilligramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.MilligramPerMilliliter); } @@ -864,7 +862,7 @@ public static MassConcentration FromMilligramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromNanogramsPerDeciliter(double value) + public static MassConcentration FromNanogramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.NanogramPerDeciliter); } @@ -872,7 +870,7 @@ public static MassConcentration FromNanogramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromNanogramsPerLiter(double value) + public static MassConcentration FromNanogramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.NanogramPerLiter); } @@ -880,7 +878,7 @@ public static MassConcentration FromNanogramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromNanogramsPerMicroliter(double value) + public static MassConcentration FromNanogramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.NanogramPerMicroliter); } @@ -888,7 +886,7 @@ public static MassConcentration FromNanogramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromNanogramsPerMilliliter(double value) + public static MassConcentration FromNanogramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.NanogramPerMilliliter); } @@ -896,7 +894,7 @@ public static MassConcentration FromNanogramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromOuncesPerImperialGallon(double value) + public static MassConcentration FromOuncesPerImperialGallon(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.OuncePerImperialGallon); } @@ -904,7 +902,7 @@ public static MassConcentration FromOuncesPerImperialGallon(double value) /// /// Creates a from . /// - public static MassConcentration FromOuncesPerUSGallon(double value) + public static MassConcentration FromOuncesPerUSGallon(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.OuncePerUSGallon); } @@ -912,7 +910,7 @@ public static MassConcentration FromOuncesPerUSGallon(double value) /// /// Creates a from . /// - public static MassConcentration FromPicogramsPerDeciliter(double value) + public static MassConcentration FromPicogramsPerDeciliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PicogramPerDeciliter); } @@ -920,7 +918,7 @@ public static MassConcentration FromPicogramsPerDeciliter(double value) /// /// Creates a from . /// - public static MassConcentration FromPicogramsPerLiter(double value) + public static MassConcentration FromPicogramsPerLiter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PicogramPerLiter); } @@ -928,7 +926,7 @@ public static MassConcentration FromPicogramsPerLiter(double value) /// /// Creates a from . /// - public static MassConcentration FromPicogramsPerMicroliter(double value) + public static MassConcentration FromPicogramsPerMicroliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PicogramPerMicroliter); } @@ -936,7 +934,7 @@ public static MassConcentration FromPicogramsPerMicroliter(double value) /// /// Creates a from . /// - public static MassConcentration FromPicogramsPerMilliliter(double value) + public static MassConcentration FromPicogramsPerMilliliter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PicogramPerMilliliter); } @@ -944,7 +942,7 @@ public static MassConcentration FromPicogramsPerMilliliter(double value) /// /// Creates a from . /// - public static MassConcentration FromPoundsPerCubicFoot(double value) + public static MassConcentration FromPoundsPerCubicFoot(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicFoot); } @@ -952,7 +950,7 @@ public static MassConcentration FromPoundsPerCubicFoot(double value) /// /// Creates a from . /// - public static MassConcentration FromPoundsPerCubicInch(double value) + public static MassConcentration FromPoundsPerCubicInch(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicInch); } @@ -960,7 +958,7 @@ public static MassConcentration FromPoundsPerCubicInch(double value) /// /// Creates a from . /// - public static MassConcentration FromPoundsPerImperialGallon(double value) + public static MassConcentration FromPoundsPerImperialGallon(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PoundPerImperialGallon); } @@ -968,7 +966,7 @@ public static MassConcentration FromPoundsPerImperialGallon(double value) /// /// Creates a from . /// - public static MassConcentration FromPoundsPerUSGallon(double value) + public static MassConcentration FromPoundsPerUSGallon(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.PoundPerUSGallon); } @@ -976,7 +974,7 @@ public static MassConcentration FromPoundsPerUSGallon(double value) /// /// Creates a from . /// - public static MassConcentration FromSlugsPerCubicFoot(double value) + public static MassConcentration FromSlugsPerCubicFoot(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.SlugPerCubicFoot); } @@ -984,7 +982,7 @@ public static MassConcentration FromSlugsPerCubicFoot(double value) /// /// Creates a from . /// - public static MassConcentration FromTonnesPerCubicCentimeter(double value) + public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicCentimeter); } @@ -992,7 +990,7 @@ public static MassConcentration FromTonnesPerCubicCentimeter(double value) /// /// Creates a from . /// - public static MassConcentration FromTonnesPerCubicMeter(double value) + public static MassConcentration FromTonnesPerCubicMeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMeter); } @@ -1000,7 +998,7 @@ public static MassConcentration FromTonnesPerCubicMeter(double value) /// /// Creates a from . /// - public static MassConcentration FromTonnesPerCubicMillimeter(double value) + public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue value) { return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMillimeter); } @@ -1011,7 +1009,7 @@ public static MassConcentration FromTonnesPerCubicMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// MassConcentration unit value. - public static MassConcentration From(double value, MassConcentrationUnit fromUnit) + public static MassConcentration From(QuantityValue value, MassConcentrationUnit fromUnit) { return new MassConcentration(value, fromUnit); } @@ -1183,25 +1181,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC } /// Get from multiplying value and . - public static MassConcentration operator *(double left, MassConcentration right) + public static MassConcentration operator *(QuantityValue left, MassConcentration right) { return new MassConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassConcentration operator *(MassConcentration left, double right) + public static MassConcentration operator *(MassConcentration left, QuantityValue right) { return new MassConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassConcentration operator /(MassConcentration left, double right) + public static MassConcentration operator /(MassConcentration left, QuantityValue right) { return new MassConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassConcentration left, MassConcentration right) + public static QuantityValue operator /(MassConcentration left, MassConcentration right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1268,27 +1266,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MassConcentration left, MassConcentration right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassConcentration other, MassConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MassConcentration left, MassConcentration right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MassConcentration otherQuantity)) @@ -1298,15 +1289,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MassConcentration other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1389,10 +1377,10 @@ public bool Equals(MassConcentration other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1409,7 +1397,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassConcentration other, MassConcentration tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1422,7 +1410,12 @@ public bool Equals(MassConcentration other, MassConcentration tolerance) /// A hash code for the current MassConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1433,7 +1426,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassConcentrationUnit unit) + public QuantityValue As(MassConcentrationUnit unit) { if (Unit == unit) return Value; @@ -1442,7 +1435,7 @@ public double As(MassConcentrationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1457,7 +1450,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); @@ -1523,104 +1516,104 @@ private bool TryToUnit(MassConcentrationUnit unit, [NotNullWhen(true)] out MassC MassConcentration? convertedOrNull = (Unit, unit) switch { // MassConcentrationUnit -> BaseUnit - (MassConcentrationUnit.CentigramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-2d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.CentigramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-2d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.CentigramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-2d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.CentigramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-2d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.DecigramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-1d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.DecigramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-1d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.DecigramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-1d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.DecigramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-1d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-3, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e3, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-6, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-1, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.CentigramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 10, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.CentigramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 100, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.CentigramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 10000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.CentigramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 10, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.DecigramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.DecigramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 10, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.DecigramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 100000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.DecigramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 100, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 10, MassConcentrationUnit.KilogramPerCubicMeter), (MassConcentrationUnit.GramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-6, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.GramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-3, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.KilogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 0.062427961) * 1e3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.KilopoundPerCubicInch, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 3.6127298147753e-5) * 1e3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e3) * 1e-6d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MicrogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-6d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MicrogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-6d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MicrogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-6d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MicrogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-6d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MilligramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e3) * 1e-3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MilligramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MilligramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MilligramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.MilligramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-3d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.NanogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-9d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.NanogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-9d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.NanogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-9d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.NanogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-9d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.OuncePerImperialGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration( _value / 0.1603586720609, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.OuncePerUSGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration( _value / 0.1335264711843, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PicogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-1) * 1e-12d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PicogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value) * 1e-12d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PicogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-6) * 1e-12d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PicogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration((_value / 1e-3) * 1e-12d, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PoundPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 0.062427961, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PoundPerCubicInch, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 3.6127298147753e-5, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PoundPerImperialGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 9.9776398e1, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.PoundPerUSGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1.19826427e2, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.SlugPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 515.378818, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-9, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.TonnePerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 0.001, MassConcentrationUnit.KilogramPerCubicMeter), - (MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1e-12, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.GramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.KilogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(1000000000000, 62427961, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.KilopoundPerCubicInch, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(100, 36127298147753, false) * BigInteger.Pow(10, 19), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MicrogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 100000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MicrogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MicrogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MicrogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MilligramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MilligramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 100, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MilligramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MilligramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.MilligramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.NanogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 100000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.NanogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.NanogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.NanogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.OuncePerImperialGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(10000000000000, 1603586720609, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.OuncePerUSGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(10000000000000, 1335264711843, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PicogramPerDeciliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 100000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PicogramPerLiter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PicogramPerMicroliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PicogramPerMilliliter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value / 1000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PoundPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(1000000000, 62427961, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PoundPerCubicInch, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(1000000000000000000, 36127298147753, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PoundPerImperialGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(49888199, 500000, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.PoundPerUSGallon, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(119826427, 1000000, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.SlugPerCubicFoot, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * new QuantityValue(257689409, 500000, false), MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.TonnePerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.KilogramPerCubicMeter), + (MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentrationUnit.KilogramPerCubicMeter) => new MassConcentration(_value * 1000000000000, MassConcentrationUnit.KilogramPerCubicMeter), // BaseUnit -> MassConcentrationUnit - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-2d, MassConcentrationUnit.CentigramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerLiter) => new MassConcentration((_value) / 1e-2d, MassConcentrationUnit.CentigramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-2d, MassConcentrationUnit.CentigramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-2d, MassConcentrationUnit.CentigramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-1d, MassConcentrationUnit.DecigramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerLiter) => new MassConcentration((_value) / 1e-1d, MassConcentrationUnit.DecigramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-1d, MassConcentrationUnit.DecigramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-1d, MassConcentrationUnit.DecigramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicCentimeter) => new MassConcentration(_value * 1e-3, MassConcentrationUnit.GramPerCubicCentimeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicMeter) => new MassConcentration(_value * 1e3, MassConcentrationUnit.GramPerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicMillimeter) => new MassConcentration(_value * 1e-6, MassConcentrationUnit.GramPerCubicMillimeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerDeciliter) => new MassConcentration(_value * 1e-1, MassConcentrationUnit.GramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerDeciliter) => new MassConcentration(_value * 10, MassConcentrationUnit.CentigramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerLiter) => new MassConcentration(_value * 100, MassConcentrationUnit.CentigramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerMicroliter) => new MassConcentration(_value / 10000, MassConcentrationUnit.CentigramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.CentigramPerMilliliter) => new MassConcentration(_value / 10, MassConcentrationUnit.CentigramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerDeciliter) => new MassConcentration(_value, MassConcentrationUnit.DecigramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerLiter) => new MassConcentration(_value * 10, MassConcentrationUnit.DecigramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerMicroliter) => new MassConcentration(_value / 100000, MassConcentrationUnit.DecigramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.DecigramPerMilliliter) => new MassConcentration(_value / 100, MassConcentrationUnit.DecigramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicCentimeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.GramPerCubicCentimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicMeter) => new MassConcentration(_value * 1000, MassConcentrationUnit.GramPerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerCubicMillimeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.GramPerCubicMillimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerDeciliter) => new MassConcentration(_value / 10, MassConcentrationUnit.GramPerDeciliter), (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerLiter) => new MassConcentration(_value, MassConcentrationUnit.GramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerMicroliter) => new MassConcentration(_value * 1e-6, MassConcentrationUnit.GramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerMilliliter) => new MassConcentration(_value * 1e-3, MassConcentrationUnit.GramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicCentimeter) => new MassConcentration((_value * 1e-3) / 1e3d, MassConcentrationUnit.KilogramPerCubicCentimeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMillimeter) => new MassConcentration((_value * 1e-6) / 1e3d, MassConcentrationUnit.KilogramPerCubicMillimeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerLiter) => new MassConcentration((_value) / 1e3d, MassConcentrationUnit.KilogramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilopoundPerCubicFoot) => new MassConcentration((_value * 0.062427961) / 1e3d, MassConcentrationUnit.KilopoundPerCubicFoot), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilopoundPerCubicInch) => new MassConcentration((_value * 3.6127298147753e-5) / 1e3d, MassConcentrationUnit.KilopoundPerCubicInch), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerCubicMeter) => new MassConcentration((_value * 1e3) / 1e-6d, MassConcentrationUnit.MicrogramPerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-6d, MassConcentrationUnit.MicrogramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerLiter) => new MassConcentration((_value) / 1e-6d, MassConcentrationUnit.MicrogramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-6d, MassConcentrationUnit.MicrogramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-6d, MassConcentrationUnit.MicrogramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerCubicMeter) => new MassConcentration((_value * 1e3) / 1e-3d, MassConcentrationUnit.MilligramPerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-3d, MassConcentrationUnit.MilligramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerLiter) => new MassConcentration((_value) / 1e-3d, MassConcentrationUnit.MilligramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-3d, MassConcentrationUnit.MilligramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-3d, MassConcentrationUnit.MilligramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-9d, MassConcentrationUnit.NanogramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerLiter) => new MassConcentration((_value) / 1e-9d, MassConcentrationUnit.NanogramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-9d, MassConcentrationUnit.NanogramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-9d, MassConcentrationUnit.NanogramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.OuncePerImperialGallon) => new MassConcentration(_value * 0.1603586720609, MassConcentrationUnit.OuncePerImperialGallon), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.OuncePerUSGallon) => new MassConcentration(_value * 0.1335264711843, MassConcentrationUnit.OuncePerUSGallon), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerDeciliter) => new MassConcentration((_value * 1e-1) / 1e-12d, MassConcentrationUnit.PicogramPerDeciliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerLiter) => new MassConcentration((_value) / 1e-12d, MassConcentrationUnit.PicogramPerLiter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerMicroliter) => new MassConcentration((_value * 1e-6) / 1e-12d, MassConcentrationUnit.PicogramPerMicroliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerMilliliter) => new MassConcentration((_value * 1e-3) / 1e-12d, MassConcentrationUnit.PicogramPerMilliliter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerCubicFoot) => new MassConcentration(_value * 0.062427961, MassConcentrationUnit.PoundPerCubicFoot), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerCubicInch) => new MassConcentration(_value * 3.6127298147753e-5, MassConcentrationUnit.PoundPerCubicInch), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerImperialGallon) => new MassConcentration(_value / 9.9776398e1, MassConcentrationUnit.PoundPerImperialGallon), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerUSGallon) => new MassConcentration(_value / 1.19826427e2, MassConcentrationUnit.PoundPerUSGallon), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.SlugPerCubicFoot) => new MassConcentration(_value * 0.00194032033, MassConcentrationUnit.SlugPerCubicFoot), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicCentimeter) => new MassConcentration(_value * 1e-9, MassConcentrationUnit.TonnePerCubicCentimeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMeter) => new MassConcentration(_value * 0.001, MassConcentrationUnit.TonnePerCubicMeter), - (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMillimeter) => new MassConcentration(_value * 1e-12, MassConcentrationUnit.TonnePerCubicMillimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerMicroliter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.GramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.GramPerMilliliter) => new MassConcentration(_value / 1000, MassConcentrationUnit.GramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicCentimeter) => new MassConcentration(_value / 1000000, MassConcentrationUnit.KilogramPerCubicCentimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMillimeter) => new MassConcentration(_value / 1000000000, MassConcentrationUnit.KilogramPerCubicMillimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerLiter) => new MassConcentration(_value / 1000, MassConcentrationUnit.KilogramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilopoundPerCubicFoot) => new MassConcentration(_value * new QuantityValue(62427961, 1000000000000, false), MassConcentrationUnit.KilopoundPerCubicFoot), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilopoundPerCubicInch) => new MassConcentration(_value * new QuantityValue(36127298147753, 100, false) / BigInteger.Pow(10, 19), MassConcentrationUnit.KilopoundPerCubicInch), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerCubicMeter) => new MassConcentration(_value * 1000000000, MassConcentrationUnit.MicrogramPerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerDeciliter) => new MassConcentration(_value * 100000, MassConcentrationUnit.MicrogramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerLiter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.MicrogramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerMicroliter) => new MassConcentration(_value, MassConcentrationUnit.MicrogramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MicrogramPerMilliliter) => new MassConcentration(_value * 1000, MassConcentrationUnit.MicrogramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerCubicMeter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.MilligramPerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerDeciliter) => new MassConcentration(_value * 100, MassConcentrationUnit.MilligramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerLiter) => new MassConcentration(_value * 1000, MassConcentrationUnit.MilligramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerMicroliter) => new MassConcentration(_value / 1000, MassConcentrationUnit.MilligramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.MilligramPerMilliliter) => new MassConcentration(_value, MassConcentrationUnit.MilligramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerDeciliter) => new MassConcentration(_value * 100000000, MassConcentrationUnit.NanogramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerLiter) => new MassConcentration(_value * 1000000000, MassConcentrationUnit.NanogramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerMicroliter) => new MassConcentration(_value * 1000, MassConcentrationUnit.NanogramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.NanogramPerMilliliter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.NanogramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.OuncePerImperialGallon) => new MassConcentration(_value * new QuantityValue(1603586720609, 10000000000000, false), MassConcentrationUnit.OuncePerImperialGallon), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.OuncePerUSGallon) => new MassConcentration(_value * new QuantityValue(1335264711843, 10000000000000, false), MassConcentrationUnit.OuncePerUSGallon), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerDeciliter) => new MassConcentration(_value * 100000000000, MassConcentrationUnit.PicogramPerDeciliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerLiter) => new MassConcentration(_value * 1000000000000, MassConcentrationUnit.PicogramPerLiter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerMicroliter) => new MassConcentration(_value * 1000000, MassConcentrationUnit.PicogramPerMicroliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PicogramPerMilliliter) => new MassConcentration(_value * 1000000000, MassConcentrationUnit.PicogramPerMilliliter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerCubicFoot) => new MassConcentration(_value * new QuantityValue(62427961, 1000000000, false), MassConcentrationUnit.PoundPerCubicFoot), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerCubicInch) => new MassConcentration(_value * new QuantityValue(36127298147753, 1000000000000000000, false), MassConcentrationUnit.PoundPerCubicInch), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerImperialGallon) => new MassConcentration(_value * new QuantityValue(500000, 49888199, false), MassConcentrationUnit.PoundPerImperialGallon), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.PoundPerUSGallon) => new MassConcentration(_value * new QuantityValue(1000000, 119826427, false), MassConcentrationUnit.PoundPerUSGallon), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.SlugPerCubicFoot) => new MassConcentration(_value * new QuantityValue(194032033, 100000000000, false), MassConcentrationUnit.SlugPerCubicFoot), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicCentimeter) => new MassConcentration(_value / 1000000000, MassConcentrationUnit.TonnePerCubicCentimeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMeter) => new MassConcentration(_value / 1000, MassConcentrationUnit.TonnePerCubicMeter), + (MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMillimeter) => new MassConcentration(_value / 1000000000000, MassConcentrationUnit.TonnePerCubicMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 5c62f5b89c..e52703a0b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -63,7 +61,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -125,7 +123,7 @@ static MassFlow() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MassFlow(double value, MassFlowUnit unit) + public MassFlow(QuantityValue value, MassFlowUnit unit) { _value = value; _unit = unit; @@ -139,7 +137,7 @@ public MassFlow(double value, MassFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlow(double value, UnitSystem unitSystem) + public MassFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -190,10 +188,10 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -218,167 +216,167 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); + public QuantityValue CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); + public QuantityValue CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); + public QuantityValue DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); /// /// Gets a value of this quantity converted into /// - public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); + public QuantityValue DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); + public QuantityValue DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); + public QuantityValue DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); /// /// Gets a value of this quantity converted into /// - public double GramsPerDay => As(MassFlowUnit.GramPerDay); + public QuantityValue GramsPerDay => As(MassFlowUnit.GramPerDay); /// /// Gets a value of this quantity converted into /// - public double GramsPerHour => As(MassFlowUnit.GramPerHour); + public QuantityValue GramsPerHour => As(MassFlowUnit.GramPerHour); /// /// Gets a value of this quantity converted into /// - public double GramsPerSecond => As(MassFlowUnit.GramPerSecond); + public QuantityValue GramsPerSecond => As(MassFlowUnit.GramPerSecond); /// /// Gets a value of this quantity converted into /// - public double HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); + public QuantityValue HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); /// /// Gets a value of this quantity converted into /// - public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); + public QuantityValue HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); + public QuantityValue KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); + public QuantityValue KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); + public QuantityValue KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); + public QuantityValue KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); + public QuantityValue MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); /// /// Gets a value of this quantity converted into /// - public double MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); + public QuantityValue MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); /// /// Gets a value of this quantity converted into /// - public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); + public QuantityValue MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); /// /// Gets a value of this quantity converted into /// - public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); + public QuantityValue MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); /// /// Gets a value of this quantity converted into /// - public double MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); + public QuantityValue MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); + public QuantityValue MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); + public QuantityValue MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); + public QuantityValue MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); + public QuantityValue MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); + public QuantityValue NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); + public QuantityValue NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); /// /// Gets a value of this quantity converted into /// - public double PoundsPerDay => As(MassFlowUnit.PoundPerDay); + public QuantityValue PoundsPerDay => As(MassFlowUnit.PoundPerDay); /// /// Gets a value of this quantity converted into /// - public double PoundsPerHour => As(MassFlowUnit.PoundPerHour); + public QuantityValue PoundsPerHour => As(MassFlowUnit.PoundPerHour); /// /// Gets a value of this quantity converted into /// - public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); + public QuantityValue PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); /// /// Gets a value of this quantity converted into /// - public double PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); + public QuantityValue PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); /// /// Gets a value of this quantity converted into /// - public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); + public QuantityValue ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); /// /// Gets a value of this quantity converted into /// - public double TonnesPerDay => As(MassFlowUnit.TonnePerDay); + public QuantityValue TonnesPerDay => As(MassFlowUnit.TonnePerDay); /// /// Gets a value of this quantity converted into /// - public double TonnesPerHour => As(MassFlowUnit.TonnePerHour); + public QuantityValue TonnesPerHour => As(MassFlowUnit.TonnePerHour); #endregion @@ -490,7 +488,7 @@ public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static MassFlow FromCentigramsPerDay(double value) + public static MassFlow FromCentigramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.CentigramPerDay); } @@ -498,7 +496,7 @@ public static MassFlow FromCentigramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromCentigramsPerSecond(double value) + public static MassFlow FromCentigramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.CentigramPerSecond); } @@ -506,7 +504,7 @@ public static MassFlow FromCentigramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromDecagramsPerDay(double value) + public static MassFlow FromDecagramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.DecagramPerDay); } @@ -514,7 +512,7 @@ public static MassFlow FromDecagramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromDecagramsPerSecond(double value) + public static MassFlow FromDecagramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.DecagramPerSecond); } @@ -522,7 +520,7 @@ public static MassFlow FromDecagramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromDecigramsPerDay(double value) + public static MassFlow FromDecigramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.DecigramPerDay); } @@ -530,7 +528,7 @@ public static MassFlow FromDecigramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromDecigramsPerSecond(double value) + public static MassFlow FromDecigramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.DecigramPerSecond); } @@ -538,7 +536,7 @@ public static MassFlow FromDecigramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromGramsPerDay(double value) + public static MassFlow FromGramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.GramPerDay); } @@ -546,7 +544,7 @@ public static MassFlow FromGramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromGramsPerHour(double value) + public static MassFlow FromGramsPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.GramPerHour); } @@ -554,7 +552,7 @@ public static MassFlow FromGramsPerHour(double value) /// /// Creates a from . /// - public static MassFlow FromGramsPerSecond(double value) + public static MassFlow FromGramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.GramPerSecond); } @@ -562,7 +560,7 @@ public static MassFlow FromGramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromHectogramsPerDay(double value) + public static MassFlow FromHectogramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.HectogramPerDay); } @@ -570,7 +568,7 @@ public static MassFlow FromHectogramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromHectogramsPerSecond(double value) + public static MassFlow FromHectogramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.HectogramPerSecond); } @@ -578,7 +576,7 @@ public static MassFlow FromHectogramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromKilogramsPerDay(double value) + public static MassFlow FromKilogramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.KilogramPerDay); } @@ -586,7 +584,7 @@ public static MassFlow FromKilogramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromKilogramsPerHour(double value) + public static MassFlow FromKilogramsPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.KilogramPerHour); } @@ -594,7 +592,7 @@ public static MassFlow FromKilogramsPerHour(double value) /// /// Creates a from . /// - public static MassFlow FromKilogramsPerMinute(double value) + public static MassFlow FromKilogramsPerMinute(QuantityValue value) { return new MassFlow(value, MassFlowUnit.KilogramPerMinute); } @@ -602,7 +600,7 @@ public static MassFlow FromKilogramsPerMinute(double value) /// /// Creates a from . /// - public static MassFlow FromKilogramsPerSecond(double value) + public static MassFlow FromKilogramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.KilogramPerSecond); } @@ -610,7 +608,7 @@ public static MassFlow FromKilogramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromMegagramsPerDay(double value) + public static MassFlow FromMegagramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MegagramPerDay); } @@ -618,7 +616,7 @@ public static MassFlow FromMegagramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromMegapoundsPerDay(double value) + public static MassFlow FromMegapoundsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MegapoundPerDay); } @@ -626,7 +624,7 @@ public static MassFlow FromMegapoundsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromMegapoundsPerHour(double value) + public static MassFlow FromMegapoundsPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MegapoundPerHour); } @@ -634,7 +632,7 @@ public static MassFlow FromMegapoundsPerHour(double value) /// /// Creates a from . /// - public static MassFlow FromMegapoundsPerMinute(double value) + public static MassFlow FromMegapoundsPerMinute(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MegapoundPerMinute); } @@ -642,7 +640,7 @@ public static MassFlow FromMegapoundsPerMinute(double value) /// /// Creates a from . /// - public static MassFlow FromMegapoundsPerSecond(double value) + public static MassFlow FromMegapoundsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MegapoundPerSecond); } @@ -650,7 +648,7 @@ public static MassFlow FromMegapoundsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromMicrogramsPerDay(double value) + public static MassFlow FromMicrogramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MicrogramPerDay); } @@ -658,7 +656,7 @@ public static MassFlow FromMicrogramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromMicrogramsPerSecond(double value) + public static MassFlow FromMicrogramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MicrogramPerSecond); } @@ -666,7 +664,7 @@ public static MassFlow FromMicrogramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromMilligramsPerDay(double value) + public static MassFlow FromMilligramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MilligramPerDay); } @@ -674,7 +672,7 @@ public static MassFlow FromMilligramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromMilligramsPerSecond(double value) + public static MassFlow FromMilligramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.MilligramPerSecond); } @@ -682,7 +680,7 @@ public static MassFlow FromMilligramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromNanogramsPerDay(double value) + public static MassFlow FromNanogramsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.NanogramPerDay); } @@ -690,7 +688,7 @@ public static MassFlow FromNanogramsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromNanogramsPerSecond(double value) + public static MassFlow FromNanogramsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.NanogramPerSecond); } @@ -698,7 +696,7 @@ public static MassFlow FromNanogramsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromPoundsPerDay(double value) + public static MassFlow FromPoundsPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.PoundPerDay); } @@ -706,7 +704,7 @@ public static MassFlow FromPoundsPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromPoundsPerHour(double value) + public static MassFlow FromPoundsPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.PoundPerHour); } @@ -714,7 +712,7 @@ public static MassFlow FromPoundsPerHour(double value) /// /// Creates a from . /// - public static MassFlow FromPoundsPerMinute(double value) + public static MassFlow FromPoundsPerMinute(QuantityValue value) { return new MassFlow(value, MassFlowUnit.PoundPerMinute); } @@ -722,7 +720,7 @@ public static MassFlow FromPoundsPerMinute(double value) /// /// Creates a from . /// - public static MassFlow FromPoundsPerSecond(double value) + public static MassFlow FromPoundsPerSecond(QuantityValue value) { return new MassFlow(value, MassFlowUnit.PoundPerSecond); } @@ -730,7 +728,7 @@ public static MassFlow FromPoundsPerSecond(double value) /// /// Creates a from . /// - public static MassFlow FromShortTonsPerHour(double value) + public static MassFlow FromShortTonsPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.ShortTonPerHour); } @@ -738,7 +736,7 @@ public static MassFlow FromShortTonsPerHour(double value) /// /// Creates a from . /// - public static MassFlow FromTonnesPerDay(double value) + public static MassFlow FromTonnesPerDay(QuantityValue value) { return new MassFlow(value, MassFlowUnit.TonnePerDay); } @@ -746,7 +744,7 @@ public static MassFlow FromTonnesPerDay(double value) /// /// Creates a from . /// - public static MassFlow FromTonnesPerHour(double value) + public static MassFlow FromTonnesPerHour(QuantityValue value) { return new MassFlow(value, MassFlowUnit.TonnePerHour); } @@ -757,7 +755,7 @@ public static MassFlow FromTonnesPerHour(double value) /// Value to convert from. /// Unit to convert from. /// MassFlow unit value. - public static MassFlow From(double value, MassFlowUnit fromUnit) + public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit) { return new MassFlow(value, fromUnit); } @@ -929,25 +927,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlow operator *(double left, MassFlow right) + public static MassFlow operator *(QuantityValue left, MassFlow right) { return new MassFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlow operator *(MassFlow left, double right) + public static MassFlow operator *(MassFlow left, QuantityValue right) { return new MassFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlow operator /(MassFlow left, double right) + public static MassFlow operator /(MassFlow left, QuantityValue right) { return new MassFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFlow left, MassFlow right) + public static QuantityValue operator /(MassFlow left, MassFlow right) { return left.GramsPerSecond / right.GramsPerSecond; } @@ -1044,27 +1042,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MassFlow left, MassFlow right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlow other, MassFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MassFlow left, MassFlow right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MassFlow otherQuantity)) @@ -1074,15 +1065,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MassFlow other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1165,10 +1153,10 @@ public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1185,7 +1173,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFlow other, MassFlow tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1198,7 +1186,12 @@ public bool Equals(MassFlow other, MassFlow tolerance) /// A hash code for the current MassFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1209,7 +1202,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFlowUnit unit) + public QuantityValue As(MassFlowUnit unit) { if (Unit == unit) return Value; @@ -1218,7 +1211,7 @@ public double As(MassFlowUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1233,7 +1226,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); @@ -1299,72 +1292,72 @@ private bool TryToUnit(MassFlowUnit unit, [NotNullWhen(true)] out MassFlow? conv MassFlow? convertedOrNull = (Unit, unit) switch { // MassFlowUnit -> BaseUnit - (MassFlowUnit.CentigramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e-2d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.CentigramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e-2d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.DecagramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e1d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.DecagramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e1d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.DecigramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e-1d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.DecigramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e-1d, MassFlowUnit.GramPerSecond), + (MassFlowUnit.CentigramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 8640000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.CentigramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 100, MassFlowUnit.GramPerSecond), + (MassFlowUnit.DecagramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 8640, MassFlowUnit.GramPerSecond), + (MassFlowUnit.DecagramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 10, MassFlowUnit.GramPerSecond), + (MassFlowUnit.DecigramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 864000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.DecigramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 10, MassFlowUnit.GramPerSecond), (MassFlowUnit.GramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 86400, MassFlowUnit.GramPerSecond), (MassFlowUnit.GramPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 3600, MassFlowUnit.GramPerSecond), - (MassFlowUnit.HectogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e2d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.HectogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e2d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.KilogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e3d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.KilogramPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 3.6, MassFlowUnit.GramPerSecond), - (MassFlowUnit.KilogramPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 0.06, MassFlowUnit.GramPerSecond), - (MassFlowUnit.KilogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e3d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MegagramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MegapoundPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 190.47936) * 1e6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MegapoundPerHour, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 7.93664) * 1e6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MegapoundPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 0.132277) * 1e6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MegapoundPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value * 453.59237) * 1e6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MicrogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e-6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MicrogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e-6d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MilligramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e-3d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.MilligramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e-3d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.NanogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow((_value / 86400) * 1e-9d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.NanogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow((_value) * 1e-9d, MassFlowUnit.GramPerSecond), - (MassFlowUnit.PoundPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 190.47936, MassFlowUnit.GramPerSecond), - (MassFlowUnit.PoundPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 7.93664, MassFlowUnit.GramPerSecond), - (MassFlowUnit.PoundPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 0.132277, MassFlowUnit.GramPerSecond), - (MassFlowUnit.PoundPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 453.59237, MassFlowUnit.GramPerSecond), - (MassFlowUnit.ShortTonPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 251.9957611, MassFlowUnit.GramPerSecond), - (MassFlowUnit.TonnePerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 0.0864000, MassFlowUnit.GramPerSecond), - (MassFlowUnit.TonnePerHour, MassFlowUnit.GramPerSecond) => new MassFlow(1000 * _value / 3.6, MassFlowUnit.GramPerSecond), + (MassFlowUnit.HectogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 864, MassFlowUnit.GramPerSecond), + (MassFlowUnit.HectogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 100, MassFlowUnit.GramPerSecond), + (MassFlowUnit.KilogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(5, 432, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.KilogramPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(5, 18, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.KilogramPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(50, 3, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.KilogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 1000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.MegagramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(625, 54, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.MegapoundPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(195312500, 37203, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.MegapoundPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(1562500000, 12401, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.MegapoundPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(1000000000000, 132277, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.MegapoundPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * 453592370, MassFlowUnit.GramPerSecond), + (MassFlowUnit.MicrogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 86400000000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.MicrogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 1000000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.MilligramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 86400000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.MilligramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 1000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.NanogramPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 86400000000000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.NanogramPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value / 1000000000, MassFlowUnit.GramPerSecond), + (MassFlowUnit.PoundPerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(3125, 595248, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.PoundPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(3125, 24802, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.PoundPerMinute, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(1000000, 132277, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.PoundPerSecond, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(45359237, 100000, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.ShortTonPerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(2519957611, 10000000, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.TonnePerDay, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(625, 54, false), MassFlowUnit.GramPerSecond), + (MassFlowUnit.TonnePerHour, MassFlowUnit.GramPerSecond) => new MassFlow(_value * new QuantityValue(2500, 9, false), MassFlowUnit.GramPerSecond), // BaseUnit -> MassFlowUnit - (MassFlowUnit.GramPerSecond, MassFlowUnit.CentigramPerDay) => new MassFlow((_value * 86400) / 1e-2d, MassFlowUnit.CentigramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.CentigramPerSecond) => new MassFlow((_value) / 1e-2d, MassFlowUnit.CentigramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.DecagramPerDay) => new MassFlow((_value * 86400) / 1e1d, MassFlowUnit.DecagramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.DecagramPerSecond) => new MassFlow((_value) / 1e1d, MassFlowUnit.DecagramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.DecigramPerDay) => new MassFlow((_value * 86400) / 1e-1d, MassFlowUnit.DecigramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.DecigramPerSecond) => new MassFlow((_value) / 1e-1d, MassFlowUnit.DecigramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.CentigramPerDay) => new MassFlow(_value * 8640000, MassFlowUnit.CentigramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.CentigramPerSecond) => new MassFlow(_value * 100, MassFlowUnit.CentigramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.DecagramPerDay) => new MassFlow(_value * 8640, MassFlowUnit.DecagramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.DecagramPerSecond) => new MassFlow(_value / 10, MassFlowUnit.DecagramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.DecigramPerDay) => new MassFlow(_value * 864000, MassFlowUnit.DecigramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.DecigramPerSecond) => new MassFlow(_value * 10, MassFlowUnit.DecigramPerSecond), (MassFlowUnit.GramPerSecond, MassFlowUnit.GramPerDay) => new MassFlow(_value * 86400, MassFlowUnit.GramPerDay), (MassFlowUnit.GramPerSecond, MassFlowUnit.GramPerHour) => new MassFlow(_value * 3600, MassFlowUnit.GramPerHour), - (MassFlowUnit.GramPerSecond, MassFlowUnit.HectogramPerDay) => new MassFlow((_value * 86400) / 1e2d, MassFlowUnit.HectogramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.HectogramPerSecond) => new MassFlow((_value) / 1e2d, MassFlowUnit.HectogramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerDay) => new MassFlow((_value * 86400) / 1e3d, MassFlowUnit.KilogramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerHour) => new MassFlow(_value * 3.6, MassFlowUnit.KilogramPerHour), - (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerMinute) => new MassFlow(_value * 0.06, MassFlowUnit.KilogramPerMinute), - (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerSecond) => new MassFlow((_value) / 1e3d, MassFlowUnit.KilogramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MegagramPerDay) => new MassFlow((_value * 86400) / 1e6d, MassFlowUnit.MegagramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerDay) => new MassFlow((_value * 190.47936) / 1e6d, MassFlowUnit.MegapoundPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerHour) => new MassFlow((_value * 7.93664) / 1e6d, MassFlowUnit.MegapoundPerHour), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerMinute) => new MassFlow((_value * 0.132277) / 1e6d, MassFlowUnit.MegapoundPerMinute), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerSecond) => new MassFlow((_value / 453.59237) / 1e6d, MassFlowUnit.MegapoundPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MicrogramPerDay) => new MassFlow((_value * 86400) / 1e-6d, MassFlowUnit.MicrogramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MicrogramPerSecond) => new MassFlow((_value) / 1e-6d, MassFlowUnit.MicrogramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MilligramPerDay) => new MassFlow((_value * 86400) / 1e-3d, MassFlowUnit.MilligramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.MilligramPerSecond) => new MassFlow((_value) / 1e-3d, MassFlowUnit.MilligramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.NanogramPerDay) => new MassFlow((_value * 86400) / 1e-9d, MassFlowUnit.NanogramPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.NanogramPerSecond) => new MassFlow((_value) / 1e-9d, MassFlowUnit.NanogramPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerDay) => new MassFlow(_value * 190.47936, MassFlowUnit.PoundPerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerHour) => new MassFlow(_value * 7.93664, MassFlowUnit.PoundPerHour), - (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerMinute) => new MassFlow(_value * 0.132277, MassFlowUnit.PoundPerMinute), - (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerSecond) => new MassFlow(_value / 453.59237, MassFlowUnit.PoundPerSecond), - (MassFlowUnit.GramPerSecond, MassFlowUnit.ShortTonPerHour) => new MassFlow(_value / 251.9957611, MassFlowUnit.ShortTonPerHour), - (MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerDay) => new MassFlow(_value * 0.0864000, MassFlowUnit.TonnePerDay), - (MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerHour) => new MassFlow(_value * 3.6 / 1000, MassFlowUnit.TonnePerHour), + (MassFlowUnit.GramPerSecond, MassFlowUnit.HectogramPerDay) => new MassFlow(_value * 864, MassFlowUnit.HectogramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.HectogramPerSecond) => new MassFlow(_value / 100, MassFlowUnit.HectogramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerDay) => new MassFlow(_value * new QuantityValue(432, 5, false), MassFlowUnit.KilogramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerHour) => new MassFlow(_value * new QuantityValue(18, 5, false), MassFlowUnit.KilogramPerHour), + (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerMinute) => new MassFlow(_value * new QuantityValue(3, 50, false), MassFlowUnit.KilogramPerMinute), + (MassFlowUnit.GramPerSecond, MassFlowUnit.KilogramPerSecond) => new MassFlow(_value / 1000, MassFlowUnit.KilogramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MegagramPerDay) => new MassFlow(_value * new QuantityValue(54, 625, false), MassFlowUnit.MegagramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerDay) => new MassFlow(_value * new QuantityValue(37203, 195312500, false), MassFlowUnit.MegapoundPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerHour) => new MassFlow(_value * new QuantityValue(12401, 1562500000, false), MassFlowUnit.MegapoundPerHour), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerMinute) => new MassFlow(_value * new QuantityValue(132277, 1000000000000, false), MassFlowUnit.MegapoundPerMinute), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MegapoundPerSecond) => new MassFlow(_value / 453592370, MassFlowUnit.MegapoundPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MicrogramPerDay) => new MassFlow(_value * 86400000000, MassFlowUnit.MicrogramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MicrogramPerSecond) => new MassFlow(_value * 1000000, MassFlowUnit.MicrogramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MilligramPerDay) => new MassFlow(_value * 86400000, MassFlowUnit.MilligramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.MilligramPerSecond) => new MassFlow(_value * 1000, MassFlowUnit.MilligramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.NanogramPerDay) => new MassFlow(_value * 86400000000000, MassFlowUnit.NanogramPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.NanogramPerSecond) => new MassFlow(_value * 1000000000, MassFlowUnit.NanogramPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerDay) => new MassFlow(_value * new QuantityValue(595248, 3125, false), MassFlowUnit.PoundPerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerHour) => new MassFlow(_value * new QuantityValue(24802, 3125, false), MassFlowUnit.PoundPerHour), + (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerMinute) => new MassFlow(_value * new QuantityValue(132277, 1000000, false), MassFlowUnit.PoundPerMinute), + (MassFlowUnit.GramPerSecond, MassFlowUnit.PoundPerSecond) => new MassFlow(_value * new QuantityValue(100000, 45359237, false), MassFlowUnit.PoundPerSecond), + (MassFlowUnit.GramPerSecond, MassFlowUnit.ShortTonPerHour) => new MassFlow(_value * new QuantityValue(10000000, 2519957611, false), MassFlowUnit.ShortTonPerHour), + (MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerDay) => new MassFlow(_value * new QuantityValue(54, 625, false), MassFlowUnit.TonnePerDay), + (MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerHour) => new MassFlow(_value * new QuantityValue(9, 2500, false), MassFlowUnit.TonnePerHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 51e34f5505..a626167975 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -56,7 +54,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +95,7 @@ static MassFlux() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MassFlux(double value, MassFluxUnit unit) + public MassFlux(QuantityValue value, MassFluxUnit unit) { _value = value; _unit = unit; @@ -111,7 +109,7 @@ public MassFlux(double value, MassFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlux(double value, UnitSystem unitSystem) + public MassFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,10 +160,10 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -190,62 +188,62 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); + public QuantityValue GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); + public QuantityValue GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); + public QuantityValue GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); + public QuantityValue GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); + public QuantityValue GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); + public QuantityValue GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); + public QuantityValue KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); + public QuantityValue KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); + public QuantityValue KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + public QuantityValue KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); + public QuantityValue KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + public QuantityValue KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); #endregion @@ -315,7 +313,7 @@ public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static MassFlux FromGramsPerHourPerSquareCentimeter(double value) + public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareCentimeter); } @@ -323,7 +321,7 @@ public static MassFlux FromGramsPerHourPerSquareCentimeter(double value) /// /// Creates a from . /// - public static MassFlux FromGramsPerHourPerSquareMeter(double value) + public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMeter); } @@ -331,7 +329,7 @@ public static MassFlux FromGramsPerHourPerSquareMeter(double value) /// /// Creates a from . /// - public static MassFlux FromGramsPerHourPerSquareMillimeter(double value) + public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMillimeter); } @@ -339,7 +337,7 @@ public static MassFlux FromGramsPerHourPerSquareMillimeter(double value) /// /// Creates a from . /// - public static MassFlux FromGramsPerSecondPerSquareCentimeter(double value) + public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareCentimeter); } @@ -347,7 +345,7 @@ public static MassFlux FromGramsPerSecondPerSquareCentimeter(double value) /// /// Creates a from . /// - public static MassFlux FromGramsPerSecondPerSquareMeter(double value) + public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter); } @@ -355,7 +353,7 @@ public static MassFlux FromGramsPerSecondPerSquareMeter(double value) /// /// Creates a from . /// - public static MassFlux FromGramsPerSecondPerSquareMillimeter(double value) + public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMillimeter); } @@ -363,7 +361,7 @@ public static MassFlux FromGramsPerSecondPerSquareMillimeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerHourPerSquareCentimeter(double value) + public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareCentimeter); } @@ -371,7 +369,7 @@ public static MassFlux FromKilogramsPerHourPerSquareCentimeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerHourPerSquareMeter(double value) + public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMeter); } @@ -379,7 +377,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerHourPerSquareMillimeter(double value) + public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMillimeter); } @@ -387,7 +385,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMillimeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(double value) + public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); } @@ -395,7 +393,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerSecondPerSquareMeter(double value) + public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter); } @@ -403,7 +401,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMeter(double value) /// /// Creates a from . /// - public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(double value) + public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue value) { return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); } @@ -414,7 +412,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// MassFlux unit value. - public static MassFlux From(double value, MassFluxUnit fromUnit) + public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit) { return new MassFlux(value, fromUnit); } @@ -586,25 +584,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlux operator *(double left, MassFlux right) + public static MassFlux operator *(QuantityValue left, MassFlux right) { return new MassFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlux operator *(MassFlux left, double right) + public static MassFlux operator *(MassFlux left, QuantityValue right) { return new MassFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlux operator /(MassFlux left, double right) + public static MassFlux operator /(MassFlux left, QuantityValue right) { return new MassFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFlux left, MassFlux right) + public static QuantityValue operator /(MassFlux left, MassFlux right) { return left.KilogramsPerSecondPerSquareMeter / right.KilogramsPerSecondPerSquareMeter; } @@ -659,27 +657,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MassFlux left, MassFlux right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFlux other, MassFlux tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MassFlux left, MassFlux right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MassFlux otherQuantity)) @@ -689,15 +680,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MassFlux other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -780,10 +768,10 @@ public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -800,7 +788,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFlux other, MassFlux tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -813,7 +801,12 @@ public bool Equals(MassFlux other, MassFlux tolerance) /// A hash code for the current MassFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -824,7 +817,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFluxUnit unit) + public QuantityValue As(MassFluxUnit unit) { if (Unit == unit) return Value; @@ -833,7 +826,7 @@ public double As(MassFluxUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -848,7 +841,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); @@ -914,30 +907,30 @@ private bool TryToUnit(MassFluxUnit unit, [NotNullWhen(true)] out MassFlux? conv MassFlux? convertedOrNull = (Unit, unit) switch { // MassFluxUnit -> BaseUnit - (MassFluxUnit.GramPerHourPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 3.6e2, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.GramPerHourPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 3.6e6, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.GramPerHourPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 3.6e0, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 1e-1, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.GramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 1e3, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 1e-3, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux((_value / 3.6e2) * 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerHourPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux((_value / 3.6e6) * 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux((_value / 3.6e0) * 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux((_value / 1e-1) * 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux((_value / 1e-3) * 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerHourPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 360, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerHourPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 3600000, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerHourPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * new QuantityValue(5, 18, false), MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * 10, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 1000, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * 1000, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * new QuantityValue(25, 9, false), MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerHourPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value / 3600, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * new QuantityValue(2500, 9, false), MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * 10000, MassFluxUnit.KilogramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFluxUnit.KilogramPerSecondPerSquareMeter) => new MassFlux(_value * 1000000, MassFluxUnit.KilogramPerSecondPerSquareMeter), // BaseUnit -> MassFluxUnit - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareCentimeter) => new MassFlux(_value * 3.6e2, MassFluxUnit.GramPerHourPerSquareCentimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareMeter) => new MassFlux(_value * 3.6e6, MassFluxUnit.GramPerHourPerSquareMeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareMillimeter) => new MassFlux(_value * 3.6e0, MassFluxUnit.GramPerHourPerSquareMillimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareCentimeter) => new MassFlux(_value * 1e-1, MassFluxUnit.GramPerSecondPerSquareCentimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareMeter) => new MassFlux(_value * 1e3, MassFluxUnit.GramPerSecondPerSquareMeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareMillimeter) => new MassFlux(_value * 1e-3, MassFluxUnit.GramPerSecondPerSquareMillimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareCentimeter) => new MassFlux((_value * 3.6e2) / 1e3d, MassFluxUnit.KilogramPerHourPerSquareCentimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareMeter) => new MassFlux((_value * 3.6e6) / 1e3d, MassFluxUnit.KilogramPerHourPerSquareMeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareMillimeter) => new MassFlux((_value * 3.6e0) / 1e3d, MassFluxUnit.KilogramPerHourPerSquareMillimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareCentimeter) => new MassFlux((_value * 1e-1) / 1e3d, MassFluxUnit.KilogramPerSecondPerSquareCentimeter), - (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMillimeter) => new MassFlux((_value * 1e-3) / 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMillimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareCentimeter) => new MassFlux(_value * 360, MassFluxUnit.GramPerHourPerSquareCentimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareMeter) => new MassFlux(_value * 3600000, MassFluxUnit.GramPerHourPerSquareMeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerHourPerSquareMillimeter) => new MassFlux(_value * new QuantityValue(18, 5, false), MassFluxUnit.GramPerHourPerSquareMillimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareCentimeter) => new MassFlux(_value / 10, MassFluxUnit.GramPerSecondPerSquareCentimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareMeter) => new MassFlux(_value * 1000, MassFluxUnit.GramPerSecondPerSquareMeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.GramPerSecondPerSquareMillimeter) => new MassFlux(_value / 1000, MassFluxUnit.GramPerSecondPerSquareMillimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareCentimeter) => new MassFlux(_value * new QuantityValue(9, 25, false), MassFluxUnit.KilogramPerHourPerSquareCentimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareMeter) => new MassFlux(_value * 3600, MassFluxUnit.KilogramPerHourPerSquareMeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareMillimeter) => new MassFlux(_value * new QuantityValue(9, 2500, false), MassFluxUnit.KilogramPerHourPerSquareMillimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareCentimeter) => new MassFlux(_value / 10000, MassFluxUnit.KilogramPerSecondPerSquareCentimeter), + (MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMillimeter) => new MassFlux(_value / 1000000, MassFluxUnit.KilogramPerSecondPerSquareMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index b7de21355e..bc3bad75ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -57,7 +55,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -110,7 +108,7 @@ static MassFraction() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MassFraction(double value, MassFractionUnit unit) + public MassFraction(QuantityValue value, MassFractionUnit unit) { _value = value; _unit = unit; @@ -124,7 +122,7 @@ public MassFraction(double value, MassFractionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFraction(double value, UnitSystem unitSystem) + public MassFraction(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -175,10 +173,10 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -203,122 +201,122 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); + public QuantityValue CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); /// /// Gets a value of this quantity converted into /// - public double CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); + public QuantityValue CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); + public QuantityValue DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); /// /// Gets a value of this quantity converted into /// - public double DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); + public QuantityValue DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); + public QuantityValue DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); + public QuantityValue DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double DecimalFractions => As(MassFractionUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(MassFractionUnit.DecimalFraction); /// /// Gets a value of this quantity converted into /// - public double GramsPerGram => As(MassFractionUnit.GramPerGram); + public QuantityValue GramsPerGram => As(MassFractionUnit.GramPerGram); /// /// Gets a value of this quantity converted into /// - public double GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); + public QuantityValue GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); + public QuantityValue HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); /// /// Gets a value of this quantity converted into /// - public double HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); + public QuantityValue HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); + public QuantityValue KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); + public QuantityValue KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); + public QuantityValue MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); + public QuantityValue MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); + public QuantityValue MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); + public QuantityValue MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); + public QuantityValue NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); + public QuantityValue NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); /// /// Gets a value of this quantity converted into /// - public double PartsPerBillion => As(MassFractionUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(MassFractionUnit.PartPerBillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerMillion => As(MassFractionUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(MassFractionUnit.PartPerMillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerThousand => As(MassFractionUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(MassFractionUnit.PartPerThousand); /// /// Gets a value of this quantity converted into /// - public double PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); /// /// Gets a value of this quantity converted into /// - public double Percent => As(MassFractionUnit.Percent); + public QuantityValue Percent => As(MassFractionUnit.Percent); #endregion @@ -412,7 +410,7 @@ public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static MassFraction FromCentigramsPerGram(double value) + public static MassFraction FromCentigramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.CentigramPerGram); } @@ -420,7 +418,7 @@ public static MassFraction FromCentigramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromCentigramsPerKilogram(double value) + public static MassFraction FromCentigramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.CentigramPerKilogram); } @@ -428,7 +426,7 @@ public static MassFraction FromCentigramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromDecagramsPerGram(double value) + public static MassFraction FromDecagramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.DecagramPerGram); } @@ -436,7 +434,7 @@ public static MassFraction FromDecagramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromDecagramsPerKilogram(double value) + public static MassFraction FromDecagramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.DecagramPerKilogram); } @@ -444,7 +442,7 @@ public static MassFraction FromDecagramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromDecigramsPerGram(double value) + public static MassFraction FromDecigramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.DecigramPerGram); } @@ -452,7 +450,7 @@ public static MassFraction FromDecigramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromDecigramsPerKilogram(double value) + public static MassFraction FromDecigramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.DecigramPerKilogram); } @@ -460,7 +458,7 @@ public static MassFraction FromDecigramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromDecimalFractions(double value) + public static MassFraction FromDecimalFractions(QuantityValue value) { return new MassFraction(value, MassFractionUnit.DecimalFraction); } @@ -468,7 +466,7 @@ public static MassFraction FromDecimalFractions(double value) /// /// Creates a from . /// - public static MassFraction FromGramsPerGram(double value) + public static MassFraction FromGramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.GramPerGram); } @@ -476,7 +474,7 @@ public static MassFraction FromGramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromGramsPerKilogram(double value) + public static MassFraction FromGramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.GramPerKilogram); } @@ -484,7 +482,7 @@ public static MassFraction FromGramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromHectogramsPerGram(double value) + public static MassFraction FromHectogramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.HectogramPerGram); } @@ -492,7 +490,7 @@ public static MassFraction FromHectogramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromHectogramsPerKilogram(double value) + public static MassFraction FromHectogramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.HectogramPerKilogram); } @@ -500,7 +498,7 @@ public static MassFraction FromHectogramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromKilogramsPerGram(double value) + public static MassFraction FromKilogramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.KilogramPerGram); } @@ -508,7 +506,7 @@ public static MassFraction FromKilogramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromKilogramsPerKilogram(double value) + public static MassFraction FromKilogramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.KilogramPerKilogram); } @@ -516,7 +514,7 @@ public static MassFraction FromKilogramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromMicrogramsPerGram(double value) + public static MassFraction FromMicrogramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.MicrogramPerGram); } @@ -524,7 +522,7 @@ public static MassFraction FromMicrogramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromMicrogramsPerKilogram(double value) + public static MassFraction FromMicrogramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.MicrogramPerKilogram); } @@ -532,7 +530,7 @@ public static MassFraction FromMicrogramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromMilligramsPerGram(double value) + public static MassFraction FromMilligramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.MilligramPerGram); } @@ -540,7 +538,7 @@ public static MassFraction FromMilligramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromMilligramsPerKilogram(double value) + public static MassFraction FromMilligramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.MilligramPerKilogram); } @@ -548,7 +546,7 @@ public static MassFraction FromMilligramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromNanogramsPerGram(double value) + public static MassFraction FromNanogramsPerGram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.NanogramPerGram); } @@ -556,7 +554,7 @@ public static MassFraction FromNanogramsPerGram(double value) /// /// Creates a from . /// - public static MassFraction FromNanogramsPerKilogram(double value) + public static MassFraction FromNanogramsPerKilogram(QuantityValue value) { return new MassFraction(value, MassFractionUnit.NanogramPerKilogram); } @@ -564,7 +562,7 @@ public static MassFraction FromNanogramsPerKilogram(double value) /// /// Creates a from . /// - public static MassFraction FromPartsPerBillion(double value) + public static MassFraction FromPartsPerBillion(QuantityValue value) { return new MassFraction(value, MassFractionUnit.PartPerBillion); } @@ -572,7 +570,7 @@ public static MassFraction FromPartsPerBillion(double value) /// /// Creates a from . /// - public static MassFraction FromPartsPerMillion(double value) + public static MassFraction FromPartsPerMillion(QuantityValue value) { return new MassFraction(value, MassFractionUnit.PartPerMillion); } @@ -580,7 +578,7 @@ public static MassFraction FromPartsPerMillion(double value) /// /// Creates a from . /// - public static MassFraction FromPartsPerThousand(double value) + public static MassFraction FromPartsPerThousand(QuantityValue value) { return new MassFraction(value, MassFractionUnit.PartPerThousand); } @@ -588,7 +586,7 @@ public static MassFraction FromPartsPerThousand(double value) /// /// Creates a from . /// - public static MassFraction FromPartsPerTrillion(double value) + public static MassFraction FromPartsPerTrillion(QuantityValue value) { return new MassFraction(value, MassFractionUnit.PartPerTrillion); } @@ -596,7 +594,7 @@ public static MassFraction FromPartsPerTrillion(double value) /// /// Creates a from . /// - public static MassFraction FromPercent(double value) + public static MassFraction FromPercent(QuantityValue value) { return new MassFraction(value, MassFractionUnit.Percent); } @@ -607,7 +605,7 @@ public static MassFraction FromPercent(double value) /// Value to convert from. /// Unit to convert from. /// MassFraction unit value. - public static MassFraction From(double value, MassFractionUnit fromUnit) + public static MassFraction From(QuantityValue value, MassFractionUnit fromUnit) { return new MassFraction(value, fromUnit); } @@ -779,25 +777,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFraction operator *(double left, MassFraction right) + public static MassFraction operator *(QuantityValue left, MassFraction right) { return new MassFraction(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFraction operator *(MassFraction left, double right) + public static MassFraction operator *(MassFraction left, QuantityValue right) { return new MassFraction(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFraction operator /(MassFraction left, double right) + public static MassFraction operator /(MassFraction left, QuantityValue right) { return new MassFraction(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFraction left, MassFraction right) + public static QuantityValue operator /(MassFraction left, MassFraction right) { return left.DecimalFractions / right.DecimalFractions; } @@ -840,27 +838,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MassFraction left, MassFraction right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassFraction other, MassFraction tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MassFraction left, MassFraction right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MassFraction otherQuantity)) @@ -870,15 +861,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MassFraction other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -961,10 +949,10 @@ public bool Equals(MassFraction other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -981,7 +969,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassFraction other, MassFraction tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -994,7 +982,12 @@ public bool Equals(MassFraction other, MassFraction tolerance) /// A hash code for the current MassFraction. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1005,7 +998,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFractionUnit unit) + public QuantityValue As(MassFractionUnit unit) { if (Unit == unit) return Value; @@ -1014,7 +1007,7 @@ public double As(MassFractionUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1029,7 +1022,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); @@ -1095,54 +1088,54 @@ private bool TryToUnit(MassFractionUnit unit, [NotNullWhen(true)] out MassFracti MassFraction? convertedOrNull = (Unit, unit) switch { // MassFractionUnit -> BaseUnit - (MassFractionUnit.CentigramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e-2d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.CentigramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e-2d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.DecagramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e1d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.DecagramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e1d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.DecigramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e-1d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.DecigramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e-1d, MassFractionUnit.DecimalFraction), + (MassFractionUnit.CentigramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 100, MassFractionUnit.DecimalFraction), + (MassFractionUnit.CentigramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 100000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.DecagramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value * 10, MassFractionUnit.DecimalFraction), + (MassFractionUnit.DecagramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 100, MassFractionUnit.DecimalFraction), + (MassFractionUnit.DecigramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 10, MassFractionUnit.DecimalFraction), + (MassFractionUnit.DecigramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 10000, MassFractionUnit.DecimalFraction), (MassFractionUnit.GramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value, MassFractionUnit.DecimalFraction), - (MassFractionUnit.GramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e3, MassFractionUnit.DecimalFraction), - (MassFractionUnit.HectogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e2d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.HectogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e2d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.KilogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e3d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.KilogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e3d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.MicrogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e-6d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.MicrogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e-6d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.MilligramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e-3d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.MilligramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e-3d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.NanogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction((_value) * 1e-9d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.NanogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction((_value / 1e3) * 1e-9d, MassFractionUnit.DecimalFraction), - (MassFractionUnit.PartPerBillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e9, MassFractionUnit.DecimalFraction), - (MassFractionUnit.PartPerMillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e6, MassFractionUnit.DecimalFraction), - (MassFractionUnit.PartPerThousand, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e3, MassFractionUnit.DecimalFraction), - (MassFractionUnit.PartPerTrillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e12, MassFractionUnit.DecimalFraction), - (MassFractionUnit.Percent, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1e2, MassFractionUnit.DecimalFraction), + (MassFractionUnit.GramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.HectogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value * 100, MassFractionUnit.DecimalFraction), + (MassFractionUnit.HectogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 10, MassFractionUnit.DecimalFraction), + (MassFractionUnit.KilogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value * 1000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.KilogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value, MassFractionUnit.DecimalFraction), + (MassFractionUnit.MicrogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.MicrogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.MilligramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.MilligramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.NanogramPerGram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.NanogramPerKilogram, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.PartPerBillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.PartPerMillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.PartPerThousand, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.PartPerTrillion, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 1000000000000, MassFractionUnit.DecimalFraction), + (MassFractionUnit.Percent, MassFractionUnit.DecimalFraction) => new MassFraction(_value / 100, MassFractionUnit.DecimalFraction), // BaseUnit -> MassFractionUnit - (MassFractionUnit.DecimalFraction, MassFractionUnit.CentigramPerGram) => new MassFraction((_value) / 1e-2d, MassFractionUnit.CentigramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.CentigramPerKilogram) => new MassFraction((_value * 1e3) / 1e-2d, MassFractionUnit.CentigramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.DecagramPerGram) => new MassFraction((_value) / 1e1d, MassFractionUnit.DecagramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.DecagramPerKilogram) => new MassFraction((_value * 1e3) / 1e1d, MassFractionUnit.DecagramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.DecigramPerGram) => new MassFraction((_value) / 1e-1d, MassFractionUnit.DecigramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.DecigramPerKilogram) => new MassFraction((_value * 1e3) / 1e-1d, MassFractionUnit.DecigramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.CentigramPerGram) => new MassFraction(_value * 100, MassFractionUnit.CentigramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.CentigramPerKilogram) => new MassFraction(_value * 100000, MassFractionUnit.CentigramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.DecagramPerGram) => new MassFraction(_value / 10, MassFractionUnit.DecagramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.DecagramPerKilogram) => new MassFraction(_value * 100, MassFractionUnit.DecagramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.DecigramPerGram) => new MassFraction(_value * 10, MassFractionUnit.DecigramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.DecigramPerKilogram) => new MassFraction(_value * 10000, MassFractionUnit.DecigramPerKilogram), (MassFractionUnit.DecimalFraction, MassFractionUnit.GramPerGram) => new MassFraction(_value, MassFractionUnit.GramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.GramPerKilogram) => new MassFraction(_value * 1e3, MassFractionUnit.GramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.HectogramPerGram) => new MassFraction((_value) / 1e2d, MassFractionUnit.HectogramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.HectogramPerKilogram) => new MassFraction((_value * 1e3) / 1e2d, MassFractionUnit.HectogramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.KilogramPerGram) => new MassFraction((_value) / 1e3d, MassFractionUnit.KilogramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.KilogramPerKilogram) => new MassFraction((_value * 1e3) / 1e3d, MassFractionUnit.KilogramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.MicrogramPerGram) => new MassFraction((_value) / 1e-6d, MassFractionUnit.MicrogramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.MicrogramPerKilogram) => new MassFraction((_value * 1e3) / 1e-6d, MassFractionUnit.MicrogramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.MilligramPerGram) => new MassFraction((_value) / 1e-3d, MassFractionUnit.MilligramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.MilligramPerKilogram) => new MassFraction((_value * 1e3) / 1e-3d, MassFractionUnit.MilligramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.NanogramPerGram) => new MassFraction((_value) / 1e-9d, MassFractionUnit.NanogramPerGram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.NanogramPerKilogram) => new MassFraction((_value * 1e3) / 1e-9d, MassFractionUnit.NanogramPerKilogram), - (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerBillion) => new MassFraction(_value * 1e9, MassFractionUnit.PartPerBillion), - (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerMillion) => new MassFraction(_value * 1e6, MassFractionUnit.PartPerMillion), - (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerThousand) => new MassFraction(_value * 1e3, MassFractionUnit.PartPerThousand), - (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerTrillion) => new MassFraction(_value * 1e12, MassFractionUnit.PartPerTrillion), - (MassFractionUnit.DecimalFraction, MassFractionUnit.Percent) => new MassFraction(_value * 1e2, MassFractionUnit.Percent), + (MassFractionUnit.DecimalFraction, MassFractionUnit.GramPerKilogram) => new MassFraction(_value * 1000, MassFractionUnit.GramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.HectogramPerGram) => new MassFraction(_value / 100, MassFractionUnit.HectogramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.HectogramPerKilogram) => new MassFraction(_value * 10, MassFractionUnit.HectogramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.KilogramPerGram) => new MassFraction(_value / 1000, MassFractionUnit.KilogramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.KilogramPerKilogram) => new MassFraction(_value, MassFractionUnit.KilogramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.MicrogramPerGram) => new MassFraction(_value * 1000000, MassFractionUnit.MicrogramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.MicrogramPerKilogram) => new MassFraction(_value * 1000000000, MassFractionUnit.MicrogramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.MilligramPerGram) => new MassFraction(_value * 1000, MassFractionUnit.MilligramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.MilligramPerKilogram) => new MassFraction(_value * 1000000, MassFractionUnit.MilligramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.NanogramPerGram) => new MassFraction(_value * 1000000000, MassFractionUnit.NanogramPerGram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.NanogramPerKilogram) => new MassFraction(_value * 1000000000000, MassFractionUnit.NanogramPerKilogram), + (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerBillion) => new MassFraction(_value * 1000000000, MassFractionUnit.PartPerBillion), + (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerMillion) => new MassFraction(_value * 1000000, MassFractionUnit.PartPerMillion), + (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerThousand) => new MassFraction(_value * 1000, MassFractionUnit.PartPerThousand), + (MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerTrillion) => new MassFraction(_value * 1000000000000, MassFractionUnit.PartPerTrillion), + (MassFractionUnit.DecimalFraction, MassFractionUnit.Percent) => new MassFraction(_value * 100, MassFractionUnit.Percent), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 7a4a7052fa..1303b88dca 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -105,7 +106,7 @@ static MassMomentOfInertia() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) + public MassMomentOfInertia(QuantityValue value, MassMomentOfInertiaUnit unit) { _value = value; _unit = unit; @@ -119,7 +120,7 @@ public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassMomentOfInertia(double value, UnitSystem unitSystem) + public MassMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -170,10 +171,10 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -198,142 +199,142 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); + public QuantityValue GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); + public QuantityValue GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); + public QuantityValue GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); /// /// Gets a value of this quantity converted into /// - public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); + public QuantityValue GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); + public QuantityValue KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); + public QuantityValue KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); + public QuantityValue KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); + public QuantityValue KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + public QuantityValue KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + public QuantityValue KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); + public QuantityValue KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + public QuantityValue KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); /// /// Gets a value of this quantity converted into /// - public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + public QuantityValue MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + public QuantityValue MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); + public QuantityValue MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + public QuantityValue MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); /// /// Gets a value of this quantity converted into /// - public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); + public QuantityValue MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); + public QuantityValue MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); + public QuantityValue MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); /// /// Gets a value of this quantity converted into /// - public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); + public QuantityValue MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); + public QuantityValue PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); /// /// Gets a value of this quantity converted into /// - public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); + public QuantityValue PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); /// /// Gets a value of this quantity converted into /// - public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); + public QuantityValue SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); /// /// Gets a value of this quantity converted into /// - public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); + public QuantityValue SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); /// /// Gets a value of this quantity converted into /// - public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); + public QuantityValue TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); + public QuantityValue TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); + public QuantityValue TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); /// /// Gets a value of this quantity converted into /// - public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); + public QuantityValue TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); #endregion @@ -435,7 +436,7 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvid /// /// Creates a from . /// - public static MassMomentOfInertia FromGramSquareCentimeters(double value) + public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter); } @@ -443,7 +444,7 @@ public static MassMomentOfInertia FromGramSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromGramSquareDecimeters(double value) + public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter); } @@ -451,7 +452,7 @@ public static MassMomentOfInertia FromGramSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromGramSquareMeters(double value) + public static MassMomentOfInertia FromGramSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter); } @@ -459,7 +460,7 @@ public static MassMomentOfInertia FromGramSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromGramSquareMillimeters(double value) + public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter); } @@ -467,7 +468,7 @@ public static MassMomentOfInertia FromGramSquareMillimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilogramSquareCentimeters(double value) + public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter); } @@ -475,7 +476,7 @@ public static MassMomentOfInertia FromKilogramSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilogramSquareDecimeters(double value) + public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter); } @@ -483,7 +484,7 @@ public static MassMomentOfInertia FromKilogramSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilogramSquareMeters(double value) + public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter); } @@ -491,7 +492,7 @@ public static MassMomentOfInertia FromKilogramSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilogramSquareMillimeters(double value) + public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter); } @@ -499,7 +500,7 @@ public static MassMomentOfInertia FromKilogramSquareMillimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilotonneSquareCentimeters(double value) + public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); } @@ -507,7 +508,7 @@ public static MassMomentOfInertia FromKilotonneSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilotonneSquareDecimeters(double value) + public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); } @@ -515,7 +516,7 @@ public static MassMomentOfInertia FromKilotonneSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilotonneSquareMeters(double value) + public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter); } @@ -523,7 +524,7 @@ public static MassMomentOfInertia FromKilotonneSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromKilotonneSquareMilimeters(double value) + public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); } @@ -531,7 +532,7 @@ public static MassMomentOfInertia FromKilotonneSquareMilimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMegatonneSquareCentimeters(double value) + public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); } @@ -539,7 +540,7 @@ public static MassMomentOfInertia FromMegatonneSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMegatonneSquareDecimeters(double value) + public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); } @@ -547,7 +548,7 @@ public static MassMomentOfInertia FromMegatonneSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMegatonneSquareMeters(double value) + public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter); } @@ -555,7 +556,7 @@ public static MassMomentOfInertia FromMegatonneSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMegatonneSquareMilimeters(double value) + public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); } @@ -563,7 +564,7 @@ public static MassMomentOfInertia FromMegatonneSquareMilimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMilligramSquareCentimeters(double value) + public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter); } @@ -571,7 +572,7 @@ public static MassMomentOfInertia FromMilligramSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMilligramSquareDecimeters(double value) + public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter); } @@ -579,7 +580,7 @@ public static MassMomentOfInertia FromMilligramSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMilligramSquareMeters(double value) + public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter); } @@ -587,7 +588,7 @@ public static MassMomentOfInertia FromMilligramSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromMilligramSquareMillimeters(double value) + public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter); } @@ -595,7 +596,7 @@ public static MassMomentOfInertia FromMilligramSquareMillimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromPoundSquareFeet(double value) + public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot); } @@ -603,7 +604,7 @@ public static MassMomentOfInertia FromPoundSquareFeet(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromPoundSquareInches(double value) + public static MassMomentOfInertia FromPoundSquareInches(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch); } @@ -611,7 +612,7 @@ public static MassMomentOfInertia FromPoundSquareInches(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromSlugSquareFeet(double value) + public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot); } @@ -619,7 +620,7 @@ public static MassMomentOfInertia FromSlugSquareFeet(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromSlugSquareInches(double value) + public static MassMomentOfInertia FromSlugSquareInches(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch); } @@ -627,7 +628,7 @@ public static MassMomentOfInertia FromSlugSquareInches(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromTonneSquareCentimeters(double value) + public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter); } @@ -635,7 +636,7 @@ public static MassMomentOfInertia FromTonneSquareCentimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromTonneSquareDecimeters(double value) + public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter); } @@ -643,7 +644,7 @@ public static MassMomentOfInertia FromTonneSquareDecimeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromTonneSquareMeters(double value) + public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter); } @@ -651,7 +652,7 @@ public static MassMomentOfInertia FromTonneSquareMeters(double value) /// /// Creates a from . /// - public static MassMomentOfInertia FromTonneSquareMilimeters(double value) + public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue value) { return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter); } @@ -662,7 +663,7 @@ public static MassMomentOfInertia FromTonneSquareMilimeters(double value) /// Value to convert from. /// Unit to convert from. /// MassMomentOfInertia unit value. - public static MassMomentOfInertia From(double value, MassMomentOfInertiaUnit fromUnit) + public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaUnit fromUnit) { return new MassMomentOfInertia(value, fromUnit); } @@ -834,25 +835,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(double left, MassMomentOfInertia right) + public static MassMomentOfInertia operator *(QuantityValue left, MassMomentOfInertia right) { return new MassMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(MassMomentOfInertia left, double right) + public static MassMomentOfInertia operator *(MassMomentOfInertia left, QuantityValue right) { return new MassMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassMomentOfInertia operator /(MassMomentOfInertia left, double right) + public static MassMomentOfInertia operator /(MassMomentOfInertia left, QuantityValue right) { return new MassMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassMomentOfInertia left, MassMomentOfInertia right) + public static QuantityValue operator /(MassMomentOfInertia left, MassMomentOfInertia right) { return left.KilogramSquareMeters / right.KilogramSquareMeters; } @@ -885,27 +886,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MassMomentOfInertia otherQuantity)) @@ -915,15 +909,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MassMomentOfInertia other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1006,10 +997,10 @@ public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1026,7 +1017,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1039,7 +1030,12 @@ public bool Equals(MassMomentOfInertia other, MassMomentOfInertia tolerance) /// A hash code for the current MassMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1050,7 +1046,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassMomentOfInertiaUnit unit) + public QuantityValue As(MassMomentOfInertiaUnit unit) { if (Unit == unit) return Value; @@ -1059,7 +1055,7 @@ public double As(MassMomentOfInertiaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1074,7 +1070,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); @@ -1140,62 +1136,62 @@ private bool TryToUnit(MassMomentOfInertiaUnit unit, [NotNullWhen(true)] out Mas MassMomentOfInertia? convertedOrNull = (Unit, unit) switch { // MassMomentOfInertiaUnit -> BaseUnit - (MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e7, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e5, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e3, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e9, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e7) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e5) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e9) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e1) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e-1) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e-3) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e3) * 1e3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e1) * 1e6d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e-1) * 1e6d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e-3) * 1e6d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e3) * 1e6d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e7) * 1e-3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e5) * 1e-3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e3) * 1e-3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia((_value / 1e9) * 1e-3d, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 4.21401101e-2, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 2.9263965e-4, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 1.3558179619, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 9.41540242e-3, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e1, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e-1, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e-3, MassMomentOfInertiaUnit.KilogramSquareMeter), - (MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1e3, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 10000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 100000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 10000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 100, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 100, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 10000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 1000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 100000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 10000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 1000000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 1000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 10000000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 100000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000000000000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * new QuantityValue(421401101, 10000000000, false), MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * new QuantityValue(5852793, 20000000000, false), MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * new QuantityValue(13558179619, 10000000000, false), MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * new QuantityValue(470770121, 50000000000, false), MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 10, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 10, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value * 1000, MassMomentOfInertiaUnit.KilogramSquareMeter), + (MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertiaUnit.KilogramSquareMeter) => new MassMomentOfInertia(_value / 1000, MassMomentOfInertiaUnit.KilogramSquareMeter), // BaseUnit -> MassMomentOfInertiaUnit - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareCentimeter) => new MassMomentOfInertia(_value * 1e7, MassMomentOfInertiaUnit.GramSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareDecimeter) => new MassMomentOfInertia(_value * 1e5, MassMomentOfInertiaUnit.GramSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareMeter) => new MassMomentOfInertia(_value * 1e3, MassMomentOfInertiaUnit.GramSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareMillimeter) => new MassMomentOfInertia(_value * 1e9, MassMomentOfInertiaUnit.GramSquareMillimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareCentimeter) => new MassMomentOfInertia((_value * 1e7) / 1e3d, MassMomentOfInertiaUnit.KilogramSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareDecimeter) => new MassMomentOfInertia((_value * 1e5) / 1e3d, MassMomentOfInertiaUnit.KilogramSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMillimeter) => new MassMomentOfInertia((_value * 1e9) / 1e3d, MassMomentOfInertiaUnit.KilogramSquareMillimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareCentimeter) => new MassMomentOfInertia((_value * 1e1) / 1e3d, MassMomentOfInertiaUnit.KilotonneSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareDecimeter) => new MassMomentOfInertia((_value * 1e-1) / 1e3d, MassMomentOfInertiaUnit.KilotonneSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareMeter) => new MassMomentOfInertia((_value * 1e-3) / 1e3d, MassMomentOfInertiaUnit.KilotonneSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareMilimeter) => new MassMomentOfInertia((_value * 1e3) / 1e3d, MassMomentOfInertiaUnit.KilotonneSquareMilimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareCentimeter) => new MassMomentOfInertia((_value * 1e1) / 1e6d, MassMomentOfInertiaUnit.MegatonneSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareDecimeter) => new MassMomentOfInertia((_value * 1e-1) / 1e6d, MassMomentOfInertiaUnit.MegatonneSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareMeter) => new MassMomentOfInertia((_value * 1e-3) / 1e6d, MassMomentOfInertiaUnit.MegatonneSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareMilimeter) => new MassMomentOfInertia((_value * 1e3) / 1e6d, MassMomentOfInertiaUnit.MegatonneSquareMilimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareCentimeter) => new MassMomentOfInertia((_value * 1e7) / 1e-3d, MassMomentOfInertiaUnit.MilligramSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareDecimeter) => new MassMomentOfInertia((_value * 1e5) / 1e-3d, MassMomentOfInertiaUnit.MilligramSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareMeter) => new MassMomentOfInertia((_value * 1e3) / 1e-3d, MassMomentOfInertiaUnit.MilligramSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareMillimeter) => new MassMomentOfInertia((_value * 1e9) / 1e-3d, MassMomentOfInertiaUnit.MilligramSquareMillimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.PoundSquareFoot) => new MassMomentOfInertia(_value / 4.21401101e-2, MassMomentOfInertiaUnit.PoundSquareFoot), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.PoundSquareInch) => new MassMomentOfInertia(_value / 2.9263965e-4, MassMomentOfInertiaUnit.PoundSquareInch), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.SlugSquareFoot) => new MassMomentOfInertia(_value / 1.3558179619, MassMomentOfInertiaUnit.SlugSquareFoot), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.SlugSquareInch) => new MassMomentOfInertia(_value / 9.41540242e-3, MassMomentOfInertiaUnit.SlugSquareInch), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareCentimeter) => new MassMomentOfInertia(_value * 1e1, MassMomentOfInertiaUnit.TonneSquareCentimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareDecimeter) => new MassMomentOfInertia(_value * 1e-1, MassMomentOfInertiaUnit.TonneSquareDecimeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMeter) => new MassMomentOfInertia(_value * 1e-3, MassMomentOfInertiaUnit.TonneSquareMeter), - (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMilimeter) => new MassMomentOfInertia(_value * 1e3, MassMomentOfInertiaUnit.TonneSquareMilimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareCentimeter) => new MassMomentOfInertia(_value * 10000000, MassMomentOfInertiaUnit.GramSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareDecimeter) => new MassMomentOfInertia(_value * 100000, MassMomentOfInertiaUnit.GramSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareMeter) => new MassMomentOfInertia(_value * 1000, MassMomentOfInertiaUnit.GramSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.GramSquareMillimeter) => new MassMomentOfInertia(_value * 1000000000, MassMomentOfInertiaUnit.GramSquareMillimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareCentimeter) => new MassMomentOfInertia(_value * 10000, MassMomentOfInertiaUnit.KilogramSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareDecimeter) => new MassMomentOfInertia(_value * 100, MassMomentOfInertiaUnit.KilogramSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMillimeter) => new MassMomentOfInertia(_value * 1000000, MassMomentOfInertiaUnit.KilogramSquareMillimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareCentimeter) => new MassMomentOfInertia(_value / 100, MassMomentOfInertiaUnit.KilotonneSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareDecimeter) => new MassMomentOfInertia(_value / 10000, MassMomentOfInertiaUnit.KilotonneSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareMeter) => new MassMomentOfInertia(_value / 1000000, MassMomentOfInertiaUnit.KilotonneSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilotonneSquareMilimeter) => new MassMomentOfInertia(_value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareCentimeter) => new MassMomentOfInertia(_value / 100000, MassMomentOfInertiaUnit.MegatonneSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareDecimeter) => new MassMomentOfInertia(_value / 10000000, MassMomentOfInertiaUnit.MegatonneSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareMeter) => new MassMomentOfInertia(_value / 1000000000, MassMomentOfInertiaUnit.MegatonneSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MegatonneSquareMilimeter) => new MassMomentOfInertia(_value / 1000, MassMomentOfInertiaUnit.MegatonneSquareMilimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareCentimeter) => new MassMomentOfInertia(_value * 10000000000, MassMomentOfInertiaUnit.MilligramSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareDecimeter) => new MassMomentOfInertia(_value * 100000000, MassMomentOfInertiaUnit.MilligramSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareMeter) => new MassMomentOfInertia(_value * 1000000, MassMomentOfInertiaUnit.MilligramSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.MilligramSquareMillimeter) => new MassMomentOfInertia(_value * 1000000000000, MassMomentOfInertiaUnit.MilligramSquareMillimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.PoundSquareFoot) => new MassMomentOfInertia(_value * new QuantityValue(10000000000, 421401101, false), MassMomentOfInertiaUnit.PoundSquareFoot), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.PoundSquareInch) => new MassMomentOfInertia(_value * new QuantityValue(20000000000, 5852793, false), MassMomentOfInertiaUnit.PoundSquareInch), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.SlugSquareFoot) => new MassMomentOfInertia(_value * new QuantityValue(10000000000, 13558179619, false), MassMomentOfInertiaUnit.SlugSquareFoot), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.SlugSquareInch) => new MassMomentOfInertia(_value * new QuantityValue(50000000000, 470770121, false), MassMomentOfInertiaUnit.SlugSquareInch), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareCentimeter) => new MassMomentOfInertia(_value * 10, MassMomentOfInertiaUnit.TonneSquareCentimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareDecimeter) => new MassMomentOfInertia(_value / 10, MassMomentOfInertiaUnit.TonneSquareDecimeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMeter) => new MassMomentOfInertia(_value / 1000, MassMomentOfInertiaUnit.TonneSquareMeter), + (MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMilimeter) => new MassMomentOfInertia(_value * 1000, MassMomentOfInertiaUnit.TonneSquareMilimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs index 157fd23c5a..c6c77377ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molality.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molality.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,7 +83,7 @@ static Molality() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Molality(double value, MolalityUnit unit) + public Molality(QuantityValue value, MolalityUnit unit) { _value = value; _unit = unit; @@ -96,7 +97,7 @@ public Molality(double value, MolalityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Molality(double value, UnitSystem unitSystem) + public Molality(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -147,10 +148,10 @@ public Molality(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -175,12 +176,12 @@ public Molality(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double MolesPerGram => As(MolalityUnit.MolePerGram); + public QuantityValue MolesPerGram => As(MolalityUnit.MolePerGram); /// /// Gets a value of this quantity converted into /// - public double MolesPerKilogram => As(MolalityUnit.MolePerKilogram); + public QuantityValue MolesPerKilogram => As(MolalityUnit.MolePerKilogram); #endregion @@ -230,7 +231,7 @@ public static string GetAbbreviation(MolalityUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static Molality FromMolesPerGram(double value) + public static Molality FromMolesPerGram(QuantityValue value) { return new Molality(value, MolalityUnit.MolePerGram); } @@ -238,7 +239,7 @@ public static Molality FromMolesPerGram(double value) /// /// Creates a from . /// - public static Molality FromMolesPerKilogram(double value) + public static Molality FromMolesPerKilogram(QuantityValue value) { return new Molality(value, MolalityUnit.MolePerKilogram); } @@ -249,7 +250,7 @@ public static Molality FromMolesPerKilogram(double value) /// Value to convert from. /// Unit to convert from. /// Molality unit value. - public static Molality From(double value, MolalityUnit fromUnit) + public static Molality From(QuantityValue value, MolalityUnit fromUnit) { return new Molality(value, fromUnit); } @@ -421,25 +422,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molal } /// Get from multiplying value and . - public static Molality operator *(double left, Molality right) + public static Molality operator *(QuantityValue left, Molality right) { return new Molality(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Molality operator *(Molality left, double right) + public static Molality operator *(Molality left, QuantityValue right) { return new Molality(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Molality operator /(Molality left, double right) + public static Molality operator /(Molality left, QuantityValue right) { return new Molality(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Molality left, Molality right) + public static QuantityValue operator /(Molality left, Molality right) { return left.MolesPerKilogram / right.MolesPerKilogram; } @@ -472,27 +473,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molal return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Molality left, Molality right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Molality left, Molality right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Molality otherQuantity)) @@ -502,15 +496,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Molality other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -593,10 +584,10 @@ public bool Equals(Molality other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -613,7 +604,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Molality other, Molality tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -626,7 +617,12 @@ public bool Equals(Molality other, Molality tolerance) /// A hash code for the current Molality. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -637,7 +633,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolalityUnit unit) + public QuantityValue As(MolalityUnit unit) { if (Unit == unit) return Value; @@ -646,7 +642,7 @@ public double As(MolalityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -661,7 +657,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolalityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolalityUnit)} is supported.", nameof(unit)); @@ -727,10 +723,10 @@ private bool TryToUnit(MolalityUnit unit, [NotNullWhen(true)] out Molality? conv Molality? convertedOrNull = (Unit, unit) switch { // MolalityUnit -> BaseUnit - (MolalityUnit.MolePerGram, MolalityUnit.MolePerKilogram) => new Molality(_value / 1e-3, MolalityUnit.MolePerKilogram), + (MolalityUnit.MolePerGram, MolalityUnit.MolePerKilogram) => new Molality(_value * 1000, MolalityUnit.MolePerKilogram), // BaseUnit -> MolalityUnit - (MolalityUnit.MolePerKilogram, MolalityUnit.MolePerGram) => new Molality(_value * 1e-3, MolalityUnit.MolePerGram), + (MolalityUnit.MolePerKilogram, MolalityUnit.MolePerGram) => new Molality(_value / 1000, MolalityUnit.MolePerGram), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index f6fc2c95b2..edf11b26cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,7 +81,7 @@ static MolarEnergy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MolarEnergy(double value, MolarEnergyUnit unit) + public MolarEnergy(QuantityValue value, MolarEnergyUnit unit) { _value = value; _unit = unit; @@ -94,7 +95,7 @@ public MolarEnergy(double value, MolarEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEnergy(double value, UnitSystem unitSystem) + public MolarEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -145,10 +146,10 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,17 +174,17 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); + public QuantityValue JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); + public QuantityValue KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); + public QuantityValue MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); #endregion @@ -235,7 +236,7 @@ public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static MolarEnergy FromJoulesPerMole(double value) + public static MolarEnergy FromJoulesPerMole(QuantityValue value) { return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole); } @@ -243,7 +244,7 @@ public static MolarEnergy FromJoulesPerMole(double value) /// /// Creates a from . /// - public static MolarEnergy FromKilojoulesPerMole(double value) + public static MolarEnergy FromKilojoulesPerMole(QuantityValue value) { return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole); } @@ -251,7 +252,7 @@ public static MolarEnergy FromKilojoulesPerMole(double value) /// /// Creates a from . /// - public static MolarEnergy FromMegajoulesPerMole(double value) + public static MolarEnergy FromMegajoulesPerMole(QuantityValue value) { return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole); } @@ -262,7 +263,7 @@ public static MolarEnergy FromMegajoulesPerMole(double value) /// Value to convert from. /// Unit to convert from. /// MolarEnergy unit value. - public static MolarEnergy From(double value, MolarEnergyUnit fromUnit) + public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit) { return new MolarEnergy(value, fromUnit); } @@ -434,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEnergy operator *(double left, MolarEnergy right) + public static MolarEnergy operator *(QuantityValue left, MolarEnergy right) { return new MolarEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEnergy operator *(MolarEnergy left, double right) + public static MolarEnergy operator *(MolarEnergy left, QuantityValue right) { return new MolarEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEnergy operator /(MolarEnergy left, double right) + public static MolarEnergy operator /(MolarEnergy left, QuantityValue right) { return new MolarEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarEnergy left, MolarEnergy right) + public static QuantityValue operator /(MolarEnergy left, MolarEnergy right) { return left.JoulesPerMole / right.JoulesPerMole; } @@ -485,27 +486,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MolarEnergy left, MolarEnergy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEnergy other, MolarEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MolarEnergy left, MolarEnergy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MolarEnergy otherQuantity)) @@ -515,15 +509,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MolarEnergy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -606,10 +597,10 @@ public bool Equals(MolarEnergy other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -626,7 +617,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarEnergy other, MolarEnergy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -639,7 +630,12 @@ public bool Equals(MolarEnergy other, MolarEnergy tolerance) /// A hash code for the current MolarEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -650,7 +646,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEnergyUnit unit) + public QuantityValue As(MolarEnergyUnit unit) { if (Unit == unit) return Value; @@ -659,7 +655,7 @@ public double As(MolarEnergyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,7 +670,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); @@ -740,12 +736,12 @@ private bool TryToUnit(MolarEnergyUnit unit, [NotNullWhen(true)] out MolarEnergy MolarEnergy? convertedOrNull = (Unit, unit) switch { // MolarEnergyUnit -> BaseUnit - (MolarEnergyUnit.KilojoulePerMole, MolarEnergyUnit.JoulePerMole) => new MolarEnergy((_value) * 1e3d, MolarEnergyUnit.JoulePerMole), - (MolarEnergyUnit.MegajoulePerMole, MolarEnergyUnit.JoulePerMole) => new MolarEnergy((_value) * 1e6d, MolarEnergyUnit.JoulePerMole), + (MolarEnergyUnit.KilojoulePerMole, MolarEnergyUnit.JoulePerMole) => new MolarEnergy(_value * 1000, MolarEnergyUnit.JoulePerMole), + (MolarEnergyUnit.MegajoulePerMole, MolarEnergyUnit.JoulePerMole) => new MolarEnergy(_value * 1000000, MolarEnergyUnit.JoulePerMole), // BaseUnit -> MolarEnergyUnit - (MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.KilojoulePerMole) => new MolarEnergy((_value) / 1e3d, MolarEnergyUnit.KilojoulePerMole), - (MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.MegajoulePerMole) => new MolarEnergy((_value) / 1e6d, MolarEnergyUnit.MegajoulePerMole), + (MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.KilojoulePerMole) => new MolarEnergy(_value / 1000, MolarEnergyUnit.KilojoulePerMole), + (MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.MegajoulePerMole) => new MolarEnergy(_value / 1000000, MolarEnergyUnit.MegajoulePerMole), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 3cb388b5d4..ecd31f40d8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,7 +81,7 @@ static MolarEntropy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MolarEntropy(double value, MolarEntropyUnit unit) + public MolarEntropy(QuantityValue value, MolarEntropyUnit unit) { _value = value; _unit = unit; @@ -94,7 +95,7 @@ public MolarEntropy(double value, MolarEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEntropy(double value, UnitSystem unitSystem) + public MolarEntropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -145,10 +146,10 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,17 +174,17 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); + public QuantityValue JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); + public QuantityValue KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); + public QuantityValue MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); #endregion @@ -235,7 +236,7 @@ public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static MolarEntropy FromJoulesPerMoleKelvin(double value) + public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue value) { return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin); } @@ -243,7 +244,7 @@ public static MolarEntropy FromJoulesPerMoleKelvin(double value) /// /// Creates a from . /// - public static MolarEntropy FromKilojoulesPerMoleKelvin(double value) + public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue value) { return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin); } @@ -251,7 +252,7 @@ public static MolarEntropy FromKilojoulesPerMoleKelvin(double value) /// /// Creates a from . /// - public static MolarEntropy FromMegajoulesPerMoleKelvin(double value) + public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue value) { return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin); } @@ -262,7 +263,7 @@ public static MolarEntropy FromMegajoulesPerMoleKelvin(double value) /// Value to convert from. /// Unit to convert from. /// MolarEntropy unit value. - public static MolarEntropy From(double value, MolarEntropyUnit fromUnit) + public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit) { return new MolarEntropy(value, fromUnit); } @@ -434,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEntropy operator *(double left, MolarEntropy right) + public static MolarEntropy operator *(QuantityValue left, MolarEntropy right) { return new MolarEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEntropy operator *(MolarEntropy left, double right) + public static MolarEntropy operator *(MolarEntropy left, QuantityValue right) { return new MolarEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEntropy operator /(MolarEntropy left, double right) + public static MolarEntropy operator /(MolarEntropy left, QuantityValue right) { return new MolarEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarEntropy left, MolarEntropy right) + public static QuantityValue operator /(MolarEntropy left, MolarEntropy right) { return left.JoulesPerMoleKelvin / right.JoulesPerMoleKelvin; } @@ -485,27 +486,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MolarEntropy left, MolarEntropy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarEntropy other, MolarEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MolarEntropy left, MolarEntropy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MolarEntropy otherQuantity)) @@ -515,15 +509,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MolarEntropy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -606,10 +597,10 @@ public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -626,7 +617,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarEntropy other, MolarEntropy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -639,7 +630,12 @@ public bool Equals(MolarEntropy other, MolarEntropy tolerance) /// A hash code for the current MolarEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -650,7 +646,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEntropyUnit unit) + public QuantityValue As(MolarEntropyUnit unit) { if (Unit == unit) return Value; @@ -659,7 +655,7 @@ public double As(MolarEntropyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,7 +670,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); @@ -740,12 +736,12 @@ private bool TryToUnit(MolarEntropyUnit unit, [NotNullWhen(true)] out MolarEntro MolarEntropy? convertedOrNull = (Unit, unit) switch { // MolarEntropyUnit -> BaseUnit - (MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropyUnit.JoulePerMoleKelvin) => new MolarEntropy((_value) * 1e3d, MolarEntropyUnit.JoulePerMoleKelvin), - (MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropyUnit.JoulePerMoleKelvin) => new MolarEntropy((_value) * 1e6d, MolarEntropyUnit.JoulePerMoleKelvin), + (MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropyUnit.JoulePerMoleKelvin) => new MolarEntropy(_value * 1000, MolarEntropyUnit.JoulePerMoleKelvin), + (MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropyUnit.JoulePerMoleKelvin) => new MolarEntropy(_value * 1000000, MolarEntropyUnit.JoulePerMoleKelvin), // BaseUnit -> MolarEntropyUnit - (MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.KilojoulePerMoleKelvin) => new MolarEntropy((_value) / 1e3d, MolarEntropyUnit.KilojoulePerMoleKelvin), - (MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.MegajoulePerMoleKelvin) => new MolarEntropy((_value) / 1e6d, MolarEntropyUnit.MegajoulePerMoleKelvin), + (MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.KilojoulePerMoleKelvin) => new MolarEntropy(_value / 1000, MolarEntropyUnit.KilojoulePerMoleKelvin), + (MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.MegajoulePerMoleKelvin) => new MolarEntropy(_value / 1000000, MolarEntropyUnit.MegajoulePerMoleKelvin), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs index 0ee93f35f4..f9a1cfaeb4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarFlow.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -57,7 +55,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -95,7 +93,7 @@ static MolarFlow() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MolarFlow(double value, MolarFlowUnit unit) + public MolarFlow(QuantityValue value, MolarFlowUnit unit) { _value = value; _unit = unit; @@ -109,7 +107,7 @@ public MolarFlow(double value, MolarFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarFlow(double value, UnitSystem unitSystem) + public MolarFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -160,10 +158,10 @@ public MolarFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,47 +186,47 @@ public MolarFlow(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilomolesPerHour => As(MolarFlowUnit.KilomolePerHour); + public QuantityValue KilomolesPerHour => As(MolarFlowUnit.KilomolePerHour); /// /// Gets a value of this quantity converted into /// - public double KilomolesPerMinute => As(MolarFlowUnit.KilomolePerMinute); + public QuantityValue KilomolesPerMinute => As(MolarFlowUnit.KilomolePerMinute); /// /// Gets a value of this quantity converted into /// - public double KilomolesPerSecond => As(MolarFlowUnit.KilomolePerSecond); + public QuantityValue KilomolesPerSecond => As(MolarFlowUnit.KilomolePerSecond); /// /// Gets a value of this quantity converted into /// - public double MolesPerHour => As(MolarFlowUnit.MolePerHour); + public QuantityValue MolesPerHour => As(MolarFlowUnit.MolePerHour); /// /// Gets a value of this quantity converted into /// - public double MolesPerMinute => As(MolarFlowUnit.MolePerMinute); + public QuantityValue MolesPerMinute => As(MolarFlowUnit.MolePerMinute); /// /// Gets a value of this quantity converted into /// - public double MolesPerSecond => As(MolarFlowUnit.MolePerSecond); + public QuantityValue MolesPerSecond => As(MolarFlowUnit.MolePerSecond); /// /// Gets a value of this quantity converted into /// - public double PoundMolesPerHour => As(MolarFlowUnit.PoundMolePerHour); + public QuantityValue PoundMolesPerHour => As(MolarFlowUnit.PoundMolePerHour); /// /// Gets a value of this quantity converted into /// - public double PoundMolesPerMinute => As(MolarFlowUnit.PoundMolePerMinute); + public QuantityValue PoundMolesPerMinute => As(MolarFlowUnit.PoundMolePerMinute); /// /// Gets a value of this quantity converted into /// - public double PoundMolesPerSecond => As(MolarFlowUnit.PoundMolePerSecond); + public QuantityValue PoundMolesPerSecond => As(MolarFlowUnit.PoundMolePerSecond); #endregion @@ -292,7 +290,7 @@ public static string GetAbbreviation(MolarFlowUnit unit, IFormatProvider? provid /// /// Creates a from . /// - public static MolarFlow FromKilomolesPerHour(double value) + public static MolarFlow FromKilomolesPerHour(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.KilomolePerHour); } @@ -300,7 +298,7 @@ public static MolarFlow FromKilomolesPerHour(double value) /// /// Creates a from . /// - public static MolarFlow FromKilomolesPerMinute(double value) + public static MolarFlow FromKilomolesPerMinute(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.KilomolePerMinute); } @@ -308,7 +306,7 @@ public static MolarFlow FromKilomolesPerMinute(double value) /// /// Creates a from . /// - public static MolarFlow FromKilomolesPerSecond(double value) + public static MolarFlow FromKilomolesPerSecond(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.KilomolePerSecond); } @@ -316,7 +314,7 @@ public static MolarFlow FromKilomolesPerSecond(double value) /// /// Creates a from . /// - public static MolarFlow FromMolesPerHour(double value) + public static MolarFlow FromMolesPerHour(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.MolePerHour); } @@ -324,7 +322,7 @@ public static MolarFlow FromMolesPerHour(double value) /// /// Creates a from . /// - public static MolarFlow FromMolesPerMinute(double value) + public static MolarFlow FromMolesPerMinute(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.MolePerMinute); } @@ -332,7 +330,7 @@ public static MolarFlow FromMolesPerMinute(double value) /// /// Creates a from . /// - public static MolarFlow FromMolesPerSecond(double value) + public static MolarFlow FromMolesPerSecond(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.MolePerSecond); } @@ -340,7 +338,7 @@ public static MolarFlow FromMolesPerSecond(double value) /// /// Creates a from . /// - public static MolarFlow FromPoundMolesPerHour(double value) + public static MolarFlow FromPoundMolesPerHour(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.PoundMolePerHour); } @@ -348,7 +346,7 @@ public static MolarFlow FromPoundMolesPerHour(double value) /// /// Creates a from . /// - public static MolarFlow FromPoundMolesPerMinute(double value) + public static MolarFlow FromPoundMolesPerMinute(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.PoundMolePerMinute); } @@ -356,7 +354,7 @@ public static MolarFlow FromPoundMolesPerMinute(double value) /// /// Creates a from . /// - public static MolarFlow FromPoundMolesPerSecond(double value) + public static MolarFlow FromPoundMolesPerSecond(QuantityValue value) { return new MolarFlow(value, MolarFlowUnit.PoundMolePerSecond); } @@ -367,7 +365,7 @@ public static MolarFlow FromPoundMolesPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// MolarFlow unit value. - public static MolarFlow From(double value, MolarFlowUnit fromUnit) + public static MolarFlow From(QuantityValue value, MolarFlowUnit fromUnit) { return new MolarFlow(value, fromUnit); } @@ -539,25 +537,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarFlow operator *(double left, MolarFlow right) + public static MolarFlow operator *(QuantityValue left, MolarFlow right) { return new MolarFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarFlow operator *(MolarFlow left, double right) + public static MolarFlow operator *(MolarFlow left, QuantityValue right) { return new MolarFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarFlow operator /(MolarFlow left, double right) + public static MolarFlow operator /(MolarFlow left, QuantityValue right) { return new MolarFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarFlow left, MolarFlow right) + public static QuantityValue operator /(MolarFlow left, MolarFlow right) { return left.MolesPerSecond / right.MolesPerSecond; } @@ -618,27 +616,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MolarFlow left, MolarFlow right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarFlow other, MolarFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MolarFlow left, MolarFlow right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MolarFlow otherQuantity)) @@ -648,15 +639,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MolarFlow other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -739,10 +727,10 @@ public bool Equals(MolarFlow other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -759,7 +747,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarFlow other, MolarFlow tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -772,7 +760,12 @@ public bool Equals(MolarFlow other, MolarFlow tolerance) /// A hash code for the current MolarFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -783,7 +776,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarFlowUnit unit) + public QuantityValue As(MolarFlowUnit unit) { if (Unit == unit) return Value; @@ -792,7 +785,7 @@ public double As(MolarFlowUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -807,7 +800,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolarFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarFlowUnit)} is supported.", nameof(unit)); @@ -873,24 +866,24 @@ private bool TryToUnit(MolarFlowUnit unit, [NotNullWhen(true)] out MolarFlow? co MolarFlow? convertedOrNull = (Unit, unit) switch { // MolarFlowUnit -> BaseUnit - (MolarFlowUnit.KilomolePerHour, MolarFlowUnit.MolePerSecond) => new MolarFlow((_value / 3600) * 1e3d, MolarFlowUnit.MolePerSecond), - (MolarFlowUnit.KilomolePerMinute, MolarFlowUnit.MolePerSecond) => new MolarFlow((_value / 60) * 1e3d, MolarFlowUnit.MolePerSecond), - (MolarFlowUnit.KilomolePerSecond, MolarFlowUnit.MolePerSecond) => new MolarFlow((_value) * 1e3d, MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.KilomolePerHour, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * new QuantityValue(5, 18, false), MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.KilomolePerMinute, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * new QuantityValue(50, 3, false), MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.KilomolePerSecond, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * 1000, MolarFlowUnit.MolePerSecond), (MolarFlowUnit.MolePerHour, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value / 3600, MolarFlowUnit.MolePerSecond), (MolarFlowUnit.MolePerMinute, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value / 60, MolarFlowUnit.MolePerSecond), - (MolarFlowUnit.PoundMolePerHour, MolarFlowUnit.MolePerSecond) => new MolarFlow((_value * 453.59237) / 3600, MolarFlowUnit.MolePerSecond), - (MolarFlowUnit.PoundMolePerMinute, MolarFlowUnit.MolePerSecond) => new MolarFlow((_value * 453.59237) / 60, MolarFlowUnit.MolePerSecond), - (MolarFlowUnit.PoundMolePerSecond, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * 453.59237, MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.PoundMolePerHour, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * new QuantityValue(45359237, 360000000, false), MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.PoundMolePerMinute, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * new QuantityValue(45359237, 6000000, false), MolarFlowUnit.MolePerSecond), + (MolarFlowUnit.PoundMolePerSecond, MolarFlowUnit.MolePerSecond) => new MolarFlow(_value * new QuantityValue(45359237, 100000, false), MolarFlowUnit.MolePerSecond), // BaseUnit -> MolarFlowUnit - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerHour) => new MolarFlow((_value * 3600) / 1e3d, MolarFlowUnit.KilomolePerHour), - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerMinute) => new MolarFlow((_value * 60) / 1e3d, MolarFlowUnit.KilomolePerMinute), - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerSecond) => new MolarFlow((_value) / 1e3d, MolarFlowUnit.KilomolePerSecond), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerHour) => new MolarFlow(_value * new QuantityValue(18, 5, false), MolarFlowUnit.KilomolePerHour), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerMinute) => new MolarFlow(_value * new QuantityValue(3, 50, false), MolarFlowUnit.KilomolePerMinute), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.KilomolePerSecond) => new MolarFlow(_value / 1000, MolarFlowUnit.KilomolePerSecond), (MolarFlowUnit.MolePerSecond, MolarFlowUnit.MolePerHour) => new MolarFlow(_value * 3600, MolarFlowUnit.MolePerHour), (MolarFlowUnit.MolePerSecond, MolarFlowUnit.MolePerMinute) => new MolarFlow(_value * 60, MolarFlowUnit.MolePerMinute), - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerHour) => new MolarFlow((_value / 453.59237) * 3600, MolarFlowUnit.PoundMolePerHour), - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerMinute) => new MolarFlow((_value / 453.59237) * 60, MolarFlowUnit.PoundMolePerMinute), - (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerSecond) => new MolarFlow(_value / 453.59237, MolarFlowUnit.PoundMolePerSecond), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerHour) => new MolarFlow(_value * new QuantityValue(360000000, 45359237, false), MolarFlowUnit.PoundMolePerHour), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerMinute) => new MolarFlow(_value * new QuantityValue(6000000, 45359237, false), MolarFlowUnit.PoundMolePerMinute), + (MolarFlowUnit.MolePerSecond, MolarFlowUnit.PoundMolePerSecond) => new MolarFlow(_value * new QuantityValue(100000, 45359237, false), MolarFlowUnit.PoundMolePerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 37114c0762..6e2e01e14d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -56,7 +54,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,7 +96,7 @@ static MolarMass() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public MolarMass(double value, MolarMassUnit unit) + public MolarMass(QuantityValue value, MolarMassUnit unit) { _value = value; _unit = unit; @@ -112,7 +110,7 @@ public MolarMass(double value, MolarMassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarMass(double value, UnitSystem unitSystem) + public MolarMass(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -163,10 +161,10 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,67 +189,67 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); + public QuantityValue CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); /// /// Gets a value of this quantity converted into /// - public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); + public QuantityValue DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); /// /// Gets a value of this quantity converted into /// - public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); + public QuantityValue DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); /// /// Gets a value of this quantity converted into /// - public double GramsPerMole => As(MolarMassUnit.GramPerMole); + public QuantityValue GramsPerMole => As(MolarMassUnit.GramPerMole); /// /// Gets a value of this quantity converted into /// - public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); + public QuantityValue HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerKilomole => As(MolarMassUnit.KilogramPerKilomole); + public QuantityValue KilogramsPerKilomole => As(MolarMassUnit.KilogramPerKilomole); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); + public QuantityValue KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); /// /// Gets a value of this quantity converted into /// - public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); + public QuantityValue KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); /// /// Gets a value of this quantity converted into /// - public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); + public QuantityValue MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); /// /// Gets a value of this quantity converted into /// - public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); + public QuantityValue MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); /// /// Gets a value of this quantity converted into /// - public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); + public QuantityValue MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); /// /// Gets a value of this quantity converted into /// - public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); + public QuantityValue NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); /// /// Gets a value of this quantity converted into /// - public double PoundsPerMole => As(MolarMassUnit.PoundPerMole); + public QuantityValue PoundsPerMole => As(MolarMassUnit.PoundPerMole); #endregion @@ -323,7 +321,7 @@ public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provid /// /// Creates a from . /// - public static MolarMass FromCentigramsPerMole(double value) + public static MolarMass FromCentigramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.CentigramPerMole); } @@ -331,7 +329,7 @@ public static MolarMass FromCentigramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromDecagramsPerMole(double value) + public static MolarMass FromDecagramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.DecagramPerMole); } @@ -339,7 +337,7 @@ public static MolarMass FromDecagramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromDecigramsPerMole(double value) + public static MolarMass FromDecigramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.DecigramPerMole); } @@ -347,7 +345,7 @@ public static MolarMass FromDecigramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromGramsPerMole(double value) + public static MolarMass FromGramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.GramPerMole); } @@ -355,7 +353,7 @@ public static MolarMass FromGramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromHectogramsPerMole(double value) + public static MolarMass FromHectogramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.HectogramPerMole); } @@ -363,7 +361,7 @@ public static MolarMass FromHectogramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromKilogramsPerKilomole(double value) + public static MolarMass FromKilogramsPerKilomole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.KilogramPerKilomole); } @@ -371,7 +369,7 @@ public static MolarMass FromKilogramsPerKilomole(double value) /// /// Creates a from . /// - public static MolarMass FromKilogramsPerMole(double value) + public static MolarMass FromKilogramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.KilogramPerMole); } @@ -379,7 +377,7 @@ public static MolarMass FromKilogramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromKilopoundsPerMole(double value) + public static MolarMass FromKilopoundsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.KilopoundPerMole); } @@ -387,7 +385,7 @@ public static MolarMass FromKilopoundsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromMegapoundsPerMole(double value) + public static MolarMass FromMegapoundsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.MegapoundPerMole); } @@ -395,7 +393,7 @@ public static MolarMass FromMegapoundsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromMicrogramsPerMole(double value) + public static MolarMass FromMicrogramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.MicrogramPerMole); } @@ -403,7 +401,7 @@ public static MolarMass FromMicrogramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromMilligramsPerMole(double value) + public static MolarMass FromMilligramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.MilligramPerMole); } @@ -411,7 +409,7 @@ public static MolarMass FromMilligramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromNanogramsPerMole(double value) + public static MolarMass FromNanogramsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.NanogramPerMole); } @@ -419,7 +417,7 @@ public static MolarMass FromNanogramsPerMole(double value) /// /// Creates a from . /// - public static MolarMass FromPoundsPerMole(double value) + public static MolarMass FromPoundsPerMole(QuantityValue value) { return new MolarMass(value, MolarMassUnit.PoundPerMole); } @@ -430,7 +428,7 @@ public static MolarMass FromPoundsPerMole(double value) /// Value to convert from. /// Unit to convert from. /// MolarMass unit value. - public static MolarMass From(double value, MolarMassUnit fromUnit) + public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit) { return new MolarMass(value, fromUnit); } @@ -602,25 +600,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarMass operator *(double left, MolarMass right) + public static MolarMass operator *(QuantityValue left, MolarMass right) { return new MolarMass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarMass operator *(MolarMass left, double right) + public static MolarMass operator *(MolarMass left, QuantityValue right) { return new MolarMass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarMass operator /(MolarMass left, double right) + public static MolarMass operator /(MolarMass left, QuantityValue right) { return new MolarMass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarMass left, MolarMass right) + public static QuantityValue operator /(MolarMass left, MolarMass right) { return left.KilogramsPerMole / right.KilogramsPerMole; } @@ -675,27 +673,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(MolarMass left, MolarMass right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(MolarMass other, MolarMass tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(MolarMass left, MolarMass right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is MolarMass otherQuantity)) @@ -705,15 +696,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(MolarMass other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +784,10 @@ public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -816,7 +804,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(MolarMass other, MolarMass tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -829,7 +817,12 @@ public bool Equals(MolarMass other, MolarMass tolerance) /// A hash code for the current MolarMass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -840,7 +833,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarMassUnit unit) + public QuantityValue As(MolarMassUnit unit) { if (Unit == unit) return Value; @@ -849,7 +842,7 @@ public double As(MolarMassUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -864,7 +857,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); @@ -930,32 +923,32 @@ private bool TryToUnit(MolarMassUnit unit, [NotNullWhen(true)] out MolarMass? co MolarMass? convertedOrNull = (Unit, unit) switch { // MolarMassUnit -> BaseUnit - (MolarMassUnit.CentigramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e-2d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.DecagramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e1d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.DecigramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e-1d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.GramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1e3, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.HectogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e2d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.KilogramPerKilomole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1e3, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.KilopoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value * 0.45359237) * 1e3d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.MegapoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value * 0.45359237) * 1e6d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.MicrogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e-6d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.MilligramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e-3d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.NanogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass((_value / 1e3) * 1e-9d, MolarMassUnit.KilogramPerMole), - (MolarMassUnit.PoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value * 0.45359237, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.CentigramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 100000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.DecagramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 100, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.DecigramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 10000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.GramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.HectogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 10, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.KilogramPerKilomole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.KilopoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value * new QuantityValue(45359237, 100000, false), MolarMassUnit.KilogramPerMole), + (MolarMassUnit.MegapoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value * new QuantityValue(45359237, 100, false), MolarMassUnit.KilogramPerMole), + (MolarMassUnit.MicrogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1000000000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.MilligramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1000000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.NanogramPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value / 1000000000000, MolarMassUnit.KilogramPerMole), + (MolarMassUnit.PoundPerMole, MolarMassUnit.KilogramPerMole) => new MolarMass(_value * new QuantityValue(45359237, 100000000, false), MolarMassUnit.KilogramPerMole), // BaseUnit -> MolarMassUnit - (MolarMassUnit.KilogramPerMole, MolarMassUnit.CentigramPerMole) => new MolarMass((_value * 1e3) / 1e-2d, MolarMassUnit.CentigramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.DecagramPerMole) => new MolarMass((_value * 1e3) / 1e1d, MolarMassUnit.DecagramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.DecigramPerMole) => new MolarMass((_value * 1e3) / 1e-1d, MolarMassUnit.DecigramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.GramPerMole) => new MolarMass(_value * 1e3, MolarMassUnit.GramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.HectogramPerMole) => new MolarMass((_value * 1e3) / 1e2d, MolarMassUnit.HectogramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.KilogramPerKilomole) => new MolarMass(_value * 1e3, MolarMassUnit.KilogramPerKilomole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.KilopoundPerMole) => new MolarMass((_value / 0.45359237) / 1e3d, MolarMassUnit.KilopoundPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.MegapoundPerMole) => new MolarMass((_value / 0.45359237) / 1e6d, MolarMassUnit.MegapoundPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.MicrogramPerMole) => new MolarMass((_value * 1e3) / 1e-6d, MolarMassUnit.MicrogramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.MilligramPerMole) => new MolarMass((_value * 1e3) / 1e-3d, MolarMassUnit.MilligramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.NanogramPerMole) => new MolarMass((_value * 1e3) / 1e-9d, MolarMassUnit.NanogramPerMole), - (MolarMassUnit.KilogramPerMole, MolarMassUnit.PoundPerMole) => new MolarMass(_value / 0.45359237, MolarMassUnit.PoundPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.CentigramPerMole) => new MolarMass(_value * 100000, MolarMassUnit.CentigramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.DecagramPerMole) => new MolarMass(_value * 100, MolarMassUnit.DecagramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.DecigramPerMole) => new MolarMass(_value * 10000, MolarMassUnit.DecigramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.GramPerMole) => new MolarMass(_value * 1000, MolarMassUnit.GramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.HectogramPerMole) => new MolarMass(_value * 10, MolarMassUnit.HectogramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.KilogramPerKilomole) => new MolarMass(_value * 1000, MolarMassUnit.KilogramPerKilomole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.KilopoundPerMole) => new MolarMass(_value * new QuantityValue(100000, 45359237, false), MolarMassUnit.KilopoundPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.MegapoundPerMole) => new MolarMass(_value * new QuantityValue(100, 45359237, false), MolarMassUnit.MegapoundPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.MicrogramPerMole) => new MolarMass(_value * 1000000000, MolarMassUnit.MicrogramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.MilligramPerMole) => new MolarMass(_value * 1000000, MolarMassUnit.MilligramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.NanogramPerMole) => new MolarMass(_value * 1000000000000, MolarMassUnit.NanogramPerMole), + (MolarMassUnit.KilogramPerMole, MolarMassUnit.PoundPerMole) => new MolarMass(_value * new QuantityValue(100000000, 45359237, false), MolarMassUnit.PoundPerMole), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index edc4201ad7..d916b4921d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -61,7 +59,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -101,7 +99,7 @@ static Molarity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Molarity(double value, MolarityUnit unit) + public Molarity(QuantityValue value, MolarityUnit unit) { _value = value; _unit = unit; @@ -115,7 +113,7 @@ public Molarity(double value, MolarityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Molarity(double value, UnitSystem unitSystem) + public Molarity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -166,10 +164,10 @@ public Molarity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,57 +192,57 @@ public Molarity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); + public QuantityValue CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); /// /// Gets a value of this quantity converted into /// - public double DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); + public QuantityValue DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); /// /// Gets a value of this quantity converted into /// - public double FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); + public QuantityValue FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); /// /// Gets a value of this quantity converted into /// - public double KilomolesPerCubicMeter => As(MolarityUnit.KilomolePerCubicMeter); + public QuantityValue KilomolesPerCubicMeter => As(MolarityUnit.KilomolePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); + public QuantityValue MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); /// /// Gets a value of this quantity converted into /// - public double MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); + public QuantityValue MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); /// /// Gets a value of this quantity converted into /// - public double MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); + public QuantityValue MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MolesPerLiter => As(MolarityUnit.MolePerLiter); + public QuantityValue MolesPerLiter => As(MolarityUnit.MolePerLiter); /// /// Gets a value of this quantity converted into /// - public double NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); + public QuantityValue NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); /// /// Gets a value of this quantity converted into /// - public double PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); + public QuantityValue PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); /// /// Gets a value of this quantity converted into /// - public double PoundMolesPerCubicFoot => As(MolarityUnit.PoundMolePerCubicFoot); + public QuantityValue PoundMolesPerCubicFoot => As(MolarityUnit.PoundMolePerCubicFoot); #endregion @@ -312,7 +310,7 @@ public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static Molarity FromCentimolesPerLiter(double value) + public static Molarity FromCentimolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.CentimolePerLiter); } @@ -320,7 +318,7 @@ public static Molarity FromCentimolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromDecimolesPerLiter(double value) + public static Molarity FromDecimolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.DecimolePerLiter); } @@ -328,7 +326,7 @@ public static Molarity FromDecimolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromFemtomolesPerLiter(double value) + public static Molarity FromFemtomolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.FemtomolePerLiter); } @@ -336,7 +334,7 @@ public static Molarity FromFemtomolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromKilomolesPerCubicMeter(double value) + public static Molarity FromKilomolesPerCubicMeter(QuantityValue value) { return new Molarity(value, MolarityUnit.KilomolePerCubicMeter); } @@ -344,7 +342,7 @@ public static Molarity FromKilomolesPerCubicMeter(double value) /// /// Creates a from . /// - public static Molarity FromMicromolesPerLiter(double value) + public static Molarity FromMicromolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.MicromolePerLiter); } @@ -352,7 +350,7 @@ public static Molarity FromMicromolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromMillimolesPerLiter(double value) + public static Molarity FromMillimolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.MillimolePerLiter); } @@ -360,7 +358,7 @@ public static Molarity FromMillimolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromMolesPerCubicMeter(double value) + public static Molarity FromMolesPerCubicMeter(QuantityValue value) { return new Molarity(value, MolarityUnit.MolePerCubicMeter); } @@ -368,7 +366,7 @@ public static Molarity FromMolesPerCubicMeter(double value) /// /// Creates a from . /// - public static Molarity FromMolesPerLiter(double value) + public static Molarity FromMolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.MolePerLiter); } @@ -376,7 +374,7 @@ public static Molarity FromMolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromNanomolesPerLiter(double value) + public static Molarity FromNanomolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.NanomolePerLiter); } @@ -384,7 +382,7 @@ public static Molarity FromNanomolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromPicomolesPerLiter(double value) + public static Molarity FromPicomolesPerLiter(QuantityValue value) { return new Molarity(value, MolarityUnit.PicomolePerLiter); } @@ -392,7 +390,7 @@ public static Molarity FromPicomolesPerLiter(double value) /// /// Creates a from . /// - public static Molarity FromPoundMolesPerCubicFoot(double value) + public static Molarity FromPoundMolesPerCubicFoot(QuantityValue value) { return new Molarity(value, MolarityUnit.PoundMolePerCubicFoot); } @@ -403,7 +401,7 @@ public static Molarity FromPoundMolesPerCubicFoot(double value) /// Value to convert from. /// Unit to convert from. /// Molarity unit value. - public static Molarity From(double value, MolarityUnit fromUnit) + public static Molarity From(QuantityValue value, MolarityUnit fromUnit) { return new Molarity(value, fromUnit); } @@ -575,25 +573,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static Molarity operator *(double left, Molarity right) + public static Molarity operator *(QuantityValue left, Molarity right) { return new Molarity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Molarity operator *(Molarity left, double right) + public static Molarity operator *(Molarity left, QuantityValue right) { return new Molarity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Molarity operator /(Molarity left, double right) + public static Molarity operator /(Molarity left, QuantityValue right) { return new Molarity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Molarity left, Molarity right) + public static QuantityValue operator /(Molarity left, Molarity right) { return left.MolesPerCubicMeter / right.MolesPerCubicMeter; } @@ -660,27 +658,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Molarity left, Molarity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Molarity other, Molarity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Molarity left, Molarity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Molarity otherQuantity)) @@ -690,15 +681,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Molarity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -781,10 +769,10 @@ public bool Equals(Molarity other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -801,7 +789,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Molarity other, Molarity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -814,7 +802,12 @@ public bool Equals(Molarity other, Molarity tolerance) /// A hash code for the current Molarity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -825,7 +818,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarityUnit unit) + public QuantityValue As(MolarityUnit unit) { if (Unit == unit) return Value; @@ -834,7 +827,7 @@ public double As(MolarityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -849,7 +842,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); @@ -915,28 +908,28 @@ private bool TryToUnit(MolarityUnit unit, [NotNullWhen(true)] out Molarity? conv Molarity? convertedOrNull = (Unit, unit) switch { // MolarityUnit -> BaseUnit - (MolarityUnit.CentimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-2d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.DecimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-1d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.FemtomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-15d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.KilomolePerCubicMeter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value) * 1e3d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.MicromolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-6d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.MillimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-3d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.MolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 1e-3, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.NanomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-9d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.PicomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity((_value / 1e-3) * 1e-12d, MolarityUnit.MolePerCubicMeter), - (MolarityUnit.PoundMolePerCubicFoot, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 6.2427960576144611956325455827221e-5, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.CentimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value * 10, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.DecimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value * 100, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.FemtomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 1000000000000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.KilomolePerCubicMeter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value * 1000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.MicromolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 1000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.MillimolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.MolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value * 1000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.NanomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 1000000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.PicomolePerLiter, MolarityUnit.MolePerCubicMeter) => new Molarity(_value / 1000000000, MolarityUnit.MolePerCubicMeter), + (MolarityUnit.PoundMolePerCubicFoot, MolarityUnit.MolePerCubicMeter) => new Molarity(_value * new QuantityValue(1765733336000000000, 110231131092439, false), MolarityUnit.MolePerCubicMeter), // BaseUnit -> MolarityUnit - (MolarityUnit.MolePerCubicMeter, MolarityUnit.CentimolePerLiter) => new Molarity((_value * 1e-3) / 1e-2d, MolarityUnit.CentimolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.DecimolePerLiter) => new Molarity((_value * 1e-3) / 1e-1d, MolarityUnit.DecimolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.FemtomolePerLiter) => new Molarity((_value * 1e-3) / 1e-15d, MolarityUnit.FemtomolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.KilomolePerCubicMeter) => new Molarity((_value) / 1e3d, MolarityUnit.KilomolePerCubicMeter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.MicromolePerLiter) => new Molarity((_value * 1e-3) / 1e-6d, MolarityUnit.MicromolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.MillimolePerLiter) => new Molarity((_value * 1e-3) / 1e-3d, MolarityUnit.MillimolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.MolePerLiter) => new Molarity(_value * 1e-3, MolarityUnit.MolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.NanomolePerLiter) => new Molarity((_value * 1e-3) / 1e-9d, MolarityUnit.NanomolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.PicomolePerLiter) => new Molarity((_value * 1e-3) / 1e-12d, MolarityUnit.PicomolePerLiter), - (MolarityUnit.MolePerCubicMeter, MolarityUnit.PoundMolePerCubicFoot) => new Molarity(_value * 6.2427960576144611956325455827221e-5, MolarityUnit.PoundMolePerCubicFoot), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.CentimolePerLiter) => new Molarity(_value / 10, MolarityUnit.CentimolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.DecimolePerLiter) => new Molarity(_value / 100, MolarityUnit.DecimolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.FemtomolePerLiter) => new Molarity(_value * 1000000000000, MolarityUnit.FemtomolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.KilomolePerCubicMeter) => new Molarity(_value / 1000, MolarityUnit.KilomolePerCubicMeter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.MicromolePerLiter) => new Molarity(_value * 1000, MolarityUnit.MicromolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.MillimolePerLiter) => new Molarity(_value, MolarityUnit.MillimolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.MolePerLiter) => new Molarity(_value / 1000, MolarityUnit.MolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.NanomolePerLiter) => new Molarity(_value * 1000000, MolarityUnit.NanomolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.PicomolePerLiter) => new Molarity(_value * 1000000000, MolarityUnit.PicomolePerLiter), + (MolarityUnit.MolePerCubicMeter, MolarityUnit.PoundMolePerCubicFoot) => new Molarity(_value * new QuantityValue(110231131092439, 1765733336000000000, false), MolarityUnit.PoundMolePerCubicFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 09d982f0f2..a4458e223a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static Permeability() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Permeability(double value, PermeabilityUnit unit) + public Permeability(QuantityValue value, PermeabilityUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public Permeability(double value, PermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permeability(double value, UnitSystem unitSystem) + public Permeability(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public Permeability(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public Permeability(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); + public QuantityValue HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static Permeability FromHenriesPerMeter(double value) + public static Permeability FromHenriesPerMeter(QuantityValue value) { return new Permeability(value, PermeabilityUnit.HenryPerMeter); } @@ -233,7 +234,7 @@ public static Permeability FromHenriesPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// Permeability unit value. - public static Permeability From(double value, PermeabilityUnit fromUnit) + public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit) { return new Permeability(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme } /// Get from multiplying value and . - public static Permeability operator *(double left, Permeability right) + public static Permeability operator *(QuantityValue left, Permeability right) { return new Permeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permeability operator *(Permeability left, double right) + public static Permeability operator *(Permeability left, QuantityValue right) { return new Permeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permeability operator /(Permeability left, double right) + public static Permeability operator /(Permeability left, QuantityValue right) { return new Permeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Permeability left, Permeability right) + public static QuantityValue operator /(Permeability left, Permeability right) { return left.HenriesPerMeter / right.HenriesPerMeter; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Permeability left, Permeability right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permeability other, Permeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Permeability left, Permeability right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Permeability otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Permeability other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(Permeability other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Permeability other, Permeability tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(Permeability other, Permeability tolerance) /// A hash code for the current Permeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermeabilityUnit unit) + public QuantityValue As(PermeabilityUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(PermeabilityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 845e869125..99f6805dec 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static Permittivity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Permittivity(double value, PermittivityUnit unit) + public Permittivity(QuantityValue value, PermittivityUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public Permittivity(double value, PermittivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permittivity(double value, UnitSystem unitSystem) + public Permittivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); + public QuantityValue FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static Permittivity FromFaradsPerMeter(double value) + public static Permittivity FromFaradsPerMeter(QuantityValue value) { return new Permittivity(value, PermittivityUnit.FaradPerMeter); } @@ -233,7 +234,7 @@ public static Permittivity FromFaradsPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// Permittivity unit value. - public static Permittivity From(double value, PermittivityUnit fromUnit) + public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit) { return new Permittivity(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi } /// Get from multiplying value and . - public static Permittivity operator *(double left, Permittivity right) + public static Permittivity operator *(QuantityValue left, Permittivity right) { return new Permittivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permittivity operator *(Permittivity left, double right) + public static Permittivity operator *(Permittivity left, QuantityValue right) { return new Permittivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permittivity operator /(Permittivity left, double right) + public static Permittivity operator /(Permittivity left, QuantityValue right) { return new Permittivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Permittivity left, Permittivity right) + public static QuantityValue operator /(Permittivity left, Permittivity right) { return left.FaradsPerMeter / right.FaradsPerMeter; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Permittivity left, Permittivity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Permittivity other, Permittivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Permittivity left, Permittivity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Permittivity otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Permittivity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(Permittivity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Permittivity other, Permittivity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(Permittivity other, Permittivity tolerance) /// A hash code for the current Permittivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermittivityUnit unit) + public QuantityValue As(PermittivityUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(PermittivityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index adcb4e7523..0b71caf348 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,7 +86,7 @@ static PorousMediumPermeability() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public PorousMediumPermeability(double value, PorousMediumPermeabilityUnit unit) + public PorousMediumPermeability(QuantityValue value, PorousMediumPermeabilityUnit unit) { _value = value; _unit = unit; @@ -99,7 +100,7 @@ public PorousMediumPermeability(double value, PorousMediumPermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PorousMediumPermeability(double value, UnitSystem unitSystem) + public PorousMediumPermeability(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -150,10 +151,10 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -178,27 +179,27 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Darcys => As(PorousMediumPermeabilityUnit.Darcy); + public QuantityValue Darcys => As(PorousMediumPermeabilityUnit.Darcy); /// /// Gets a value of this quantity converted into /// - public double Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); + public QuantityValue Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); /// /// Gets a value of this quantity converted into /// - public double Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); + public QuantityValue Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); /// /// Gets a value of this quantity converted into /// - public double SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); + public QuantityValue SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); + public QuantityValue SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); #endregion @@ -254,7 +255,7 @@ public static string GetAbbreviation(PorousMediumPermeabilityUnit unit, IFormatP /// /// Creates a from . /// - public static PorousMediumPermeability FromDarcys(double value) + public static PorousMediumPermeability FromDarcys(QuantityValue value) { return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Darcy); } @@ -262,7 +263,7 @@ public static PorousMediumPermeability FromDarcys(double value) /// /// Creates a from . /// - public static PorousMediumPermeability FromMicrodarcys(double value) + public static PorousMediumPermeability FromMicrodarcys(QuantityValue value) { return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Microdarcy); } @@ -270,7 +271,7 @@ public static PorousMediumPermeability FromMicrodarcys(double value) /// /// Creates a from . /// - public static PorousMediumPermeability FromMillidarcys(double value) + public static PorousMediumPermeability FromMillidarcys(QuantityValue value) { return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Millidarcy); } @@ -278,7 +279,7 @@ public static PorousMediumPermeability FromMillidarcys(double value) /// /// Creates a from . /// - public static PorousMediumPermeability FromSquareCentimeters(double value) + public static PorousMediumPermeability FromSquareCentimeters(QuantityValue value) { return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareCentimeter); } @@ -286,7 +287,7 @@ public static PorousMediumPermeability FromSquareCentimeters(double value) /// /// Creates a from . /// - public static PorousMediumPermeability FromSquareMeters(double value) + public static PorousMediumPermeability FromSquareMeters(QuantityValue value) { return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareMeter); } @@ -297,7 +298,7 @@ public static PorousMediumPermeability FromSquareMeters(double value) /// Value to convert from. /// Unit to convert from. /// PorousMediumPermeability unit value. - public static PorousMediumPermeability From(double value, PorousMediumPermeabilityUnit fromUnit) + public static PorousMediumPermeability From(QuantityValue value, PorousMediumPermeabilityUnit fromUnit) { return new PorousMediumPermeability(value, fromUnit); } @@ -469,25 +470,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(double left, PorousMediumPermeability right) + public static PorousMediumPermeability operator *(QuantityValue left, PorousMediumPermeability right) { return new PorousMediumPermeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(PorousMediumPermeability left, double right) + public static PorousMediumPermeability operator *(PorousMediumPermeability left, QuantityValue right) { return new PorousMediumPermeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PorousMediumPermeability operator /(PorousMediumPermeability left, double right) + public static PorousMediumPermeability operator /(PorousMediumPermeability left, QuantityValue right) { return new PorousMediumPermeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PorousMediumPermeability left, PorousMediumPermeability right) + public static QuantityValue operator /(PorousMediumPermeability left, PorousMediumPermeability right) { return left.SquareMeters / right.SquareMeters; } @@ -520,27 +521,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(PorousMediumPermeability left, PorousMediumPermeability right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(PorousMediumPermeability left, PorousMediumPermeability right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is PorousMediumPermeability otherQuantity)) @@ -550,15 +544,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(PorousMediumPermeability other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -641,10 +632,10 @@ public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -661,7 +652,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PorousMediumPermeability other, PorousMediumPermeability tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -674,7 +665,12 @@ public bool Equals(PorousMediumPermeability other, PorousMediumPermeability tole /// A hash code for the current PorousMediumPermeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -685,7 +681,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PorousMediumPermeabilityUnit unit) + public QuantityValue As(PorousMediumPermeabilityUnit unit) { if (Unit == unit) return Value; @@ -694,7 +690,7 @@ public double As(PorousMediumPermeabilityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -709,7 +705,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); @@ -775,16 +771,16 @@ private bool TryToUnit(PorousMediumPermeabilityUnit unit, [NotNullWhen(true)] ou PorousMediumPermeability? convertedOrNull = (Unit, unit) switch { // PorousMediumPermeabilityUnit -> BaseUnit - (PorousMediumPermeabilityUnit.Darcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value * 9.869233e-13, PorousMediumPermeabilityUnit.SquareMeter), - (PorousMediumPermeabilityUnit.Microdarcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability((_value * 9.869233e-13) * 1e-6d, PorousMediumPermeabilityUnit.SquareMeter), - (PorousMediumPermeabilityUnit.Millidarcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability((_value * 9.869233e-13) * 1e-3d, PorousMediumPermeabilityUnit.SquareMeter), - (PorousMediumPermeabilityUnit.SquareCentimeter, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value * 1e-4, PorousMediumPermeabilityUnit.SquareMeter), + (PorousMediumPermeabilityUnit.Darcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value * 9869233 / BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.SquareMeter), + (PorousMediumPermeabilityUnit.Microdarcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value * new QuantityValue(9869233, 1000000, false) / BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.SquareMeter), + (PorousMediumPermeabilityUnit.Millidarcy, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value * new QuantityValue(9869233, 1000, false) / BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.SquareMeter), + (PorousMediumPermeabilityUnit.SquareCentimeter, PorousMediumPermeabilityUnit.SquareMeter) => new PorousMediumPermeability(_value / 10000, PorousMediumPermeabilityUnit.SquareMeter), // BaseUnit -> PorousMediumPermeabilityUnit - (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Darcy) => new PorousMediumPermeability(_value / 9.869233e-13, PorousMediumPermeabilityUnit.Darcy), - (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Microdarcy) => new PorousMediumPermeability((_value / 9.869233e-13) / 1e-6d, PorousMediumPermeabilityUnit.Microdarcy), - (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Millidarcy) => new PorousMediumPermeability((_value / 9.869233e-13) / 1e-3d, PorousMediumPermeabilityUnit.Millidarcy), - (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.SquareCentimeter) => new PorousMediumPermeability(_value / 1e-4, PorousMediumPermeabilityUnit.SquareCentimeter), + (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Darcy) => new PorousMediumPermeability(_value / 9869233 * BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.Darcy), + (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Microdarcy) => new PorousMediumPermeability(_value * new QuantityValue(1000000, 9869233, false) * BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.Microdarcy), + (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.Millidarcy) => new PorousMediumPermeability(_value * new QuantityValue(1000, 9869233, false) * BigInteger.Pow(10, 19), PorousMediumPermeabilityUnit.Millidarcy), + (PorousMediumPermeabilityUnit.SquareMeter, PorousMediumPermeabilityUnit.SquareCentimeter) => new PorousMediumPermeability(_value * 10000, PorousMediumPermeabilityUnit.SquareCentimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 20edecda3d..c8532dc67c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -67,7 +65,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -122,7 +120,7 @@ static Power() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Power(double value, PowerUnit unit) + public Power(QuantityValue value, PowerUnit unit) { _value = value; _unit = unit; @@ -136,7 +134,7 @@ public Power(double value, PowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Power(double value, UnitSystem unitSystem) + public Power(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -187,10 +185,10 @@ public Power(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -215,132 +213,132 @@ public Power(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public QuantityValue BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// /// Gets a value of this quantity converted into /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public QuantityValue BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// /// Gets a value of this quantity converted into /// - public double Decawatts => As(PowerUnit.Decawatt); + public QuantityValue Decawatts => As(PowerUnit.Decawatt); /// /// Gets a value of this quantity converted into /// - public double Deciwatts => As(PowerUnit.Deciwatt); + public QuantityValue Deciwatts => As(PowerUnit.Deciwatt); /// /// Gets a value of this quantity converted into /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public QuantityValue ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// /// Gets a value of this quantity converted into /// - public double Femtowatts => As(PowerUnit.Femtowatt); + public QuantityValue Femtowatts => As(PowerUnit.Femtowatt); /// /// Gets a value of this quantity converted into /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public QuantityValue GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// /// Gets a value of this quantity converted into /// - public double Gigawatts => As(PowerUnit.Gigawatt); + public QuantityValue Gigawatts => As(PowerUnit.Gigawatt); /// /// Gets a value of this quantity converted into /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public QuantityValue HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// /// Gets a value of this quantity converted into /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); + public QuantityValue JoulesPerHour => As(PowerUnit.JoulePerHour); /// /// Gets a value of this quantity converted into /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public QuantityValue KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public QuantityValue KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// /// Gets a value of this quantity converted into /// - public double Kilowatts => As(PowerUnit.Kilowatt); + public QuantityValue Kilowatts => As(PowerUnit.Kilowatt); /// /// Gets a value of this quantity converted into /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public QuantityValue MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// /// Gets a value of this quantity converted into /// - public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); + public QuantityValue MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public QuantityValue MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// /// Gets a value of this quantity converted into /// - public double Megawatts => As(PowerUnit.Megawatt); + public QuantityValue Megawatts => As(PowerUnit.Megawatt); /// /// Gets a value of this quantity converted into /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); + public QuantityValue MetricHorsepower => As(PowerUnit.MetricHorsepower); /// /// Gets a value of this quantity converted into /// - public double Microwatts => As(PowerUnit.Microwatt); + public QuantityValue Microwatts => As(PowerUnit.Microwatt); /// /// Gets a value of this quantity converted into /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public QuantityValue MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// /// Gets a value of this quantity converted into /// - public double Milliwatts => As(PowerUnit.Milliwatt); + public QuantityValue Milliwatts => As(PowerUnit.Milliwatt); /// /// Gets a value of this quantity converted into /// - public double Nanowatts => As(PowerUnit.Nanowatt); + public QuantityValue Nanowatts => As(PowerUnit.Nanowatt); /// /// Gets a value of this quantity converted into /// - public double Petawatts => As(PowerUnit.Petawatt); + public QuantityValue Petawatts => As(PowerUnit.Petawatt); /// /// Gets a value of this quantity converted into /// - public double Picowatts => As(PowerUnit.Picowatt); + public QuantityValue Picowatts => As(PowerUnit.Picowatt); /// /// Gets a value of this quantity converted into /// - public double Terawatts => As(PowerUnit.Terawatt); + public QuantityValue Terawatts => As(PowerUnit.Terawatt); /// /// Gets a value of this quantity converted into /// - public double Watts => As(PowerUnit.Watt); + public QuantityValue Watts => As(PowerUnit.Watt); #endregion @@ -438,7 +436,7 @@ public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Power FromBoilerHorsepower(double value) + public static Power FromBoilerHorsepower(QuantityValue value) { return new Power(value, PowerUnit.BoilerHorsepower); } @@ -446,7 +444,7 @@ public static Power FromBoilerHorsepower(double value) /// /// Creates a from . /// - public static Power FromBritishThermalUnitsPerHour(double value) + public static Power FromBritishThermalUnitsPerHour(QuantityValue value) { return new Power(value, PowerUnit.BritishThermalUnitPerHour); } @@ -454,7 +452,7 @@ public static Power FromBritishThermalUnitsPerHour(double value) /// /// Creates a from . /// - public static Power FromDecawatts(double value) + public static Power FromDecawatts(QuantityValue value) { return new Power(value, PowerUnit.Decawatt); } @@ -462,7 +460,7 @@ public static Power FromDecawatts(double value) /// /// Creates a from . /// - public static Power FromDeciwatts(double value) + public static Power FromDeciwatts(QuantityValue value) { return new Power(value, PowerUnit.Deciwatt); } @@ -470,7 +468,7 @@ public static Power FromDeciwatts(double value) /// /// Creates a from . /// - public static Power FromElectricalHorsepower(double value) + public static Power FromElectricalHorsepower(QuantityValue value) { return new Power(value, PowerUnit.ElectricalHorsepower); } @@ -478,7 +476,7 @@ public static Power FromElectricalHorsepower(double value) /// /// Creates a from . /// - public static Power FromFemtowatts(double value) + public static Power FromFemtowatts(QuantityValue value) { return new Power(value, PowerUnit.Femtowatt); } @@ -486,7 +484,7 @@ public static Power FromFemtowatts(double value) /// /// Creates a from . /// - public static Power FromGigajoulesPerHour(double value) + public static Power FromGigajoulesPerHour(QuantityValue value) { return new Power(value, PowerUnit.GigajoulePerHour); } @@ -494,7 +492,7 @@ public static Power FromGigajoulesPerHour(double value) /// /// Creates a from . /// - public static Power FromGigawatts(double value) + public static Power FromGigawatts(QuantityValue value) { return new Power(value, PowerUnit.Gigawatt); } @@ -502,7 +500,7 @@ public static Power FromGigawatts(double value) /// /// Creates a from . /// - public static Power FromHydraulicHorsepower(double value) + public static Power FromHydraulicHorsepower(QuantityValue value) { return new Power(value, PowerUnit.HydraulicHorsepower); } @@ -510,7 +508,7 @@ public static Power FromHydraulicHorsepower(double value) /// /// Creates a from . /// - public static Power FromJoulesPerHour(double value) + public static Power FromJoulesPerHour(QuantityValue value) { return new Power(value, PowerUnit.JoulePerHour); } @@ -518,7 +516,7 @@ public static Power FromJoulesPerHour(double value) /// /// Creates a from . /// - public static Power FromKilobritishThermalUnitsPerHour(double value) + public static Power FromKilobritishThermalUnitsPerHour(QuantityValue value) { return new Power(value, PowerUnit.KilobritishThermalUnitPerHour); } @@ -526,7 +524,7 @@ public static Power FromKilobritishThermalUnitsPerHour(double value) /// /// Creates a from . /// - public static Power FromKilojoulesPerHour(double value) + public static Power FromKilojoulesPerHour(QuantityValue value) { return new Power(value, PowerUnit.KilojoulePerHour); } @@ -534,7 +532,7 @@ public static Power FromKilojoulesPerHour(double value) /// /// Creates a from . /// - public static Power FromKilowatts(double value) + public static Power FromKilowatts(QuantityValue value) { return new Power(value, PowerUnit.Kilowatt); } @@ -542,7 +540,7 @@ public static Power FromKilowatts(double value) /// /// Creates a from . /// - public static Power FromMechanicalHorsepower(double value) + public static Power FromMechanicalHorsepower(QuantityValue value) { return new Power(value, PowerUnit.MechanicalHorsepower); } @@ -550,7 +548,7 @@ public static Power FromMechanicalHorsepower(double value) /// /// Creates a from . /// - public static Power FromMegabritishThermalUnitsPerHour(double value) + public static Power FromMegabritishThermalUnitsPerHour(QuantityValue value) { return new Power(value, PowerUnit.MegabritishThermalUnitPerHour); } @@ -558,7 +556,7 @@ public static Power FromMegabritishThermalUnitsPerHour(double value) /// /// Creates a from . /// - public static Power FromMegajoulesPerHour(double value) + public static Power FromMegajoulesPerHour(QuantityValue value) { return new Power(value, PowerUnit.MegajoulePerHour); } @@ -566,7 +564,7 @@ public static Power FromMegajoulesPerHour(double value) /// /// Creates a from . /// - public static Power FromMegawatts(double value) + public static Power FromMegawatts(QuantityValue value) { return new Power(value, PowerUnit.Megawatt); } @@ -574,7 +572,7 @@ public static Power FromMegawatts(double value) /// /// Creates a from . /// - public static Power FromMetricHorsepower(double value) + public static Power FromMetricHorsepower(QuantityValue value) { return new Power(value, PowerUnit.MetricHorsepower); } @@ -582,7 +580,7 @@ public static Power FromMetricHorsepower(double value) /// /// Creates a from . /// - public static Power FromMicrowatts(double value) + public static Power FromMicrowatts(QuantityValue value) { return new Power(value, PowerUnit.Microwatt); } @@ -590,7 +588,7 @@ public static Power FromMicrowatts(double value) /// /// Creates a from . /// - public static Power FromMillijoulesPerHour(double value) + public static Power FromMillijoulesPerHour(QuantityValue value) { return new Power(value, PowerUnit.MillijoulePerHour); } @@ -598,7 +596,7 @@ public static Power FromMillijoulesPerHour(double value) /// /// Creates a from . /// - public static Power FromMilliwatts(double value) + public static Power FromMilliwatts(QuantityValue value) { return new Power(value, PowerUnit.Milliwatt); } @@ -606,7 +604,7 @@ public static Power FromMilliwatts(double value) /// /// Creates a from . /// - public static Power FromNanowatts(double value) + public static Power FromNanowatts(QuantityValue value) { return new Power(value, PowerUnit.Nanowatt); } @@ -614,7 +612,7 @@ public static Power FromNanowatts(double value) /// /// Creates a from . /// - public static Power FromPetawatts(double value) + public static Power FromPetawatts(QuantityValue value) { return new Power(value, PowerUnit.Petawatt); } @@ -622,7 +620,7 @@ public static Power FromPetawatts(double value) /// /// Creates a from . /// - public static Power FromPicowatts(double value) + public static Power FromPicowatts(QuantityValue value) { return new Power(value, PowerUnit.Picowatt); } @@ -630,7 +628,7 @@ public static Power FromPicowatts(double value) /// /// Creates a from . /// - public static Power FromTerawatts(double value) + public static Power FromTerawatts(QuantityValue value) { return new Power(value, PowerUnit.Terawatt); } @@ -638,7 +636,7 @@ public static Power FromTerawatts(double value) /// /// Creates a from . /// - public static Power FromWatts(double value) + public static Power FromWatts(QuantityValue value) { return new Power(value, PowerUnit.Watt); } @@ -649,7 +647,7 @@ public static Power FromWatts(double value) /// Value to convert from. /// Unit to convert from. /// Power unit value. - public static Power From(double value, PowerUnit fromUnit) + public static Power From(QuantityValue value, PowerUnit fromUnit) { return new Power(value, fromUnit); } @@ -821,25 +819,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static Power operator *(double left, Power right) + public static Power operator *(QuantityValue left, Power right) { return new Power(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Power operator *(Power left, double right) + public static Power operator *(Power left, QuantityValue right) { return new Power(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Power operator /(Power left, double right) + public static Power operator /(Power left, QuantityValue right) { return new Power(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Power left, Power right) + public static QuantityValue operator /(Power left, Power right) { return left.Watts / right.Watts; } @@ -960,27 +958,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Power left, Power right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Power left, Power right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Power otherQuantity)) @@ -990,15 +981,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Power other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1081,10 +1069,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1101,7 +1089,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Power other, Power tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1114,7 +1102,12 @@ public bool Equals(Power other, Power tolerance) /// A hash code for the current Power. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1125,7 +1118,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) + public QuantityValue As(PowerUnit unit) { if (Unit == unit) return Value; @@ -1134,7 +1127,7 @@ public double As(PowerUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1149,7 +1142,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); @@ -1215,58 +1208,58 @@ private bool TryToUnit(PowerUnit unit, [NotNullWhen(true)] out Power? converted) Power? convertedOrNull = (Unit, unit) switch { // PowerUnit -> BaseUnit - (PowerUnit.BoilerHorsepower, PowerUnit.Watt) => new Power(_value * 9812.5, PowerUnit.Watt), - (PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * 0.29307107017, PowerUnit.Watt), - (PowerUnit.Decawatt, PowerUnit.Watt) => new Power((_value) * 1e1d, PowerUnit.Watt), - (PowerUnit.Deciwatt, PowerUnit.Watt) => new Power((_value) * 1e-1d, PowerUnit.Watt), + (PowerUnit.BoilerHorsepower, PowerUnit.Watt) => new Power(_value * new QuantityValue(19625, 2, false), PowerUnit.Watt), + (PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(29307107017, 100000000000, false), PowerUnit.Watt), + (PowerUnit.Decawatt, PowerUnit.Watt) => new Power(_value * 10, PowerUnit.Watt), + (PowerUnit.Deciwatt, PowerUnit.Watt) => new Power(_value / 10, PowerUnit.Watt), (PowerUnit.ElectricalHorsepower, PowerUnit.Watt) => new Power(_value * 746, PowerUnit.Watt), - (PowerUnit.Femtowatt, PowerUnit.Watt) => new Power((_value) * 1e-15d, PowerUnit.Watt), - (PowerUnit.GigajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e9d, PowerUnit.Watt), - (PowerUnit.Gigawatt, PowerUnit.Watt) => new Power((_value) * 1e9d, PowerUnit.Watt), - (PowerUnit.HydraulicHorsepower, PowerUnit.Watt) => new Power(_value * 745.69988145, PowerUnit.Watt), + (PowerUnit.Femtowatt, PowerUnit.Watt) => new Power(_value / 1000000000000000, PowerUnit.Watt), + (PowerUnit.GigajoulePerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(2500000, 9, false), PowerUnit.Watt), + (PowerUnit.Gigawatt, PowerUnit.Watt) => new Power(_value * 1000000000, PowerUnit.Watt), + (PowerUnit.HydraulicHorsepower, PowerUnit.Watt) => new Power(_value * new QuantityValue(14913997629, 20000000, false), PowerUnit.Watt), (PowerUnit.JoulePerHour, PowerUnit.Watt) => new Power(_value / 3600, PowerUnit.Watt), - (PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017) * 1e3d, PowerUnit.Watt), - (PowerUnit.KilojoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e3d, PowerUnit.Watt), - (PowerUnit.Kilowatt, PowerUnit.Watt) => new Power((_value) * 1e3d, PowerUnit.Watt), - (PowerUnit.MechanicalHorsepower, PowerUnit.Watt) => new Power(_value * 745.69, PowerUnit.Watt), - (PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017) * 1e6d, PowerUnit.Watt), - (PowerUnit.MegajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e6d, PowerUnit.Watt), - (PowerUnit.Megawatt, PowerUnit.Watt) => new Power((_value) * 1e6d, PowerUnit.Watt), - (PowerUnit.MetricHorsepower, PowerUnit.Watt) => new Power(_value * 735.49875, PowerUnit.Watt), - (PowerUnit.Microwatt, PowerUnit.Watt) => new Power((_value) * 1e-6d, PowerUnit.Watt), - (PowerUnit.MillijoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e-3d, PowerUnit.Watt), - (PowerUnit.Milliwatt, PowerUnit.Watt) => new Power((_value) * 1e-3d, PowerUnit.Watt), - (PowerUnit.Nanowatt, PowerUnit.Watt) => new Power((_value) * 1e-9d, PowerUnit.Watt), - (PowerUnit.Petawatt, PowerUnit.Watt) => new Power((_value) * 1e15d, PowerUnit.Watt), - (PowerUnit.Picowatt, PowerUnit.Watt) => new Power((_value) * 1e-12d, PowerUnit.Watt), - (PowerUnit.Terawatt, PowerUnit.Watt) => new Power((_value) * 1e12d, PowerUnit.Watt), + (PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(29307107017, 100000000, false), PowerUnit.Watt), + (PowerUnit.KilojoulePerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(5, 18, false), PowerUnit.Watt), + (PowerUnit.Kilowatt, PowerUnit.Watt) => new Power(_value * 1000, PowerUnit.Watt), + (PowerUnit.MechanicalHorsepower, PowerUnit.Watt) => new Power(_value * new QuantityValue(74569, 100, false), PowerUnit.Watt), + (PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(29307107017, 100000, false), PowerUnit.Watt), + (PowerUnit.MegajoulePerHour, PowerUnit.Watt) => new Power(_value * new QuantityValue(2500, 9, false), PowerUnit.Watt), + (PowerUnit.Megawatt, PowerUnit.Watt) => new Power(_value * 1000000, PowerUnit.Watt), + (PowerUnit.MetricHorsepower, PowerUnit.Watt) => new Power(_value * new QuantityValue(588399, 800, false), PowerUnit.Watt), + (PowerUnit.Microwatt, PowerUnit.Watt) => new Power(_value / 1000000, PowerUnit.Watt), + (PowerUnit.MillijoulePerHour, PowerUnit.Watt) => new Power(_value / 3600000, PowerUnit.Watt), + (PowerUnit.Milliwatt, PowerUnit.Watt) => new Power(_value / 1000, PowerUnit.Watt), + (PowerUnit.Nanowatt, PowerUnit.Watt) => new Power(_value / 1000000000, PowerUnit.Watt), + (PowerUnit.Petawatt, PowerUnit.Watt) => new Power(_value * 1000000000000000, PowerUnit.Watt), + (PowerUnit.Picowatt, PowerUnit.Watt) => new Power(_value / 1000000000000, PowerUnit.Watt), + (PowerUnit.Terawatt, PowerUnit.Watt) => new Power(_value * 1000000000000, PowerUnit.Watt), // BaseUnit -> PowerUnit - (PowerUnit.Watt, PowerUnit.BoilerHorsepower) => new Power(_value / 9812.5, PowerUnit.BoilerHorsepower), - (PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour) => new Power(_value / 0.29307107017, PowerUnit.BritishThermalUnitPerHour), - (PowerUnit.Watt, PowerUnit.Decawatt) => new Power((_value) / 1e1d, PowerUnit.Decawatt), - (PowerUnit.Watt, PowerUnit.Deciwatt) => new Power((_value) / 1e-1d, PowerUnit.Deciwatt), + (PowerUnit.Watt, PowerUnit.BoilerHorsepower) => new Power(_value * new QuantityValue(2, 19625, false), PowerUnit.BoilerHorsepower), + (PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour) => new Power(_value * new QuantityValue(100000000000, 29307107017, false), PowerUnit.BritishThermalUnitPerHour), + (PowerUnit.Watt, PowerUnit.Decawatt) => new Power(_value / 10, PowerUnit.Decawatt), + (PowerUnit.Watt, PowerUnit.Deciwatt) => new Power(_value * 10, PowerUnit.Deciwatt), (PowerUnit.Watt, PowerUnit.ElectricalHorsepower) => new Power(_value / 746, PowerUnit.ElectricalHorsepower), - (PowerUnit.Watt, PowerUnit.Femtowatt) => new Power((_value) / 1e-15d, PowerUnit.Femtowatt), - (PowerUnit.Watt, PowerUnit.GigajoulePerHour) => new Power((_value * 3600) / 1e9d, PowerUnit.GigajoulePerHour), - (PowerUnit.Watt, PowerUnit.Gigawatt) => new Power((_value) / 1e9d, PowerUnit.Gigawatt), - (PowerUnit.Watt, PowerUnit.HydraulicHorsepower) => new Power(_value / 745.69988145, PowerUnit.HydraulicHorsepower), + (PowerUnit.Watt, PowerUnit.Femtowatt) => new Power(_value * 1000000000000000, PowerUnit.Femtowatt), + (PowerUnit.Watt, PowerUnit.GigajoulePerHour) => new Power(_value * new QuantityValue(9, 2500000, false), PowerUnit.GigajoulePerHour), + (PowerUnit.Watt, PowerUnit.Gigawatt) => new Power(_value / 1000000000, PowerUnit.Gigawatt), + (PowerUnit.Watt, PowerUnit.HydraulicHorsepower) => new Power(_value * new QuantityValue(20000000, 14913997629, false), PowerUnit.HydraulicHorsepower), (PowerUnit.Watt, PowerUnit.JoulePerHour) => new Power(_value * 3600, PowerUnit.JoulePerHour), - (PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour) => new Power((_value / 0.29307107017) / 1e3d, PowerUnit.KilobritishThermalUnitPerHour), - (PowerUnit.Watt, PowerUnit.KilojoulePerHour) => new Power((_value * 3600) / 1e3d, PowerUnit.KilojoulePerHour), - (PowerUnit.Watt, PowerUnit.Kilowatt) => new Power((_value) / 1e3d, PowerUnit.Kilowatt), - (PowerUnit.Watt, PowerUnit.MechanicalHorsepower) => new Power(_value / 745.69, PowerUnit.MechanicalHorsepower), - (PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour) => new Power((_value / 0.29307107017) / 1e6d, PowerUnit.MegabritishThermalUnitPerHour), - (PowerUnit.Watt, PowerUnit.MegajoulePerHour) => new Power((_value * 3600) / 1e6d, PowerUnit.MegajoulePerHour), - (PowerUnit.Watt, PowerUnit.Megawatt) => new Power((_value) / 1e6d, PowerUnit.Megawatt), - (PowerUnit.Watt, PowerUnit.MetricHorsepower) => new Power(_value / 735.49875, PowerUnit.MetricHorsepower), - (PowerUnit.Watt, PowerUnit.Microwatt) => new Power((_value) / 1e-6d, PowerUnit.Microwatt), - (PowerUnit.Watt, PowerUnit.MillijoulePerHour) => new Power((_value * 3600) / 1e-3d, PowerUnit.MillijoulePerHour), - (PowerUnit.Watt, PowerUnit.Milliwatt) => new Power((_value) / 1e-3d, PowerUnit.Milliwatt), - (PowerUnit.Watt, PowerUnit.Nanowatt) => new Power((_value) / 1e-9d, PowerUnit.Nanowatt), - (PowerUnit.Watt, PowerUnit.Petawatt) => new Power((_value) / 1e15d, PowerUnit.Petawatt), - (PowerUnit.Watt, PowerUnit.Picowatt) => new Power((_value) / 1e-12d, PowerUnit.Picowatt), - (PowerUnit.Watt, PowerUnit.Terawatt) => new Power((_value) / 1e12d, PowerUnit.Terawatt), + (PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour) => new Power(_value * new QuantityValue(100000000, 29307107017, false), PowerUnit.KilobritishThermalUnitPerHour), + (PowerUnit.Watt, PowerUnit.KilojoulePerHour) => new Power(_value * new QuantityValue(18, 5, false), PowerUnit.KilojoulePerHour), + (PowerUnit.Watt, PowerUnit.Kilowatt) => new Power(_value / 1000, PowerUnit.Kilowatt), + (PowerUnit.Watt, PowerUnit.MechanicalHorsepower) => new Power(_value * new QuantityValue(100, 74569, false), PowerUnit.MechanicalHorsepower), + (PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour) => new Power(_value * new QuantityValue(100000, 29307107017, false), PowerUnit.MegabritishThermalUnitPerHour), + (PowerUnit.Watt, PowerUnit.MegajoulePerHour) => new Power(_value * new QuantityValue(9, 2500, false), PowerUnit.MegajoulePerHour), + (PowerUnit.Watt, PowerUnit.Megawatt) => new Power(_value / 1000000, PowerUnit.Megawatt), + (PowerUnit.Watt, PowerUnit.MetricHorsepower) => new Power(_value * new QuantityValue(800, 588399, false), PowerUnit.MetricHorsepower), + (PowerUnit.Watt, PowerUnit.Microwatt) => new Power(_value * 1000000, PowerUnit.Microwatt), + (PowerUnit.Watt, PowerUnit.MillijoulePerHour) => new Power(_value * 3600000, PowerUnit.MillijoulePerHour), + (PowerUnit.Watt, PowerUnit.Milliwatt) => new Power(_value * 1000, PowerUnit.Milliwatt), + (PowerUnit.Watt, PowerUnit.Nanowatt) => new Power(_value * 1000000000, PowerUnit.Nanowatt), + (PowerUnit.Watt, PowerUnit.Petawatt) => new Power(_value / 1000000000000000, PowerUnit.Petawatt), + (PowerUnit.Watt, PowerUnit.Picowatt) => new Power(_value * 1000000000000, PowerUnit.Picowatt), + (PowerUnit.Watt, PowerUnit.Terawatt) => new Power(_value / 1000000000000, PowerUnit.Terawatt), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 8e3c050aac..fe522ea39c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -121,7 +122,7 @@ static PowerDensity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public PowerDensity(double value, PowerDensityUnit unit) + public PowerDensity(QuantityValue value, PowerDensityUnit unit) { _value = value; _unit = unit; @@ -135,7 +136,7 @@ public PowerDensity(double value, PowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerDensity(double value, UnitSystem unitSystem) + public PowerDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -186,10 +187,10 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -214,222 +215,222 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); + public QuantityValue DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); + public QuantityValue DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); + public QuantityValue DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); + public QuantityValue DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); /// /// Gets a value of this quantity converted into /// - public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); + public QuantityValue DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); + public QuantityValue DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); + public QuantityValue DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); + public QuantityValue DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); + public QuantityValue GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); + public QuantityValue GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); + public QuantityValue GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); + public QuantityValue GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); + public QuantityValue KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); + public QuantityValue KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); + public QuantityValue KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); + public QuantityValue KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); + public QuantityValue MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); + public QuantityValue MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); + public QuantityValue MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); + public QuantityValue MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); + public QuantityValue MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); + public QuantityValue MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); + public QuantityValue MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); + public QuantityValue MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); + public QuantityValue MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); + public QuantityValue MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); + public QuantityValue MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); + public QuantityValue MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); + public QuantityValue NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); + public QuantityValue NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); + public QuantityValue NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); + public QuantityValue NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); + public QuantityValue PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); + public QuantityValue PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); + public QuantityValue PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); + public QuantityValue PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); /// /// Gets a value of this quantity converted into /// - public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); + public QuantityValue TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); + public QuantityValue TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); + public QuantityValue TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); + public QuantityValue TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); /// /// Gets a value of this quantity converted into /// - public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); + public QuantityValue WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); + public QuantityValue WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); /// /// Gets a value of this quantity converted into /// - public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); + public QuantityValue WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter); + public QuantityValue WattsPerLiter => As(PowerDensityUnit.WattPerLiter); #endregion @@ -563,7 +564,7 @@ public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? pro /// /// Creates a from . /// - public static PowerDensity FromDecawattsPerCubicFoot(double value) + public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot); } @@ -571,7 +572,7 @@ public static PowerDensity FromDecawattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromDecawattsPerCubicInch(double value) + public static PowerDensity FromDecawattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch); } @@ -579,7 +580,7 @@ public static PowerDensity FromDecawattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromDecawattsPerCubicMeter(double value) + public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter); } @@ -587,7 +588,7 @@ public static PowerDensity FromDecawattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromDecawattsPerLiter(double value) + public static PowerDensity FromDecawattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter); } @@ -595,7 +596,7 @@ public static PowerDensity FromDecawattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromDeciwattsPerCubicFoot(double value) + public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot); } @@ -603,7 +604,7 @@ public static PowerDensity FromDeciwattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromDeciwattsPerCubicInch(double value) + public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch); } @@ -611,7 +612,7 @@ public static PowerDensity FromDeciwattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromDeciwattsPerCubicMeter(double value) + public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter); } @@ -619,7 +620,7 @@ public static PowerDensity FromDeciwattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromDeciwattsPerLiter(double value) + public static PowerDensity FromDeciwattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter); } @@ -627,7 +628,7 @@ public static PowerDensity FromDeciwattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromGigawattsPerCubicFoot(double value) + public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot); } @@ -635,7 +636,7 @@ public static PowerDensity FromGigawattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromGigawattsPerCubicInch(double value) + public static PowerDensity FromGigawattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch); } @@ -643,7 +644,7 @@ public static PowerDensity FromGigawattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromGigawattsPerCubicMeter(double value) + public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter); } @@ -651,7 +652,7 @@ public static PowerDensity FromGigawattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromGigawattsPerLiter(double value) + public static PowerDensity FromGigawattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter); } @@ -659,7 +660,7 @@ public static PowerDensity FromGigawattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromKilowattsPerCubicFoot(double value) + public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot); } @@ -667,7 +668,7 @@ public static PowerDensity FromKilowattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromKilowattsPerCubicInch(double value) + public static PowerDensity FromKilowattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch); } @@ -675,7 +676,7 @@ public static PowerDensity FromKilowattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromKilowattsPerCubicMeter(double value) + public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter); } @@ -683,7 +684,7 @@ public static PowerDensity FromKilowattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromKilowattsPerLiter(double value) + public static PowerDensity FromKilowattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter); } @@ -691,7 +692,7 @@ public static PowerDensity FromKilowattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromMegawattsPerCubicFoot(double value) + public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot); } @@ -699,7 +700,7 @@ public static PowerDensity FromMegawattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromMegawattsPerCubicInch(double value) + public static PowerDensity FromMegawattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch); } @@ -707,7 +708,7 @@ public static PowerDensity FromMegawattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromMegawattsPerCubicMeter(double value) + public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter); } @@ -715,7 +716,7 @@ public static PowerDensity FromMegawattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromMegawattsPerLiter(double value) + public static PowerDensity FromMegawattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter); } @@ -723,7 +724,7 @@ public static PowerDensity FromMegawattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromMicrowattsPerCubicFoot(double value) + public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot); } @@ -731,7 +732,7 @@ public static PowerDensity FromMicrowattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromMicrowattsPerCubicInch(double value) + public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch); } @@ -739,7 +740,7 @@ public static PowerDensity FromMicrowattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromMicrowattsPerCubicMeter(double value) + public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter); } @@ -747,7 +748,7 @@ public static PowerDensity FromMicrowattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromMicrowattsPerLiter(double value) + public static PowerDensity FromMicrowattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter); } @@ -755,7 +756,7 @@ public static PowerDensity FromMicrowattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromMilliwattsPerCubicFoot(double value) + public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot); } @@ -763,7 +764,7 @@ public static PowerDensity FromMilliwattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromMilliwattsPerCubicInch(double value) + public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch); } @@ -771,7 +772,7 @@ public static PowerDensity FromMilliwattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromMilliwattsPerCubicMeter(double value) + public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter); } @@ -779,7 +780,7 @@ public static PowerDensity FromMilliwattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromMilliwattsPerLiter(double value) + public static PowerDensity FromMilliwattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter); } @@ -787,7 +788,7 @@ public static PowerDensity FromMilliwattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromNanowattsPerCubicFoot(double value) + public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot); } @@ -795,7 +796,7 @@ public static PowerDensity FromNanowattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromNanowattsPerCubicInch(double value) + public static PowerDensity FromNanowattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch); } @@ -803,7 +804,7 @@ public static PowerDensity FromNanowattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromNanowattsPerCubicMeter(double value) + public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter); } @@ -811,7 +812,7 @@ public static PowerDensity FromNanowattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromNanowattsPerLiter(double value) + public static PowerDensity FromNanowattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter); } @@ -819,7 +820,7 @@ public static PowerDensity FromNanowattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromPicowattsPerCubicFoot(double value) + public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot); } @@ -827,7 +828,7 @@ public static PowerDensity FromPicowattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromPicowattsPerCubicInch(double value) + public static PowerDensity FromPicowattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch); } @@ -835,7 +836,7 @@ public static PowerDensity FromPicowattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromPicowattsPerCubicMeter(double value) + public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter); } @@ -843,7 +844,7 @@ public static PowerDensity FromPicowattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromPicowattsPerLiter(double value) + public static PowerDensity FromPicowattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter); } @@ -851,7 +852,7 @@ public static PowerDensity FromPicowattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromTerawattsPerCubicFoot(double value) + public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot); } @@ -859,7 +860,7 @@ public static PowerDensity FromTerawattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromTerawattsPerCubicInch(double value) + public static PowerDensity FromTerawattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch); } @@ -867,7 +868,7 @@ public static PowerDensity FromTerawattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromTerawattsPerCubicMeter(double value) + public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter); } @@ -875,7 +876,7 @@ public static PowerDensity FromTerawattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromTerawattsPerLiter(double value) + public static PowerDensity FromTerawattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter); } @@ -883,7 +884,7 @@ public static PowerDensity FromTerawattsPerLiter(double value) /// /// Creates a from . /// - public static PowerDensity FromWattsPerCubicFoot(double value) + public static PowerDensity FromWattsPerCubicFoot(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot); } @@ -891,7 +892,7 @@ public static PowerDensity FromWattsPerCubicFoot(double value) /// /// Creates a from . /// - public static PowerDensity FromWattsPerCubicInch(double value) + public static PowerDensity FromWattsPerCubicInch(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch); } @@ -899,7 +900,7 @@ public static PowerDensity FromWattsPerCubicInch(double value) /// /// Creates a from . /// - public static PowerDensity FromWattsPerCubicMeter(double value) + public static PowerDensity FromWattsPerCubicMeter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter); } @@ -907,7 +908,7 @@ public static PowerDensity FromWattsPerCubicMeter(double value) /// /// Creates a from . /// - public static PowerDensity FromWattsPerLiter(double value) + public static PowerDensity FromWattsPerLiter(QuantityValue value) { return new PowerDensity(value, PowerDensityUnit.WattPerLiter); } @@ -918,7 +919,7 @@ public static PowerDensity FromWattsPerLiter(double value) /// Value to convert from. /// Unit to convert from. /// PowerDensity unit value. - public static PowerDensity From(double value, PowerDensityUnit fromUnit) + public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit) { return new PowerDensity(value, fromUnit); } @@ -1090,25 +1091,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static PowerDensity operator *(double left, PowerDensity right) + public static PowerDensity operator *(QuantityValue left, PowerDensity right) { return new PowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PowerDensity operator *(PowerDensity left, double right) + public static PowerDensity operator *(PowerDensity left, QuantityValue right) { return new PowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PowerDensity operator /(PowerDensity left, double right) + public static PowerDensity operator /(PowerDensity left, QuantityValue right) { return new PowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PowerDensity left, PowerDensity right) + public static QuantityValue operator /(PowerDensity left, PowerDensity right) { return left.WattsPerCubicMeter / right.WattsPerCubicMeter; } @@ -1141,27 +1142,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(PowerDensity left, PowerDensity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerDensity other, PowerDensity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(PowerDensity left, PowerDensity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is PowerDensity otherQuantity)) @@ -1171,15 +1165,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(PowerDensity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1262,10 +1253,10 @@ public bool Equals(PowerDensity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1282,7 +1273,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PowerDensity other, PowerDensity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1295,7 +1286,12 @@ public bool Equals(PowerDensity other, PowerDensity tolerance) /// A hash code for the current PowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1306,7 +1302,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerDensityUnit unit) + public QuantityValue As(PowerDensityUnit unit) { if (Unit == unit) return Value; @@ -1315,7 +1311,7 @@ public double As(PowerDensityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1330,7 +1326,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); @@ -1396,94 +1392,94 @@ private bool TryToUnit(PowerDensityUnit unit, [NotNullWhen(true)] out PowerDensi PowerDensity? convertedOrNull = (Unit, unit) switch { // PowerDensityUnit -> BaseUnit - (PowerDensityUnit.DecawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DecawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DecawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DecawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DeciwattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e-1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DeciwattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e-1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DeciwattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e-1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.DeciwattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e-1d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.GigawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.GigawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.GigawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.GigawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.KilowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.KilowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.KilowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.KilowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MegawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MegawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MegawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MegawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MicrowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e-6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MicrowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e-6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MicrowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e-6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MicrowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e-6d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MilliwattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e-3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MilliwattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e-3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MilliwattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e-3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.MilliwattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e-3d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.NanowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e-9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.NanowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e-9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.NanowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e-9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.NanowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e-9d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.PicowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e-12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.PicowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e-12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.PicowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e-12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.PicowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e-12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.TerawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 3.531466672148859e1) * 1e12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.TerawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 6.102374409473228e4) * 1e12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.TerawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value) * 1e12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.TerawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity((_value * 1.0e3) * 1e12d, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.WattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 3.531466672148859e1, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.WattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 6.102374409473228e4, PowerDensityUnit.WattPerCubicMeter), - (PowerDensityUnit.WattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1.0e3, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DecawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 10000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DecawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 2500000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DecawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 10, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DecawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 10000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DeciwattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 1000000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DeciwattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 250000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DeciwattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 10, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.DeciwattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 100, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.GigawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.GigawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.GigawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.GigawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.KilowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.KilowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.KilowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.KilowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MegawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MegawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MegawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MegawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MicrowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 10, false) / BigInteger.Pow(10, 19), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MicrowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25000000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MicrowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MicrowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MilliwattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100000000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MilliwattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MilliwattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.MilliwattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.NanowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 10000, false) / BigInteger.Pow(10, 19), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.NanowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3051187204736614, 5, false) / BigInteger.Pow(10, 19), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.NanowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.NanowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.PicowattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 10000000, false) / BigInteger.Pow(10, 19), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.PicowattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 2500, false) / BigInteger.Pow(10, 19), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.PicowattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.PicowattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value / 1000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.TerawattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.TerawattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 61023744094732280, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.TerawattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.TerawattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000000000000000, PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.WattPerCubicFoot, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(3531466672148859, 100000000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.WattPerCubicInch, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * new QuantityValue(1525593602368307, 25000000000, false), PowerDensityUnit.WattPerCubicMeter), + (PowerDensityUnit.WattPerLiter, PowerDensityUnit.WattPerCubicMeter) => new PowerDensity(_value * 1000, PowerDensityUnit.WattPerCubicMeter), // BaseUnit -> PowerDensityUnit - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e1d, PowerDensityUnit.DecawattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e1d, PowerDensityUnit.DecawattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicMeter) => new PowerDensity((_value) / 1e1d, PowerDensityUnit.DecawattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e1d, PowerDensityUnit.DecawattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e-1d, PowerDensityUnit.DeciwattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e-1d, PowerDensityUnit.DeciwattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicMeter) => new PowerDensity((_value) / 1e-1d, PowerDensityUnit.DeciwattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e-1d, PowerDensityUnit.DeciwattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e9d, PowerDensityUnit.GigawattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e9d, PowerDensityUnit.GigawattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicMeter) => new PowerDensity((_value) / 1e9d, PowerDensityUnit.GigawattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e9d, PowerDensityUnit.GigawattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e3d, PowerDensityUnit.KilowattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e3d, PowerDensityUnit.KilowattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicMeter) => new PowerDensity((_value) / 1e3d, PowerDensityUnit.KilowattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e3d, PowerDensityUnit.KilowattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e6d, PowerDensityUnit.MegawattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e6d, PowerDensityUnit.MegawattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicMeter) => new PowerDensity((_value) / 1e6d, PowerDensityUnit.MegawattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e6d, PowerDensityUnit.MegawattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e-6d, PowerDensityUnit.MicrowattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e-6d, PowerDensityUnit.MicrowattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicMeter) => new PowerDensity((_value) / 1e-6d, PowerDensityUnit.MicrowattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e-6d, PowerDensityUnit.MicrowattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e-3d, PowerDensityUnit.MilliwattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e-3d, PowerDensityUnit.MilliwattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicMeter) => new PowerDensity((_value) / 1e-3d, PowerDensityUnit.MilliwattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e-3d, PowerDensityUnit.MilliwattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e-9d, PowerDensityUnit.NanowattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e-9d, PowerDensityUnit.NanowattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicMeter) => new PowerDensity((_value) / 1e-9d, PowerDensityUnit.NanowattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e-9d, PowerDensityUnit.NanowattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e-12d, PowerDensityUnit.PicowattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e-12d, PowerDensityUnit.PicowattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicMeter) => new PowerDensity((_value) / 1e-12d, PowerDensityUnit.PicowattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e-12d, PowerDensityUnit.PicowattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicFoot) => new PowerDensity((_value / 3.531466672148859e1) / 1e12d, PowerDensityUnit.TerawattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicInch) => new PowerDensity((_value / 6.102374409473228e4) / 1e12d, PowerDensityUnit.TerawattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicMeter) => new PowerDensity((_value) / 1e12d, PowerDensityUnit.TerawattPerCubicMeter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerLiter) => new PowerDensity((_value / 1.0e3) / 1e12d, PowerDensityUnit.TerawattPerLiter), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicFoot) => new PowerDensity(_value / 3.531466672148859e1, PowerDensityUnit.WattPerCubicFoot), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicInch) => new PowerDensity(_value / 6.102374409473228e4, PowerDensityUnit.WattPerCubicInch), - (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerLiter) => new PowerDensity(_value / 1.0e3, PowerDensityUnit.WattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(10000000000000, 3531466672148859, false), PowerDensityUnit.DecawattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicInch) => new PowerDensity(_value * new QuantityValue(2500000000, 1525593602368307, false), PowerDensityUnit.DecawattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerCubicMeter) => new PowerDensity(_value / 10, PowerDensityUnit.DecawattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DecawattPerLiter) => new PowerDensity(_value / 10000, PowerDensityUnit.DecawattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(1000000000000000, 3531466672148859, false), PowerDensityUnit.DeciwattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicInch) => new PowerDensity(_value * new QuantityValue(250000000000, 1525593602368307, false), PowerDensityUnit.DeciwattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerCubicMeter) => new PowerDensity(_value * 10, PowerDensityUnit.DeciwattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.DeciwattPerLiter) => new PowerDensity(_value / 100, PowerDensityUnit.DeciwattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100000, 3531466672148859, false), PowerDensityUnit.GigawattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25, 1525593602368307, false), PowerDensityUnit.GigawattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerCubicMeter) => new PowerDensity(_value / 1000000000, PowerDensityUnit.GigawattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.GigawattPerLiter) => new PowerDensity(_value / 1000000000000, PowerDensityUnit.GigawattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100000000000, 3531466672148859, false), PowerDensityUnit.KilowattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25000000, 1525593602368307, false), PowerDensityUnit.KilowattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerCubicMeter) => new PowerDensity(_value / 1000, PowerDensityUnit.KilowattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.KilowattPerLiter) => new PowerDensity(_value / 1000000, PowerDensityUnit.KilowattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100000000, 3531466672148859, false), PowerDensityUnit.MegawattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25000, 1525593602368307, false), PowerDensityUnit.MegawattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerCubicMeter) => new PowerDensity(_value / 1000000, PowerDensityUnit.MegawattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MegawattPerLiter) => new PowerDensity(_value / 1000000000, PowerDensityUnit.MegawattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(10, 3531466672148859, false) * BigInteger.Pow(10, 19), PowerDensityUnit.MicrowattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25000000000000000, 1525593602368307, false), PowerDensityUnit.MicrowattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerCubicMeter) => new PowerDensity(_value * 1000000, PowerDensityUnit.MicrowattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MicrowattPerLiter) => new PowerDensity(_value * 1000, PowerDensityUnit.MicrowattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100000000000000000, 3531466672148859, false), PowerDensityUnit.MilliwattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25000000000000, 1525593602368307, false), PowerDensityUnit.MilliwattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerCubicMeter) => new PowerDensity(_value * 1000, PowerDensityUnit.MilliwattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.MilliwattPerLiter) => new PowerDensity(_value, PowerDensityUnit.MilliwattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(10000, 3531466672148859, false) * BigInteger.Pow(10, 19), PowerDensityUnit.NanowattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicInch) => new PowerDensity(_value * new QuantityValue(5, 3051187204736614, false) * BigInteger.Pow(10, 19), PowerDensityUnit.NanowattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerCubicMeter) => new PowerDensity(_value * 1000000000, PowerDensityUnit.NanowattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.NanowattPerLiter) => new PowerDensity(_value * 1000000, PowerDensityUnit.NanowattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(10000000, 3531466672148859, false) * BigInteger.Pow(10, 19), PowerDensityUnit.PicowattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicInch) => new PowerDensity(_value * new QuantityValue(2500, 1525593602368307, false) * BigInteger.Pow(10, 19), PowerDensityUnit.PicowattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerCubicMeter) => new PowerDensity(_value * 1000000000000, PowerDensityUnit.PicowattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.PicowattPerLiter) => new PowerDensity(_value * 1000000000, PowerDensityUnit.PicowattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100, 3531466672148859, false), PowerDensityUnit.TerawattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicInch) => new PowerDensity(_value / 61023744094732280, PowerDensityUnit.TerawattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerCubicMeter) => new PowerDensity(_value / 1000000000000, PowerDensityUnit.TerawattPerCubicMeter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.TerawattPerLiter) => new PowerDensity(_value / 1000000000000000, PowerDensityUnit.TerawattPerLiter), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicFoot) => new PowerDensity(_value * new QuantityValue(100000000000000, 3531466672148859, false), PowerDensityUnit.WattPerCubicFoot), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicInch) => new PowerDensity(_value * new QuantityValue(25000000000, 1525593602368307, false), PowerDensityUnit.WattPerCubicInch), + (PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerLiter) => new PowerDensity(_value / 1000, PowerDensityUnit.WattPerLiter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index a61254e6a5..fd53898cea 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,7 +80,7 @@ static PowerRatio() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public PowerRatio(double value, PowerRatioUnit unit) + public PowerRatio(QuantityValue value, PowerRatioUnit unit) { _value = value; _unit = unit; @@ -93,7 +94,7 @@ public PowerRatio(double value, PowerRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerRatio(double value, UnitSystem unitSystem) + public PowerRatio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -144,10 +145,10 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -172,12 +173,12 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); + public QuantityValue DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); /// /// Gets a value of this quantity converted into /// - public double DecibelWatts => As(PowerRatioUnit.DecibelWatt); + public QuantityValue DecibelWatts => As(PowerRatioUnit.DecibelWatt); #endregion @@ -227,7 +228,7 @@ public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provi /// /// Creates a from . /// - public static PowerRatio FromDecibelMilliwatts(double value) + public static PowerRatio FromDecibelMilliwatts(QuantityValue value) { return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt); } @@ -235,7 +236,7 @@ public static PowerRatio FromDecibelMilliwatts(double value) /// /// Creates a from . /// - public static PowerRatio FromDecibelWatts(double value) + public static PowerRatio FromDecibelWatts(QuantityValue value) { return new PowerRatio(value, PowerRatioUnit.DecibelWatt); } @@ -246,7 +247,7 @@ public static PowerRatio FromDecibelWatts(double value) /// Value to convert from. /// Unit to convert from. /// PowerRatio unit value. - public static PowerRatio From(double value, PowerRatioUnit fromUnit) + public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit) { return new PowerRatio(value, fromUnit); } @@ -410,7 +411,10 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value / 10) + Math.Pow(10, right.ToUnit(left.Unit).Value / 10)), left.Unit); + // TODO see if we can switch to operating in linear space: left + right.ToUnit(left.Unit) + return new PowerRatio(10 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 10).ToDouble()) + Math.Pow(10, (right.ToUnit(left.Unit).Value / 10).ToDouble()))), + left.Unit); } /// Get from logarithmic subtraction of two . @@ -418,35 +422,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value / 10) - Math.Pow(10, right.ToUnit(left.Unit).Value / 10)), left.Unit); + // TODO see if we can switch to operating in linear space: left - right.ToUnit(left.Unit) + return new PowerRatio(10 * QuantityValue.FromDoubleRounded(Math.Log10( + Math.Pow(10, (left.Value / 10).ToDouble()) - Math.Pow(10, (right.ToUnit(left.Unit).Value / 10).ToDouble()))), + left.Unit); } /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(double left, PowerRatio right) + public static PowerRatio operator *(QuantityValue left, PowerRatio right) { // Logarithmic multiplication = addition + // TODO see if we can switch to operating in linear space: left * right.ToUnit(left.Unit) return new PowerRatio(left + right.Value, right.Unit); } /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(PowerRatio left, double right) + public static PowerRatio operator *(PowerRatio left, QuantityValue right) { // Logarithmic multiplication = addition return new PowerRatio(left.Value + right, left.Unit); } /// Get from logarithmic division of by value. - public static PowerRatio operator /(PowerRatio left, double right) + public static PowerRatio operator /(PowerRatio left, QuantityValue right) { // Logarithmic division = subtraction return new PowerRatio(left.Value - right, left.Unit); } /// Get ratio value from logarithmic division of by . - public static double operator /(PowerRatio left, PowerRatio right) + public static QuantityValue operator /(PowerRatio left, PowerRatio right) { // Logarithmic division = subtraction - return Convert.ToDouble(left.Value - right.ToUnit(left.Unit).Value); + return left.Value - right.ToUnit(left.Unit).Value; } #endregion @@ -477,27 +485,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(PowerRatio left, PowerRatio right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PowerRatio other, PowerRatio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(PowerRatio left, PowerRatio right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is PowerRatio otherQuantity)) @@ -507,15 +508,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(PowerRatio other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -598,10 +596,10 @@ public bool Equals(PowerRatio other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -618,7 +616,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PowerRatio other, PowerRatio tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -631,7 +629,12 @@ public bool Equals(PowerRatio other, PowerRatio tolerance) /// A hash code for the current PowerRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -642,7 +645,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerRatioUnit unit) + public QuantityValue As(PowerRatioUnit unit) { if (Unit == unit) return Value; @@ -651,7 +654,7 @@ public double As(PowerRatioUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -666,7 +669,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); @@ -732,7 +735,7 @@ private bool TryToUnit(PowerRatioUnit unit, [NotNullWhen(true)] out PowerRatio? PowerRatio? convertedOrNull = (Unit, unit) switch { // PowerRatioUnit -> BaseUnit - (PowerRatioUnit.DecibelMilliwatt, PowerRatioUnit.DecibelWatt) => new PowerRatio(_value - 30, PowerRatioUnit.DecibelWatt), + (PowerRatioUnit.DecibelMilliwatt, PowerRatioUnit.DecibelWatt) => new PowerRatio(_value + -30, PowerRatioUnit.DecibelWatt), // BaseUnit -> PowerRatioUnit (PowerRatioUnit.DecibelWatt, PowerRatioUnit.DecibelMilliwatt) => new PowerRatio(_value + 30, PowerRatioUnit.DecibelMilliwatt), diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 2b9b0ac0c2..390c79f1b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -63,7 +61,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -141,7 +139,7 @@ static Pressure() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Pressure(double value, PressureUnit unit) + public Pressure(QuantityValue value, PressureUnit unit) { _value = value; _unit = unit; @@ -155,7 +153,7 @@ public Pressure(double value, PressureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Pressure(double value, UnitSystem unitSystem) + public Pressure(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -206,10 +204,10 @@ public Pressure(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -234,247 +232,247 @@ public Pressure(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Atmospheres => As(PressureUnit.Atmosphere); + public QuantityValue Atmospheres => As(PressureUnit.Atmosphere); /// /// Gets a value of this quantity converted into /// - public double Bars => As(PressureUnit.Bar); + public QuantityValue Bars => As(PressureUnit.Bar); /// /// Gets a value of this quantity converted into /// - public double Centibars => As(PressureUnit.Centibar); + public QuantityValue Centibars => As(PressureUnit.Centibar); /// /// Gets a value of this quantity converted into /// - public double CentimetersOfWaterColumn => As(PressureUnit.CentimeterOfWaterColumn); + public QuantityValue CentimetersOfWaterColumn => As(PressureUnit.CentimeterOfWaterColumn); /// /// Gets a value of this quantity converted into /// - public double Decapascals => As(PressureUnit.Decapascal); + public QuantityValue Decapascals => As(PressureUnit.Decapascal); /// /// Gets a value of this quantity converted into /// - public double Decibars => As(PressureUnit.Decibar); + public QuantityValue Decibars => As(PressureUnit.Decibar); /// /// Gets a value of this quantity converted into /// - public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); + public QuantityValue DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double FeetOfElevation => As(PressureUnit.FootOfElevation); + public QuantityValue FeetOfElevation => As(PressureUnit.FootOfElevation); /// /// Gets a value of this quantity converted into /// - public double FeetOfHead => As(PressureUnit.FootOfHead); + public QuantityValue FeetOfHead => As(PressureUnit.FootOfHead); /// /// Gets a value of this quantity converted into /// - public double Gigapascals => As(PressureUnit.Gigapascal); + public QuantityValue Gigapascals => As(PressureUnit.Gigapascal); /// /// Gets a value of this quantity converted into /// - public double Hectopascals => As(PressureUnit.Hectopascal); + public QuantityValue Hectopascals => As(PressureUnit.Hectopascal); /// /// Gets a value of this quantity converted into /// - public double InchesOfMercury => As(PressureUnit.InchOfMercury); + public QuantityValue InchesOfMercury => As(PressureUnit.InchOfMercury); /// /// Gets a value of this quantity converted into /// - public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); + public QuantityValue InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); /// /// Gets a value of this quantity converted into /// - public double Kilobars => As(PressureUnit.Kilobar); + public QuantityValue Kilobars => As(PressureUnit.Kilobar); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); + public QuantityValue KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); + public QuantityValue KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); + public QuantityValue KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); + public QuantityValue KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); + public QuantityValue KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); + public QuantityValue KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double Kilopascals => As(PressureUnit.Kilopascal); + public QuantityValue Kilopascals => As(PressureUnit.Kilopascal); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); + public QuantityValue KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); + public QuantityValue KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); + public QuantityValue KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); /// /// Gets a value of this quantity converted into /// - public double Megabars => As(PressureUnit.Megabar); + public QuantityValue Megabars => As(PressureUnit.Megabar); /// /// Gets a value of this quantity converted into /// - public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); + public QuantityValue MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double Megapascals => As(PressureUnit.Megapascal); + public QuantityValue Megapascals => As(PressureUnit.Megapascal); /// /// Gets a value of this quantity converted into /// - public double MetersOfElevation => As(PressureUnit.MeterOfElevation); + public QuantityValue MetersOfElevation => As(PressureUnit.MeterOfElevation); /// /// Gets a value of this quantity converted into /// - public double MetersOfHead => As(PressureUnit.MeterOfHead); + public QuantityValue MetersOfHead => As(PressureUnit.MeterOfHead); /// /// Gets a value of this quantity converted into /// - public double MetersOfWaterColumn => As(PressureUnit.MeterOfWaterColumn); + public QuantityValue MetersOfWaterColumn => As(PressureUnit.MeterOfWaterColumn); /// /// Gets a value of this quantity converted into /// - public double Microbars => As(PressureUnit.Microbar); + public QuantityValue Microbars => As(PressureUnit.Microbar); /// /// Gets a value of this quantity converted into /// - public double Micropascals => As(PressureUnit.Micropascal); + public QuantityValue Micropascals => As(PressureUnit.Micropascal); /// /// Gets a value of this quantity converted into /// - public double Millibars => As(PressureUnit.Millibar); + public QuantityValue Millibars => As(PressureUnit.Millibar); /// /// Gets a value of this quantity converted into /// - public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); + public QuantityValue MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); /// /// Gets a value of this quantity converted into /// - public double MillimetersOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); + public QuantityValue MillimetersOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); /// /// Gets a value of this quantity converted into /// - public double Millipascals => As(PressureUnit.Millipascal); + public QuantityValue Millipascals => As(PressureUnit.Millipascal); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); + public QuantityValue NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); + public QuantityValue NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); + public QuantityValue NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double Pascals => As(PressureUnit.Pascal); + public QuantityValue Pascals => As(PressureUnit.Pascal); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); + public QuantityValue PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); + public QuantityValue PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); + public QuantityValue PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); /// /// Gets a value of this quantity converted into /// - public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); + public QuantityValue PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); /// /// Gets a value of this quantity converted into /// - public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); + public QuantityValue TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); + public QuantityValue TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); + public QuantityValue TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); + public QuantityValue TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double Torrs => As(PressureUnit.Torr); + public QuantityValue Torrs => As(PressureUnit.Torr); #endregion @@ -618,7 +616,7 @@ public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static Pressure FromAtmospheres(double value) + public static Pressure FromAtmospheres(QuantityValue value) { return new Pressure(value, PressureUnit.Atmosphere); } @@ -626,7 +624,7 @@ public static Pressure FromAtmospheres(double value) /// /// Creates a from . /// - public static Pressure FromBars(double value) + public static Pressure FromBars(QuantityValue value) { return new Pressure(value, PressureUnit.Bar); } @@ -634,7 +632,7 @@ public static Pressure FromBars(double value) /// /// Creates a from . /// - public static Pressure FromCentibars(double value) + public static Pressure FromCentibars(QuantityValue value) { return new Pressure(value, PressureUnit.Centibar); } @@ -642,7 +640,7 @@ public static Pressure FromCentibars(double value) /// /// Creates a from . /// - public static Pressure FromCentimetersOfWaterColumn(double value) + public static Pressure FromCentimetersOfWaterColumn(QuantityValue value) { return new Pressure(value, PressureUnit.CentimeterOfWaterColumn); } @@ -650,7 +648,7 @@ public static Pressure FromCentimetersOfWaterColumn(double value) /// /// Creates a from . /// - public static Pressure FromDecapascals(double value) + public static Pressure FromDecapascals(QuantityValue value) { return new Pressure(value, PressureUnit.Decapascal); } @@ -658,7 +656,7 @@ public static Pressure FromDecapascals(double value) /// /// Creates a from . /// - public static Pressure FromDecibars(double value) + public static Pressure FromDecibars(QuantityValue value) { return new Pressure(value, PressureUnit.Decibar); } @@ -666,7 +664,7 @@ public static Pressure FromDecibars(double value) /// /// Creates a from . /// - public static Pressure FromDynesPerSquareCentimeter(double value) + public static Pressure FromDynesPerSquareCentimeter(QuantityValue value) { return new Pressure(value, PressureUnit.DynePerSquareCentimeter); } @@ -674,7 +672,7 @@ public static Pressure FromDynesPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Pressure FromFeetOfElevation(double value) + public static Pressure FromFeetOfElevation(QuantityValue value) { return new Pressure(value, PressureUnit.FootOfElevation); } @@ -682,7 +680,7 @@ public static Pressure FromFeetOfElevation(double value) /// /// Creates a from . /// - public static Pressure FromFeetOfHead(double value) + public static Pressure FromFeetOfHead(QuantityValue value) { return new Pressure(value, PressureUnit.FootOfHead); } @@ -690,7 +688,7 @@ public static Pressure FromFeetOfHead(double value) /// /// Creates a from . /// - public static Pressure FromGigapascals(double value) + public static Pressure FromGigapascals(QuantityValue value) { return new Pressure(value, PressureUnit.Gigapascal); } @@ -698,7 +696,7 @@ public static Pressure FromGigapascals(double value) /// /// Creates a from . /// - public static Pressure FromHectopascals(double value) + public static Pressure FromHectopascals(QuantityValue value) { return new Pressure(value, PressureUnit.Hectopascal); } @@ -706,7 +704,7 @@ public static Pressure FromHectopascals(double value) /// /// Creates a from . /// - public static Pressure FromInchesOfMercury(double value) + public static Pressure FromInchesOfMercury(QuantityValue value) { return new Pressure(value, PressureUnit.InchOfMercury); } @@ -714,7 +712,7 @@ public static Pressure FromInchesOfMercury(double value) /// /// Creates a from . /// - public static Pressure FromInchesOfWaterColumn(double value) + public static Pressure FromInchesOfWaterColumn(QuantityValue value) { return new Pressure(value, PressureUnit.InchOfWaterColumn); } @@ -722,7 +720,7 @@ public static Pressure FromInchesOfWaterColumn(double value) /// /// Creates a from . /// - public static Pressure FromKilobars(double value) + public static Pressure FromKilobars(QuantityValue value) { return new Pressure(value, PressureUnit.Kilobar); } @@ -730,7 +728,7 @@ public static Pressure FromKilobars(double value) /// /// Creates a from . /// - public static Pressure FromKilogramsForcePerSquareCentimeter(double value) + public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter); } @@ -738,7 +736,7 @@ public static Pressure FromKilogramsForcePerSquareCentimeter(double value) /// /// Creates a from . /// - public static Pressure FromKilogramsForcePerSquareMeter(double value) + public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter); } @@ -746,7 +744,7 @@ public static Pressure FromKilogramsForcePerSquareMeter(double value) /// /// Creates a from . /// - public static Pressure FromKilogramsForcePerSquareMillimeter(double value) + public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter); } @@ -754,7 +752,7 @@ public static Pressure FromKilogramsForcePerSquareMillimeter(double value) /// /// Creates a from . /// - public static Pressure FromKilonewtonsPerSquareCentimeter(double value) + public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter); } @@ -762,7 +760,7 @@ public static Pressure FromKilonewtonsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Pressure FromKilonewtonsPerSquareMeter(double value) + public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter); } @@ -770,7 +768,7 @@ public static Pressure FromKilonewtonsPerSquareMeter(double value) /// /// Creates a from . /// - public static Pressure FromKilonewtonsPerSquareMillimeter(double value) + public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue value) { return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter); } @@ -778,7 +776,7 @@ public static Pressure FromKilonewtonsPerSquareMillimeter(double value) /// /// Creates a from . /// - public static Pressure FromKilopascals(double value) + public static Pressure FromKilopascals(QuantityValue value) { return new Pressure(value, PressureUnit.Kilopascal); } @@ -786,7 +784,7 @@ public static Pressure FromKilopascals(double value) /// /// Creates a from . /// - public static Pressure FromKilopoundsForcePerSquareFoot(double value) + public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue value) { return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot); } @@ -794,7 +792,7 @@ public static Pressure FromKilopoundsForcePerSquareFoot(double value) /// /// Creates a from . /// - public static Pressure FromKilopoundsForcePerSquareInch(double value) + public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue value) { return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch); } @@ -802,7 +800,7 @@ public static Pressure FromKilopoundsForcePerSquareInch(double value) /// /// Creates a from . /// - public static Pressure FromKilopoundsForcePerSquareMil(double value) + public static Pressure FromKilopoundsForcePerSquareMil(QuantityValue value) { return new Pressure(value, PressureUnit.KilopoundForcePerSquareMil); } @@ -810,7 +808,7 @@ public static Pressure FromKilopoundsForcePerSquareMil(double value) /// /// Creates a from . /// - public static Pressure FromMegabars(double value) + public static Pressure FromMegabars(QuantityValue value) { return new Pressure(value, PressureUnit.Megabar); } @@ -818,7 +816,7 @@ public static Pressure FromMegabars(double value) /// /// Creates a from . /// - public static Pressure FromMeganewtonsPerSquareMeter(double value) + public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue value) { return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter); } @@ -826,7 +824,7 @@ public static Pressure FromMeganewtonsPerSquareMeter(double value) /// /// Creates a from . /// - public static Pressure FromMegapascals(double value) + public static Pressure FromMegapascals(QuantityValue value) { return new Pressure(value, PressureUnit.Megapascal); } @@ -834,7 +832,7 @@ public static Pressure FromMegapascals(double value) /// /// Creates a from . /// - public static Pressure FromMetersOfElevation(double value) + public static Pressure FromMetersOfElevation(QuantityValue value) { return new Pressure(value, PressureUnit.MeterOfElevation); } @@ -842,7 +840,7 @@ public static Pressure FromMetersOfElevation(double value) /// /// Creates a from . /// - public static Pressure FromMetersOfHead(double value) + public static Pressure FromMetersOfHead(QuantityValue value) { return new Pressure(value, PressureUnit.MeterOfHead); } @@ -850,7 +848,7 @@ public static Pressure FromMetersOfHead(double value) /// /// Creates a from . /// - public static Pressure FromMetersOfWaterColumn(double value) + public static Pressure FromMetersOfWaterColumn(QuantityValue value) { return new Pressure(value, PressureUnit.MeterOfWaterColumn); } @@ -858,7 +856,7 @@ public static Pressure FromMetersOfWaterColumn(double value) /// /// Creates a from . /// - public static Pressure FromMicrobars(double value) + public static Pressure FromMicrobars(QuantityValue value) { return new Pressure(value, PressureUnit.Microbar); } @@ -866,7 +864,7 @@ public static Pressure FromMicrobars(double value) /// /// Creates a from . /// - public static Pressure FromMicropascals(double value) + public static Pressure FromMicropascals(QuantityValue value) { return new Pressure(value, PressureUnit.Micropascal); } @@ -874,7 +872,7 @@ public static Pressure FromMicropascals(double value) /// /// Creates a from . /// - public static Pressure FromMillibars(double value) + public static Pressure FromMillibars(QuantityValue value) { return new Pressure(value, PressureUnit.Millibar); } @@ -882,7 +880,7 @@ public static Pressure FromMillibars(double value) /// /// Creates a from . /// - public static Pressure FromMillimetersOfMercury(double value) + public static Pressure FromMillimetersOfMercury(QuantityValue value) { return new Pressure(value, PressureUnit.MillimeterOfMercury); } @@ -890,7 +888,7 @@ public static Pressure FromMillimetersOfMercury(double value) /// /// Creates a from . /// - public static Pressure FromMillimetersOfWaterColumn(double value) + public static Pressure FromMillimetersOfWaterColumn(QuantityValue value) { return new Pressure(value, PressureUnit.MillimeterOfWaterColumn); } @@ -898,7 +896,7 @@ public static Pressure FromMillimetersOfWaterColumn(double value) /// /// Creates a from . /// - public static Pressure FromMillipascals(double value) + public static Pressure FromMillipascals(QuantityValue value) { return new Pressure(value, PressureUnit.Millipascal); } @@ -906,7 +904,7 @@ public static Pressure FromMillipascals(double value) /// /// Creates a from . /// - public static Pressure FromNewtonsPerSquareCentimeter(double value) + public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue value) { return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter); } @@ -914,7 +912,7 @@ public static Pressure FromNewtonsPerSquareCentimeter(double value) /// /// Creates a from . /// - public static Pressure FromNewtonsPerSquareMeter(double value) + public static Pressure FromNewtonsPerSquareMeter(QuantityValue value) { return new Pressure(value, PressureUnit.NewtonPerSquareMeter); } @@ -922,7 +920,7 @@ public static Pressure FromNewtonsPerSquareMeter(double value) /// /// Creates a from . /// - public static Pressure FromNewtonsPerSquareMillimeter(double value) + public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue value) { return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter); } @@ -930,7 +928,7 @@ public static Pressure FromNewtonsPerSquareMillimeter(double value) /// /// Creates a from . /// - public static Pressure FromPascals(double value) + public static Pressure FromPascals(QuantityValue value) { return new Pressure(value, PressureUnit.Pascal); } @@ -938,7 +936,7 @@ public static Pressure FromPascals(double value) /// /// Creates a from . /// - public static Pressure FromPoundsForcePerSquareFoot(double value) + public static Pressure FromPoundsForcePerSquareFoot(QuantityValue value) { return new Pressure(value, PressureUnit.PoundForcePerSquareFoot); } @@ -946,7 +944,7 @@ public static Pressure FromPoundsForcePerSquareFoot(double value) /// /// Creates a from . /// - public static Pressure FromPoundsForcePerSquareInch(double value) + public static Pressure FromPoundsForcePerSquareInch(QuantityValue value) { return new Pressure(value, PressureUnit.PoundForcePerSquareInch); } @@ -954,7 +952,7 @@ public static Pressure FromPoundsForcePerSquareInch(double value) /// /// Creates a from . /// - public static Pressure FromPoundsForcePerSquareMil(double value) + public static Pressure FromPoundsForcePerSquareMil(QuantityValue value) { return new Pressure(value, PressureUnit.PoundForcePerSquareMil); } @@ -962,7 +960,7 @@ public static Pressure FromPoundsForcePerSquareMil(double value) /// /// Creates a from . /// - public static Pressure FromPoundsPerInchSecondSquared(double value) + public static Pressure FromPoundsPerInchSecondSquared(QuantityValue value) { return new Pressure(value, PressureUnit.PoundPerInchSecondSquared); } @@ -970,7 +968,7 @@ public static Pressure FromPoundsPerInchSecondSquared(double value) /// /// Creates a from . /// - public static Pressure FromTechnicalAtmospheres(double value) + public static Pressure FromTechnicalAtmospheres(QuantityValue value) { return new Pressure(value, PressureUnit.TechnicalAtmosphere); } @@ -978,7 +976,7 @@ public static Pressure FromTechnicalAtmospheres(double value) /// /// Creates a from . /// - public static Pressure FromTonnesForcePerSquareCentimeter(double value) + public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue value) { return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter); } @@ -986,7 +984,7 @@ public static Pressure FromTonnesForcePerSquareCentimeter(double value) /// /// Creates a from . /// - public static Pressure FromTonnesForcePerSquareMeter(double value) + public static Pressure FromTonnesForcePerSquareMeter(QuantityValue value) { return new Pressure(value, PressureUnit.TonneForcePerSquareMeter); } @@ -994,7 +992,7 @@ public static Pressure FromTonnesForcePerSquareMeter(double value) /// /// Creates a from . /// - public static Pressure FromTonnesForcePerSquareMillimeter(double value) + public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue value) { return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter); } @@ -1002,7 +1000,7 @@ public static Pressure FromTonnesForcePerSquareMillimeter(double value) /// /// Creates a from . /// - public static Pressure FromTorrs(double value) + public static Pressure FromTorrs(QuantityValue value) { return new Pressure(value, PressureUnit.Torr); } @@ -1013,7 +1011,7 @@ public static Pressure FromTorrs(double value) /// Value to convert from. /// Unit to convert from. /// Pressure unit value. - public static Pressure From(double value, PressureUnit fromUnit) + public static Pressure From(QuantityValue value, PressureUnit fromUnit) { return new Pressure(value, fromUnit); } @@ -1185,25 +1183,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static Pressure operator *(double left, Pressure right) + public static Pressure operator *(QuantityValue left, Pressure right) { return new Pressure(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Pressure operator *(Pressure left, double right) + public static Pressure operator *(Pressure left, QuantityValue right) { return new Pressure(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Pressure operator /(Pressure left, double right) + public static Pressure operator /(Pressure left, QuantityValue right) { return new Pressure(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Pressure left, Pressure right) + public static QuantityValue operator /(Pressure left, Pressure right) { return left.Pascals / right.Pascals; } @@ -1300,27 +1298,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Pressure left, Pressure right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Pressure other, Pressure tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Pressure left, Pressure right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Pressure otherQuantity)) @@ -1330,15 +1321,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Pressure other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1421,10 +1409,10 @@ public bool Equals(Pressure other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1441,7 +1429,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Pressure other, Pressure tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1454,7 +1442,12 @@ public bool Equals(Pressure other, Pressure tolerance) /// A hash code for the current Pressure. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1465,7 +1458,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureUnit unit) + public QuantityValue As(PressureUnit unit) { if (Unit == unit) return Value; @@ -1474,7 +1467,7 @@ public double As(PressureUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1489,7 +1482,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); @@ -1555,104 +1548,104 @@ private bool TryToUnit(PressureUnit unit, [NotNullWhen(true)] out Pressure? conv Pressure? convertedOrNull = (Unit, unit) switch { // PressureUnit -> BaseUnit - (PressureUnit.Atmosphere, PressureUnit.Pascal) => new Pressure(_value * 1.01325 * 1e5, PressureUnit.Pascal), - (PressureUnit.Bar, PressureUnit.Pascal) => new Pressure(_value * 1e5, PressureUnit.Pascal), - (PressureUnit.Centibar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e-2d, PressureUnit.Pascal), - (PressureUnit.CentimeterOfWaterColumn, PressureUnit.Pascal) => new Pressure((_value * 9.806650000000272e3) * 1e-2d, PressureUnit.Pascal), - (PressureUnit.Decapascal, PressureUnit.Pascal) => new Pressure((_value) * 1e1d, PressureUnit.Pascal), - (PressureUnit.Decibar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e-1d, PressureUnit.Pascal), - (PressureUnit.DynePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 1.0e-1, PressureUnit.Pascal), - (PressureUnit.FootOfElevation, PressureUnit.Pascal) => new Pressure(Math.Pow(1.0 - (_value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal), - (PressureUnit.FootOfHead, PressureUnit.Pascal) => new Pressure(_value * 2989.0669, PressureUnit.Pascal), - (PressureUnit.Gigapascal, PressureUnit.Pascal) => new Pressure((_value) * 1e9d, PressureUnit.Pascal), - (PressureUnit.Hectopascal, PressureUnit.Pascal) => new Pressure((_value) * 1e2d, PressureUnit.Pascal), - (PressureUnit.InchOfMercury, PressureUnit.Pascal) => new Pressure(_value / 2.95299830714159e-4, PressureUnit.Pascal), - (PressureUnit.InchOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * 249.08890833333, PressureUnit.Pascal), - (PressureUnit.Kilobar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilogramForcePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665e4, PressureUnit.Pascal), - (PressureUnit.KilogramForcePerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665019960652, PressureUnit.Pascal), - (PressureUnit.KilogramForcePerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665e6, PressureUnit.Pascal), - (PressureUnit.KilonewtonPerSquareCentimeter, PressureUnit.Pascal) => new Pressure((_value * 1e4) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilonewtonPerSquareMeter, PressureUnit.Pascal) => new Pressure((_value) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilonewtonPerSquareMillimeter, PressureUnit.Pascal) => new Pressure((_value * 1e6) * 1e3d, PressureUnit.Pascal), - (PressureUnit.Kilopascal, PressureUnit.Pascal) => new Pressure((_value) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilopoundForcePerSquareFoot, PressureUnit.Pascal) => new Pressure((_value * 4.788025898033584e1) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilopoundForcePerSquareInch, PressureUnit.Pascal) => new Pressure((_value * 6.894757293168361e3) * 1e3d, PressureUnit.Pascal), - (PressureUnit.KilopoundForcePerSquareMil, PressureUnit.Pascal) => new Pressure((_value * 6.894757293168361e9) * 1e3d, PressureUnit.Pascal), - (PressureUnit.Megabar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e6d, PressureUnit.Pascal), - (PressureUnit.MeganewtonPerSquareMeter, PressureUnit.Pascal) => new Pressure((_value) * 1e6d, PressureUnit.Pascal), - (PressureUnit.Megapascal, PressureUnit.Pascal) => new Pressure((_value) * 1e6d, PressureUnit.Pascal), - (PressureUnit.MeterOfElevation, PressureUnit.Pascal) => new Pressure(Math.Pow(1.0 - (_value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal), - (PressureUnit.MeterOfHead, PressureUnit.Pascal) => new Pressure(_value * 9804.139432, PressureUnit.Pascal), - (PressureUnit.MeterOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * 9.806650000000272e3, PressureUnit.Pascal), - (PressureUnit.Microbar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e-6d, PressureUnit.Pascal), - (PressureUnit.Micropascal, PressureUnit.Pascal) => new Pressure((_value) * 1e-6d, PressureUnit.Pascal), - (PressureUnit.Millibar, PressureUnit.Pascal) => new Pressure((_value * 1e5) * 1e-3d, PressureUnit.Pascal), - (PressureUnit.MillimeterOfMercury, PressureUnit.Pascal) => new Pressure(_value / 7.50061561302643e-3, PressureUnit.Pascal), - (PressureUnit.MillimeterOfWaterColumn, PressureUnit.Pascal) => new Pressure((_value * 9.806650000000272e3) * 1e-3d, PressureUnit.Pascal), - (PressureUnit.Millipascal, PressureUnit.Pascal) => new Pressure((_value) * 1e-3d, PressureUnit.Pascal), - (PressureUnit.NewtonPerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 1e4, PressureUnit.Pascal), + (PressureUnit.Atmosphere, PressureUnit.Pascal) => new Pressure(_value * 101325, PressureUnit.Pascal), + (PressureUnit.Bar, PressureUnit.Pascal) => new Pressure(_value * 100000, PressureUnit.Pascal), + (PressureUnit.Centibar, PressureUnit.Pascal) => new Pressure(_value * 1000, PressureUnit.Pascal), + (PressureUnit.CentimeterOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(612915625000017, 6250000000000, false), PressureUnit.Pascal), + (PressureUnit.Decapascal, PressureUnit.Pascal) => new Pressure(_value * 10, PressureUnit.Pascal), + (PressureUnit.Decibar, PressureUnit.Pascal) => new Pressure(_value * 10000, PressureUnit.Pascal), + (PressureUnit.DynePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value / 10, PressureUnit.Pascal), + (PressureUnit.FootOfElevation, PressureUnit.Pascal) => new Pressure(QuantityValue.FromDoubleRounded(Math.Pow((_value * new QuantityValue(-20, 2907329, false) + 1).ToDouble(), 5.255302600323726640179941561)) * 101325, PressureUnit.Pascal), + (PressureUnit.FootOfHead, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(29890669, 10000, false), PressureUnit.Pascal), + (PressureUnit.Gigapascal, PressureUnit.Pascal) => new Pressure(_value * 1000000000, PressureUnit.Pascal), + (PressureUnit.Hectopascal, PressureUnit.Pascal) => new Pressure(_value * 100, PressureUnit.Pascal), + (PressureUnit.InchOfMercury, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(1000000000000000000, 295299830714159, false), PressureUnit.Pascal), + (PressureUnit.InchOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(24908890833333, 100000000000, false), PressureUnit.Pascal), + (PressureUnit.Kilobar, PressureUnit.Pascal) => new Pressure(_value * 100000000, PressureUnit.Pascal), + (PressureUnit.KilogramForcePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(196133, 2, false), PressureUnit.Pascal), + (PressureUnit.KilogramForcePerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(245166254990163, 25000000000000, false), PressureUnit.Pascal), + (PressureUnit.KilogramForcePerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 9806650, PressureUnit.Pascal), + (PressureUnit.KilonewtonPerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 10000000, PressureUnit.Pascal), + (PressureUnit.KilonewtonPerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * 1000, PressureUnit.Pascal), + (PressureUnit.KilonewtonPerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 1000000000, PressureUnit.Pascal), + (PressureUnit.Kilopascal, PressureUnit.Pascal) => new Pressure(_value * 1000, PressureUnit.Pascal), + (PressureUnit.KilopoundForcePerSquareFoot, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(299251618627099, 6250000000, false), PressureUnit.Pascal), + (PressureUnit.KilopoundForcePerSquareInch, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(6894757293168361, 1000000000, false), PressureUnit.Pascal), + (PressureUnit.KilopoundForcePerSquareMil, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(6894757293168361, 1000, false), PressureUnit.Pascal), + (PressureUnit.Megabar, PressureUnit.Pascal) => new Pressure(_value * 100000000000, PressureUnit.Pascal), + (PressureUnit.MeganewtonPerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * 1000000, PressureUnit.Pascal), + (PressureUnit.Megapascal, PressureUnit.Pascal) => new Pressure(_value * 1000000, PressureUnit.Pascal), + (PressureUnit.MeterOfElevation, PressureUnit.Pascal) => new Pressure(QuantityValue.FromDoubleRounded(Math.Pow((_value * new QuantityValue(-25000, 1107692349, false) + 1).ToDouble(), 5.255302600323726640179941561)) * 101325, PressureUnit.Pascal), + (PressureUnit.MeterOfHead, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(1225517429, 125000, false), PressureUnit.Pascal), + (PressureUnit.MeterOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(612915625000017, 62500000000, false), PressureUnit.Pascal), + (PressureUnit.Microbar, PressureUnit.Pascal) => new Pressure(_value / 10, PressureUnit.Pascal), + (PressureUnit.Micropascal, PressureUnit.Pascal) => new Pressure(_value / 1000000, PressureUnit.Pascal), + (PressureUnit.Millibar, PressureUnit.Pascal) => new Pressure(_value * 100, PressureUnit.Pascal), + (PressureUnit.MillimeterOfMercury, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(100000000000000000, 750061561302643, false), PressureUnit.Pascal), + (PressureUnit.MillimeterOfWaterColumn, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(612915625000017, 62500000000000, false), PressureUnit.Pascal), + (PressureUnit.Millipascal, PressureUnit.Pascal) => new Pressure(_value / 1000, PressureUnit.Pascal), + (PressureUnit.NewtonPerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 10000, PressureUnit.Pascal), (PressureUnit.NewtonPerSquareMeter, PressureUnit.Pascal) => new Pressure(_value, PressureUnit.Pascal), - (PressureUnit.NewtonPerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 1e6, PressureUnit.Pascal), - (PressureUnit.PoundForcePerSquareFoot, PressureUnit.Pascal) => new Pressure(_value * 4.788025898033584e1, PressureUnit.Pascal), - (PressureUnit.PoundForcePerSquareInch, PressureUnit.Pascal) => new Pressure(_value * 6.894757293168361e3, PressureUnit.Pascal), - (PressureUnit.PoundForcePerSquareMil, PressureUnit.Pascal) => new Pressure(_value * 6.894757293168361e9, PressureUnit.Pascal), - (PressureUnit.PoundPerInchSecondSquared, PressureUnit.Pascal) => new Pressure(_value * 1.785796732283465e1, PressureUnit.Pascal), - (PressureUnit.TechnicalAtmosphere, PressureUnit.Pascal) => new Pressure(_value * 9.80680592331 * 1e4, PressureUnit.Pascal), - (PressureUnit.TonneForcePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665e7, PressureUnit.Pascal), - (PressureUnit.TonneForcePerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665e3, PressureUnit.Pascal), - (PressureUnit.TonneForcePerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 9.80665e9, PressureUnit.Pascal), - (PressureUnit.Torr, PressureUnit.Pascal) => new Pressure(_value * 1.3332266752 * 1e2, PressureUnit.Pascal), + (PressureUnit.NewtonPerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 1000000, PressureUnit.Pascal), + (PressureUnit.PoundForcePerSquareFoot, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(299251618627099, 6250000000000, false), PressureUnit.Pascal), + (PressureUnit.PoundForcePerSquareInch, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(6894757293168361, 1000000000000, false), PressureUnit.Pascal), + (PressureUnit.PoundForcePerSquareMil, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(6894757293168361, 1000000, false), PressureUnit.Pascal), + (PressureUnit.PoundPerInchSecondSquared, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(357159346456693, 20000000000000, false), PressureUnit.Pascal), + (PressureUnit.TechnicalAtmosphere, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(980680592331, 10000000, false), PressureUnit.Pascal), + (PressureUnit.TonneForcePerSquareCentimeter, PressureUnit.Pascal) => new Pressure(_value * 98066500, PressureUnit.Pascal), + (PressureUnit.TonneForcePerSquareMeter, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(196133, 20, false), PressureUnit.Pascal), + (PressureUnit.TonneForcePerSquareMillimeter, PressureUnit.Pascal) => new Pressure(_value * 9806650000, PressureUnit.Pascal), + (PressureUnit.Torr, PressureUnit.Pascal) => new Pressure(_value * new QuantityValue(52079167, 390625, false), PressureUnit.Pascal), // BaseUnit -> PressureUnit - (PressureUnit.Pascal, PressureUnit.Atmosphere) => new Pressure(_value / (1.01325 * 1e5), PressureUnit.Atmosphere), - (PressureUnit.Pascal, PressureUnit.Bar) => new Pressure(_value / 1e5, PressureUnit.Bar), - (PressureUnit.Pascal, PressureUnit.Centibar) => new Pressure((_value / 1e5) / 1e-2d, PressureUnit.Centibar), - (PressureUnit.Pascal, PressureUnit.CentimeterOfWaterColumn) => new Pressure((_value / 9.806650000000272e3) / 1e-2d, PressureUnit.CentimeterOfWaterColumn), - (PressureUnit.Pascal, PressureUnit.Decapascal) => new Pressure((_value) / 1e1d, PressureUnit.Decapascal), - (PressureUnit.Pascal, PressureUnit.Decibar) => new Pressure((_value / 1e5) / 1e-1d, PressureUnit.Decibar), - (PressureUnit.Pascal, PressureUnit.DynePerSquareCentimeter) => new Pressure(_value / 1.0e-1, PressureUnit.DynePerSquareCentimeter), - (PressureUnit.Pascal, PressureUnit.FootOfElevation) => new Pressure((1.0 - Math.Pow(_value / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfElevation), - (PressureUnit.Pascal, PressureUnit.FootOfHead) => new Pressure(_value * 0.000334552565551, PressureUnit.FootOfHead), - (PressureUnit.Pascal, PressureUnit.Gigapascal) => new Pressure((_value) / 1e9d, PressureUnit.Gigapascal), - (PressureUnit.Pascal, PressureUnit.Hectopascal) => new Pressure((_value) / 1e2d, PressureUnit.Hectopascal), - (PressureUnit.Pascal, PressureUnit.InchOfMercury) => new Pressure(_value * 2.95299830714159e-4, PressureUnit.InchOfMercury), - (PressureUnit.Pascal, PressureUnit.InchOfWaterColumn) => new Pressure(_value / 249.08890833333, PressureUnit.InchOfWaterColumn), - (PressureUnit.Pascal, PressureUnit.Kilobar) => new Pressure((_value / 1e5) / 1e3d, PressureUnit.Kilobar), - (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareCentimeter) => new Pressure(_value / 9.80665e4, PressureUnit.KilogramForcePerSquareCentimeter), - (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareMeter) => new Pressure(_value * 0.101971619222242, PressureUnit.KilogramForcePerSquareMeter), - (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareMillimeter) => new Pressure(_value / 9.80665e6, PressureUnit.KilogramForcePerSquareMillimeter), - (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareCentimeter) => new Pressure((_value / 1e4) / 1e3d, PressureUnit.KilonewtonPerSquareCentimeter), - (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareMeter) => new Pressure((_value) / 1e3d, PressureUnit.KilonewtonPerSquareMeter), - (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareMillimeter) => new Pressure((_value / 1e6) / 1e3d, PressureUnit.KilonewtonPerSquareMillimeter), - (PressureUnit.Pascal, PressureUnit.Kilopascal) => new Pressure((_value) / 1e3d, PressureUnit.Kilopascal), - (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareFoot) => new Pressure((_value / 4.788025898033584e1) / 1e3d, PressureUnit.KilopoundForcePerSquareFoot), - (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareInch) => new Pressure((_value / 6.894757293168361e3) / 1e3d, PressureUnit.KilopoundForcePerSquareInch), - (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareMil) => new Pressure((_value / 6.894757293168361e9) / 1e3d, PressureUnit.KilopoundForcePerSquareMil), - (PressureUnit.Pascal, PressureUnit.Megabar) => new Pressure((_value / 1e5) / 1e6d, PressureUnit.Megabar), - (PressureUnit.Pascal, PressureUnit.MeganewtonPerSquareMeter) => new Pressure((_value) / 1e6d, PressureUnit.MeganewtonPerSquareMeter), - (PressureUnit.Pascal, PressureUnit.Megapascal) => new Pressure((_value) / 1e6d, PressureUnit.Megapascal), - (PressureUnit.Pascal, PressureUnit.MeterOfElevation) => new Pressure((1.0 - Math.Pow(_value / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfElevation), - (PressureUnit.Pascal, PressureUnit.MeterOfHead) => new Pressure(_value * 0.0001019977334, PressureUnit.MeterOfHead), - (PressureUnit.Pascal, PressureUnit.MeterOfWaterColumn) => new Pressure(_value / 9.806650000000272e3, PressureUnit.MeterOfWaterColumn), - (PressureUnit.Pascal, PressureUnit.Microbar) => new Pressure((_value / 1e5) / 1e-6d, PressureUnit.Microbar), - (PressureUnit.Pascal, PressureUnit.Micropascal) => new Pressure((_value) / 1e-6d, PressureUnit.Micropascal), - (PressureUnit.Pascal, PressureUnit.Millibar) => new Pressure((_value / 1e5) / 1e-3d, PressureUnit.Millibar), - (PressureUnit.Pascal, PressureUnit.MillimeterOfMercury) => new Pressure(_value * 7.50061561302643e-3, PressureUnit.MillimeterOfMercury), - (PressureUnit.Pascal, PressureUnit.MillimeterOfWaterColumn) => new Pressure((_value / 9.806650000000272e3) / 1e-3d, PressureUnit.MillimeterOfWaterColumn), - (PressureUnit.Pascal, PressureUnit.Millipascal) => new Pressure((_value) / 1e-3d, PressureUnit.Millipascal), - (PressureUnit.Pascal, PressureUnit.NewtonPerSquareCentimeter) => new Pressure(_value / 1e4, PressureUnit.NewtonPerSquareCentimeter), + (PressureUnit.Pascal, PressureUnit.Atmosphere) => new Pressure(_value / 101325, PressureUnit.Atmosphere), + (PressureUnit.Pascal, PressureUnit.Bar) => new Pressure(_value / 100000, PressureUnit.Bar), + (PressureUnit.Pascal, PressureUnit.Centibar) => new Pressure(_value / 1000, PressureUnit.Centibar), + (PressureUnit.Pascal, PressureUnit.CentimeterOfWaterColumn) => new Pressure(_value * new QuantityValue(6250000000000, 612915625000017, false), PressureUnit.CentimeterOfWaterColumn), + (PressureUnit.Pascal, PressureUnit.Decapascal) => new Pressure(_value / 10, PressureUnit.Decapascal), + (PressureUnit.Pascal, PressureUnit.Decibar) => new Pressure(_value / 10000, PressureUnit.Decibar), + (PressureUnit.Pascal, PressureUnit.DynePerSquareCentimeter) => new Pressure(_value * 10, PressureUnit.DynePerSquareCentimeter), + (PressureUnit.Pascal, PressureUnit.FootOfElevation) => new Pressure(QuantityValue.FromDoubleRounded(Math.Pow((_value / 101325).ToDouble(), 0.190284)) * new QuantityValue(-2907329, 20, false) + new QuantityValue(2907329, 20, false), PressureUnit.FootOfElevation), + (PressureUnit.Pascal, PressureUnit.FootOfHead) => new Pressure(_value * new QuantityValue(334552565551, 1000000000000000, false), PressureUnit.FootOfHead), + (PressureUnit.Pascal, PressureUnit.Gigapascal) => new Pressure(_value / 1000000000, PressureUnit.Gigapascal), + (PressureUnit.Pascal, PressureUnit.Hectopascal) => new Pressure(_value / 100, PressureUnit.Hectopascal), + (PressureUnit.Pascal, PressureUnit.InchOfMercury) => new Pressure(_value * new QuantityValue(295299830714159, 1000000000000000000, false), PressureUnit.InchOfMercury), + (PressureUnit.Pascal, PressureUnit.InchOfWaterColumn) => new Pressure(_value * new QuantityValue(100000000000, 24908890833333, false), PressureUnit.InchOfWaterColumn), + (PressureUnit.Pascal, PressureUnit.Kilobar) => new Pressure(_value / 100000000, PressureUnit.Kilobar), + (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareCentimeter) => new Pressure(_value * new QuantityValue(2, 196133, false), PressureUnit.KilogramForcePerSquareCentimeter), + (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareMeter) => new Pressure(_value * new QuantityValue(50985809611121, 500000000000000, false), PressureUnit.KilogramForcePerSquareMeter), + (PressureUnit.Pascal, PressureUnit.KilogramForcePerSquareMillimeter) => new Pressure(_value / 9806650, PressureUnit.KilogramForcePerSquareMillimeter), + (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareCentimeter) => new Pressure(_value / 10000000, PressureUnit.KilonewtonPerSquareCentimeter), + (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareMeter) => new Pressure(_value / 1000, PressureUnit.KilonewtonPerSquareMeter), + (PressureUnit.Pascal, PressureUnit.KilonewtonPerSquareMillimeter) => new Pressure(_value / 1000000000, PressureUnit.KilonewtonPerSquareMillimeter), + (PressureUnit.Pascal, PressureUnit.Kilopascal) => new Pressure(_value / 1000, PressureUnit.Kilopascal), + (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareFoot) => new Pressure(_value * new QuantityValue(6250000000, 299251618627099, false), PressureUnit.KilopoundForcePerSquareFoot), + (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareInch) => new Pressure(_value * new QuantityValue(1000000000, 6894757293168361, false), PressureUnit.KilopoundForcePerSquareInch), + (PressureUnit.Pascal, PressureUnit.KilopoundForcePerSquareMil) => new Pressure(_value * new QuantityValue(1000, 6894757293168361, false), PressureUnit.KilopoundForcePerSquareMil), + (PressureUnit.Pascal, PressureUnit.Megabar) => new Pressure(_value / 100000000000, PressureUnit.Megabar), + (PressureUnit.Pascal, PressureUnit.MeganewtonPerSquareMeter) => new Pressure(_value / 1000000, PressureUnit.MeganewtonPerSquareMeter), + (PressureUnit.Pascal, PressureUnit.Megapascal) => new Pressure(_value / 1000000, PressureUnit.Megapascal), + (PressureUnit.Pascal, PressureUnit.MeterOfElevation) => new Pressure(QuantityValue.FromDoubleRounded(Math.Pow((_value / 101325).ToDouble(), 0.190284)) * new QuantityValue(-1107692349, 25000, false) + new QuantityValue(1107692349, 25000, false), PressureUnit.MeterOfElevation), + (PressureUnit.Pascal, PressureUnit.MeterOfHead) => new Pressure(_value * new QuantityValue(509988667, 5000000000000, false), PressureUnit.MeterOfHead), + (PressureUnit.Pascal, PressureUnit.MeterOfWaterColumn) => new Pressure(_value * new QuantityValue(62500000000, 612915625000017, false), PressureUnit.MeterOfWaterColumn), + (PressureUnit.Pascal, PressureUnit.Microbar) => new Pressure(_value * 10, PressureUnit.Microbar), + (PressureUnit.Pascal, PressureUnit.Micropascal) => new Pressure(_value * 1000000, PressureUnit.Micropascal), + (PressureUnit.Pascal, PressureUnit.Millibar) => new Pressure(_value / 100, PressureUnit.Millibar), + (PressureUnit.Pascal, PressureUnit.MillimeterOfMercury) => new Pressure(_value * new QuantityValue(750061561302643, 100000000000000000, false), PressureUnit.MillimeterOfMercury), + (PressureUnit.Pascal, PressureUnit.MillimeterOfWaterColumn) => new Pressure(_value * new QuantityValue(62500000000000, 612915625000017, false), PressureUnit.MillimeterOfWaterColumn), + (PressureUnit.Pascal, PressureUnit.Millipascal) => new Pressure(_value * 1000, PressureUnit.Millipascal), + (PressureUnit.Pascal, PressureUnit.NewtonPerSquareCentimeter) => new Pressure(_value / 10000, PressureUnit.NewtonPerSquareCentimeter), (PressureUnit.Pascal, PressureUnit.NewtonPerSquareMeter) => new Pressure(_value, PressureUnit.NewtonPerSquareMeter), - (PressureUnit.Pascal, PressureUnit.NewtonPerSquareMillimeter) => new Pressure(_value / 1e6, PressureUnit.NewtonPerSquareMillimeter), - (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareFoot) => new Pressure(_value / 4.788025898033584e1, PressureUnit.PoundForcePerSquareFoot), - (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareInch) => new Pressure(_value / 6.894757293168361e3, PressureUnit.PoundForcePerSquareInch), - (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareMil) => new Pressure(_value / 6.894757293168361e9, PressureUnit.PoundForcePerSquareMil), - (PressureUnit.Pascal, PressureUnit.PoundPerInchSecondSquared) => new Pressure(_value / 1.785796732283465e1, PressureUnit.PoundPerInchSecondSquared), - (PressureUnit.Pascal, PressureUnit.TechnicalAtmosphere) => new Pressure(_value / (9.80680592331 * 1e4), PressureUnit.TechnicalAtmosphere), - (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareCentimeter) => new Pressure(_value / 9.80665e7, PressureUnit.TonneForcePerSquareCentimeter), - (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMeter) => new Pressure(_value / 9.80665e3, PressureUnit.TonneForcePerSquareMeter), - (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMillimeter) => new Pressure(_value / 9.80665e9, PressureUnit.TonneForcePerSquareMillimeter), - (PressureUnit.Pascal, PressureUnit.Torr) => new Pressure(_value / (1.3332266752 * 1e2), PressureUnit.Torr), + (PressureUnit.Pascal, PressureUnit.NewtonPerSquareMillimeter) => new Pressure(_value / 1000000, PressureUnit.NewtonPerSquareMillimeter), + (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareFoot) => new Pressure(_value * new QuantityValue(6250000000000, 299251618627099, false), PressureUnit.PoundForcePerSquareFoot), + (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareInch) => new Pressure(_value * new QuantityValue(1000000000000, 6894757293168361, false), PressureUnit.PoundForcePerSquareInch), + (PressureUnit.Pascal, PressureUnit.PoundForcePerSquareMil) => new Pressure(_value * new QuantityValue(1000000, 6894757293168361, false), PressureUnit.PoundForcePerSquareMil), + (PressureUnit.Pascal, PressureUnit.PoundPerInchSecondSquared) => new Pressure(_value * new QuantityValue(20000000000000, 357159346456693, false), PressureUnit.PoundPerInchSecondSquared), + (PressureUnit.Pascal, PressureUnit.TechnicalAtmosphere) => new Pressure(_value * new QuantityValue(10000000, 980680592331, false), PressureUnit.TechnicalAtmosphere), + (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareCentimeter) => new Pressure(_value / 98066500, PressureUnit.TonneForcePerSquareCentimeter), + (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMeter) => new Pressure(_value * new QuantityValue(20, 196133, false), PressureUnit.TonneForcePerSquareMeter), + (PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMillimeter) => new Pressure(_value / 9806650000, PressureUnit.TonneForcePerSquareMillimeter), + (PressureUnit.Pascal, PressureUnit.Torr) => new Pressure(_value * new QuantityValue(390625, 52079167, false), PressureUnit.Torr), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 79c0e35242..545910255f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -101,7 +99,7 @@ static PressureChangeRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public PressureChangeRate(double value, PressureChangeRateUnit unit) + public PressureChangeRate(QuantityValue value, PressureChangeRateUnit unit) { _value = value; _unit = unit; @@ -115,7 +113,7 @@ public PressureChangeRate(double value, PressureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PressureChangeRate(double value, UnitSystem unitSystem) + public PressureChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -166,10 +164,10 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,92 +192,92 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); + public QuantityValue AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); /// /// Gets a value of this quantity converted into /// - public double BarsPerMinute => As(PressureChangeRateUnit.BarPerMinute); + public QuantityValue BarsPerMinute => As(PressureChangeRateUnit.BarPerMinute); /// /// Gets a value of this quantity converted into /// - public double BarsPerSecond => As(PressureChangeRateUnit.BarPerSecond); + public QuantityValue BarsPerSecond => As(PressureChangeRateUnit.BarPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); + public QuantityValue KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); + public QuantityValue KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); + public QuantityValue KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); + public QuantityValue KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); + public QuantityValue MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); /// /// Gets a value of this quantity converted into /// - public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); + public QuantityValue MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); + public QuantityValue MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); /// /// Gets a value of this quantity converted into /// - public double MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); + public QuantityValue MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillibarsPerMinute => As(PressureChangeRateUnit.MillibarPerMinute); + public QuantityValue MillibarsPerMinute => As(PressureChangeRateUnit.MillibarPerMinute); /// /// Gets a value of this quantity converted into /// - public double MillibarsPerSecond => As(PressureChangeRateUnit.MillibarPerSecond); + public QuantityValue MillibarsPerSecond => As(PressureChangeRateUnit.MillibarPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); + public QuantityValue MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); /// /// Gets a value of this quantity converted into /// - public double PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); + public QuantityValue PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); /// /// Gets a value of this quantity converted into /// - public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); + public QuantityValue PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); + public QuantityValue PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); + public QuantityValue PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); #endregion @@ -361,7 +359,7 @@ public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvide /// /// Creates a from . /// - public static PressureChangeRate FromAtmospheresPerSecond(double value) + public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond); } @@ -369,7 +367,7 @@ public static PressureChangeRate FromAtmospheresPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromBarsPerMinute(double value) + public static PressureChangeRate FromBarsPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.BarPerMinute); } @@ -377,7 +375,7 @@ public static PressureChangeRate FromBarsPerMinute(double value) /// /// Creates a from . /// - public static PressureChangeRate FromBarsPerSecond(double value) + public static PressureChangeRate FromBarsPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.BarPerSecond); } @@ -385,7 +383,7 @@ public static PressureChangeRate FromBarsPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromKilopascalsPerMinute(double value) + public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerMinute); } @@ -393,7 +391,7 @@ public static PressureChangeRate FromKilopascalsPerMinute(double value) /// /// Creates a from . /// - public static PressureChangeRate FromKilopascalsPerSecond(double value) + public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond); } @@ -401,7 +399,7 @@ public static PressureChangeRate FromKilopascalsPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(double value) + public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); } @@ -409,7 +407,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(doubl /// /// Creates a from . /// - public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(double value) + public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); } @@ -417,7 +415,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(doubl /// /// Creates a from . /// - public static PressureChangeRate FromMegapascalsPerMinute(double value) + public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerMinute); } @@ -425,7 +423,7 @@ public static PressureChangeRate FromMegapascalsPerMinute(double value) /// /// Creates a from . /// - public static PressureChangeRate FromMegapascalsPerSecond(double value) + public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond); } @@ -433,7 +431,7 @@ public static PressureChangeRate FromMegapascalsPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(double value) + public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); } @@ -441,7 +439,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(doubl /// /// Creates a from . /// - public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(double value) + public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); } @@ -449,7 +447,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(doubl /// /// Creates a from . /// - public static PressureChangeRate FromMillibarsPerMinute(double value) + public static PressureChangeRate FromMillibarsPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MillibarPerMinute); } @@ -457,7 +455,7 @@ public static PressureChangeRate FromMillibarsPerMinute(double value) /// /// Creates a from . /// - public static PressureChangeRate FromMillibarsPerSecond(double value) + public static PressureChangeRate FromMillibarsPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MillibarPerSecond); } @@ -465,7 +463,7 @@ public static PressureChangeRate FromMillibarsPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromMillimetersOfMercuryPerSecond(double value) + public static PressureChangeRate FromMillimetersOfMercuryPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.MillimeterOfMercuryPerSecond); } @@ -473,7 +471,7 @@ public static PressureChangeRate FromMillimetersOfMercuryPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromPascalsPerMinute(double value) + public static PressureChangeRate FromPascalsPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerMinute); } @@ -481,7 +479,7 @@ public static PressureChangeRate FromPascalsPerMinute(double value) /// /// Creates a from . /// - public static PressureChangeRate FromPascalsPerSecond(double value) + public static PressureChangeRate FromPascalsPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond); } @@ -489,7 +487,7 @@ public static PressureChangeRate FromPascalsPerSecond(double value) /// /// Creates a from . /// - public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(double value) + public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); } @@ -497,7 +495,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(double va /// /// Creates a from . /// - public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(double value) + public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(QuantityValue value) { return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); } @@ -508,7 +506,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(double va /// Value to convert from. /// Unit to convert from. /// PressureChangeRate unit value. - public static PressureChangeRate From(double value, PressureChangeRateUnit fromUnit) + public static PressureChangeRate From(QuantityValue value, PressureChangeRateUnit fromUnit) { return new PressureChangeRate(value, fromUnit); } @@ -680,25 +678,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static PressureChangeRate operator *(double left, PressureChangeRate right) + public static PressureChangeRate operator *(QuantityValue left, PressureChangeRate right) { return new PressureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PressureChangeRate operator *(PressureChangeRate left, double right) + public static PressureChangeRate operator *(PressureChangeRate left, QuantityValue right) { return new PressureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PressureChangeRate operator /(PressureChangeRate left, double right) + public static PressureChangeRate operator /(PressureChangeRate left, QuantityValue right) { return new PressureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PressureChangeRate left, PressureChangeRate right) + public static QuantityValue operator /(PressureChangeRate left, PressureChangeRate right) { return left.PascalsPerSecond / right.PascalsPerSecond; } @@ -741,27 +739,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(PressureChangeRate left, PressureChangeRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(PressureChangeRate other, PressureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(PressureChangeRate left, PressureChangeRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is PressureChangeRate otherQuantity)) @@ -771,15 +762,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(PressureChangeRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -862,10 +850,10 @@ public bool Equals(PressureChangeRate other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -882,7 +870,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(PressureChangeRate other, PressureChangeRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -895,7 +883,12 @@ public bool Equals(PressureChangeRate other, PressureChangeRate tolerance) /// A hash code for the current PressureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -906,7 +899,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureChangeRateUnit unit) + public QuantityValue As(PressureChangeRateUnit unit) { if (Unit == unit) return Value; @@ -915,7 +908,7 @@ public double As(PressureChangeRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -930,7 +923,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); @@ -996,42 +989,42 @@ private bool TryToUnit(PressureChangeRateUnit unit, [NotNullWhen(true)] out Pres PressureChangeRate? convertedOrNull = (Unit, unit) switch { // PressureChangeRateUnit -> BaseUnit - (PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 1.01325 * 1e5, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.BarPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 1e5 / 60, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.BarPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 1e5, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value / 60) * 1e3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value) * 1e3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 6.894757293168361e3 / 60) * 1e3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 6.894757293168361e3) * 1e3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value / 60) * 1e6d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value) * 1e6d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 6.894757293168361e3 / 60) * 1e6d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 6.894757293168361e3) * 1e6d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MillibarPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 1e5 / 60) * 1e-3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MillibarPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate((_value * 1e5) * 1e-3d, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.MillimeterOfMercuryPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 133.322, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 101325, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.BarPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(5000, 3, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.BarPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 100000, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(50, 3, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 1000, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 60000000000, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 1000000000, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(50000, 3, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 1000000, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 60000000, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 1000000, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MillibarPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(5, 3, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MillibarPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 100, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.MillimeterOfMercuryPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(66661, 500, false), PressureChangeRateUnit.PascalPerSecond), (PressureChangeRateUnit.PascalPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value / 60, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 6.894757293168361e3 / 60, PressureChangeRateUnit.PascalPerSecond), - (PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * 6.894757293168361e3, PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 60000000000000, false), PressureChangeRateUnit.PascalPerSecond), + (PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, PressureChangeRateUnit.PascalPerSecond) => new PressureChangeRate(_value * new QuantityValue(6894757293168361, 1000000000000, false), PressureChangeRateUnit.PascalPerSecond), // BaseUnit -> PressureChangeRateUnit - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.AtmospherePerSecond) => new PressureChangeRate(_value / (1.01325 * 1e5), PressureChangeRateUnit.AtmospherePerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.BarPerMinute) => new PressureChangeRate(_value / 1e5 * 60, PressureChangeRateUnit.BarPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.BarPerSecond) => new PressureChangeRate(_value / 1e5, PressureChangeRateUnit.BarPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopascalPerMinute) => new PressureChangeRate((_value * 60) / 1e3d, PressureChangeRateUnit.KilopascalPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopascalPerSecond) => new PressureChangeRate((_value) / 1e3d, PressureChangeRateUnit.KilopascalPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute) => new PressureChangeRate((_value / 6.894757293168361e3 * 60) / 1e3d, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond) => new PressureChangeRate((_value / 6.894757293168361e3) / 1e3d, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapascalPerMinute) => new PressureChangeRate((_value * 60) / 1e6d, PressureChangeRateUnit.MegapascalPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapascalPerSecond) => new PressureChangeRate((_value) / 1e6d, PressureChangeRateUnit.MegapascalPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute) => new PressureChangeRate((_value / 6.894757293168361e3 * 60) / 1e6d, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond) => new PressureChangeRate((_value / 6.894757293168361e3) / 1e6d, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillibarPerMinute) => new PressureChangeRate((_value / 1e5 * 60) / 1e-3d, PressureChangeRateUnit.MillibarPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillibarPerSecond) => new PressureChangeRate((_value / 1e5) / 1e-3d, PressureChangeRateUnit.MillibarPerSecond), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillimeterOfMercuryPerSecond) => new PressureChangeRate(_value / 133.322, PressureChangeRateUnit.MillimeterOfMercuryPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.AtmospherePerSecond) => new PressureChangeRate(_value / 101325, PressureChangeRateUnit.AtmospherePerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.BarPerMinute) => new PressureChangeRate(_value * new QuantityValue(3, 5000, false), PressureChangeRateUnit.BarPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.BarPerSecond) => new PressureChangeRate(_value / 100000, PressureChangeRateUnit.BarPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopascalPerMinute) => new PressureChangeRate(_value * new QuantityValue(3, 50, false), PressureChangeRateUnit.KilopascalPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopascalPerSecond) => new PressureChangeRate(_value / 1000, PressureChangeRateUnit.KilopascalPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute) => new PressureChangeRate(_value * new QuantityValue(60000000000, 6894757293168361, false), PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond) => new PressureChangeRate(_value * new QuantityValue(1000000000, 6894757293168361, false), PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapascalPerMinute) => new PressureChangeRate(_value * new QuantityValue(3, 50000, false), PressureChangeRateUnit.MegapascalPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapascalPerSecond) => new PressureChangeRate(_value / 1000000, PressureChangeRateUnit.MegapascalPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute) => new PressureChangeRate(_value * new QuantityValue(60000000, 6894757293168361, false), PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond) => new PressureChangeRate(_value * new QuantityValue(1000000, 6894757293168361, false), PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillibarPerMinute) => new PressureChangeRate(_value * new QuantityValue(3, 5, false), PressureChangeRateUnit.MillibarPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillibarPerSecond) => new PressureChangeRate(_value / 100, PressureChangeRateUnit.MillibarPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.MillimeterOfMercuryPerSecond) => new PressureChangeRate(_value * new QuantityValue(500, 66661, false), PressureChangeRateUnit.MillimeterOfMercuryPerSecond), (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PascalPerMinute) => new PressureChangeRate(_value * 60, PressureChangeRateUnit.PascalPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute) => new PressureChangeRate(_value / 6.894757293168361e3 * 60, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute), - (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond) => new PressureChangeRate(_value / 6.894757293168361e3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute) => new PressureChangeRate(_value * new QuantityValue(60000000000000, 6894757293168361, false), PressureChangeRateUnit.PoundForcePerSquareInchPerMinute), + (PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond) => new PressureChangeRate(_value * new QuantityValue(1000000000000, 6894757293168361, false), PressureChangeRateUnit.PoundForcePerSquareInchPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs new file mode 100644 index 0000000000..dba64240bd --- /dev/null +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDose.g.cs @@ -0,0 +1,992 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; +using System.Runtime.Serialization; +using UnitsNet.InternalHelpers; +using UnitsNet.Units; +using System.Numerics; + +#nullable enable + +// ReSharper disable once CheckNamespace + +namespace UnitsNet +{ + /// + /// + /// Equivalent dose is a dose quantity representing the stochastic health effects of low levels of ionizing radiation on the human body which represents the probability of radiation-induced cancer and genetic damage. + /// + [DataContract] + public readonly partial struct RadiationEquivalentDose : + IArithmeticQuantity, + IComparable, + IComparable, + IConvertible, + IEquatable, + IFormattable + { + /// + /// The numeric value this quantity was constructed with. + /// + [DataMember(Name = "Value", Order = 1)] + private readonly QuantityValue _value; + + /// + /// The unit this quantity was constructed with. + /// + [DataMember(Name = "Unit", Order = 2)] + private readonly RadiationEquivalentDoseUnit? _unit; + + static RadiationEquivalentDose() + { + BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); + BaseUnit = RadiationEquivalentDoseUnit.Sievert; + Units = Enum.GetValues(typeof(RadiationEquivalentDoseUnit)).Cast().ToArray(); + Zero = new RadiationEquivalentDose(0, BaseUnit); + Info = new QuantityInfo("RadiationEquivalentDose", + new UnitInfo[] + { + new UnitInfo(RadiationEquivalentDoseUnit.Microsievert, "Microsieverts", BaseUnits.Undefined, "RadiationEquivalentDose"), + new UnitInfo(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, "MilliroentgensEquivalentMan", BaseUnits.Undefined, "RadiationEquivalentDose"), + new UnitInfo(RadiationEquivalentDoseUnit.Millisievert, "Millisieverts", BaseUnits.Undefined, "RadiationEquivalentDose"), + new UnitInfo(RadiationEquivalentDoseUnit.Nanosievert, "Nanosieverts", BaseUnits.Undefined, "RadiationEquivalentDose"), + new UnitInfo(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, "RoentgensEquivalentMan", BaseUnits.Undefined, "RadiationEquivalentDose"), + new UnitInfo(RadiationEquivalentDoseUnit.Sievert, "Sieverts", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second), "RadiationEquivalentDose"), + }, + BaseUnit, Zero, BaseDimensions); + + DefaultConversionFunctions = new UnitConverter(); + RegisterDefaultConversions(DefaultConversionFunctions); + } + + /// + /// Creates the quantity with the given numeric value and unit. + /// + /// The numeric value to construct this quantity with. + /// The unit representation to construct this quantity with. + public RadiationEquivalentDose(QuantityValue value, RadiationEquivalentDoseUnit unit) + { + _value = value; + _unit = unit; + } + + /// + /// Creates an instance of the quantity with the given numeric value in units compatible with the given . + /// If multiple compatible units were found, the first match is used. + /// + /// The numeric value to construct this quantity with. + /// The unit system to create the quantity with. + /// The given is null. + /// No unit was found for the given . + public RadiationEquivalentDose(QuantityValue value, UnitSystem unitSystem) + { + if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + var firstUnitInfo = unitInfos.FirstOrDefault(); + + _value = value; + _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + } + + #region Static Properties + + /// + /// The containing the default generated conversion functions for instances. + /// + public static UnitConverter DefaultConversionFunctions { get; } + + /// + public static QuantityInfo Info { get; } + + /// + /// The of this quantity. + /// + public static BaseDimensions BaseDimensions { get; } + + /// + /// The base unit of RadiationEquivalentDose, which is Sievert. All conversions go via this value. + /// + public static RadiationEquivalentDoseUnit BaseUnit { get; } + + /// + /// All units of measurement for the RadiationEquivalentDose quantity. + /// + public static RadiationEquivalentDoseUnit[] Units { get; } + + /// + /// Gets an instance of this quantity with a value of 0 in the base unit Sievert. + /// + public static RadiationEquivalentDose Zero { get; } + + /// + public static RadiationEquivalentDose AdditiveIdentity => Zero; + + #endregion + + #region Properties + + /// + /// The numeric value this quantity was constructed with. + /// + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; + + Enum IQuantity.Unit => Unit; + + /// + public RadiationEquivalentDoseUnit Unit => _unit.GetValueOrDefault(BaseUnit); + + /// + public QuantityInfo QuantityInfo => Info; + + /// + QuantityInfo IQuantity.QuantityInfo => Info; + + /// + /// The of this quantity. + /// + public BaseDimensions Dimensions => RadiationEquivalentDose.BaseDimensions; + + #endregion + + #region Conversion Properties + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue Microsieverts => As(RadiationEquivalentDoseUnit.Microsievert); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue MilliroentgensEquivalentMan => As(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue Millisieverts => As(RadiationEquivalentDoseUnit.Millisievert); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue Nanosieverts => As(RadiationEquivalentDoseUnit.Nanosievert); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue RoentgensEquivalentMan => As(RadiationEquivalentDoseUnit.RoentgenEquivalentMan); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue Sieverts => As(RadiationEquivalentDoseUnit.Sievert); + + #endregion + + #region Static Methods + + /// + /// Registers the default conversion functions in the given instance. + /// + /// The to register the default conversion functions in. + internal static void RegisterDefaultConversions(UnitConverter unitConverter) + { + // Register in unit converter: RadiationEquivalentDoseUnit -> BaseUnit + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Microsievert, RadiationEquivalentDoseUnit.Sievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Sievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, RadiationEquivalentDoseUnit.Sievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Sievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Millisievert, RadiationEquivalentDoseUnit.Sievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Sievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Nanosievert, RadiationEquivalentDoseUnit.Sievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Sievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.RoentgenEquivalentMan, RadiationEquivalentDoseUnit.Sievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Sievert)); + + // Register in unit converter: BaseUnit <-> BaseUnit + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Sievert, quantity => quantity); + + // Register in unit converter: BaseUnit -> RadiationEquivalentDoseUnit + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Microsievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Microsievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Millisievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Millisievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Nanosievert, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.Nanosievert)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.RoentgenEquivalentMan, quantity => quantity.ToUnit(RadiationEquivalentDoseUnit.RoentgenEquivalentMan)); + } + + /// + /// Get unit abbreviation string. + /// + /// Unit to get abbreviation for. + /// Unit abbreviation string. + public static string GetAbbreviation(RadiationEquivalentDoseUnit unit) + { + return GetAbbreviation(unit, null); + } + + /// + /// Get unit abbreviation string. + /// + /// Unit to get abbreviation for. + /// Unit abbreviation string. + /// Format to use for localization. Defaults to if null. + public static string GetAbbreviation(RadiationEquivalentDoseUnit unit, IFormatProvider? provider) + { + return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); + } + + #endregion + + #region Static Factory Methods + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMicrosieverts(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.Microsievert); + } + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMilliroentgensEquivalentMan(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan); + } + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromMillisieverts(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.Millisievert); + } + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromNanosieverts(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.Nanosievert); + } + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromRoentgensEquivalentMan(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.RoentgenEquivalentMan); + } + + /// + /// Creates a from . + /// + public static RadiationEquivalentDose FromSieverts(QuantityValue value) + { + return new RadiationEquivalentDose(value, RadiationEquivalentDoseUnit.Sievert); + } + + /// + /// Dynamically convert from value and unit enum to . + /// + /// Value to convert from. + /// Unit to convert from. + /// RadiationEquivalentDose unit value. + public static RadiationEquivalentDose From(QuantityValue value, RadiationEquivalentDoseUnit fromUnit) + { + return new RadiationEquivalentDose(value, fromUnit); + } + + #endregion + + #region Static Parse Methods + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// + /// Expected string to have one or two pairs of quantity and unit in the format + /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" + /// + /// + /// More than one unit is represented by the specified unit abbreviation. + /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of + /// , and . + /// + /// + /// If anything else goes wrong, typically due to a bug or unhandled case. + /// We wrap exceptions in to allow you to distinguish + /// Units.NET exceptions from other exceptions. + /// + public static RadiationEquivalentDose Parse(string str) + { + return Parse(str, null); + } + + /// + /// Parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// + /// Expected string to have one or two pairs of quantity and unit in the format + /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" + /// + /// + /// More than one unit is represented by the specified unit abbreviation. + /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of + /// , and . + /// + /// + /// If anything else goes wrong, typically due to a bug or unhandled case. + /// We wrap exceptions in to allow you to distinguish + /// Units.NET exceptions from other exceptions. + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static RadiationEquivalentDose Parse(string str, IFormatProvider? provider) + { + return QuantityParser.Default.Parse( + str, + provider, + From); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + public static bool TryParse(string? str, out RadiationEquivalentDose result) + { + return TryParse(str, null, out result); + } + + /// + /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". + /// + /// String to parse. Typically in the form: {number} {unit} + /// Resulting unit quantity if successful. + /// True if successful, otherwise false. + /// + /// Length.Parse("5.5 m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParse(string? str, IFormatProvider? provider, out RadiationEquivalentDose result) + { + return QuantityParser.Default.TryParse( + str, + provider, + From, + out result); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// + /// Length.ParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// Error parsing string. + public static RadiationEquivalentDoseUnit ParseUnit(string str) + { + return ParseUnit(str, null); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// Format to use when parsing number and unit. Defaults to if null. + /// + /// Length.ParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// The value of 'str' cannot be null. + /// Error parsing string. + public static RadiationEquivalentDoseUnit ParseUnit(string str, IFormatProvider? provider) + { + return UnitParser.Default.Parse(str, provider); + } + + /// + public static bool TryParseUnit(string str, out RadiationEquivalentDoseUnit unit) + { + return TryParseUnit(str, null, out unit); + } + + /// + /// Parse a unit string. + /// + /// String to parse. Typically in the form: {number} {unit} + /// The parsed unit if successful. + /// True if successful, otherwise false. + /// + /// Length.TryParseUnit("m", CultureInfo.GetCultureInfo("en-US")); + /// + /// Format to use when parsing number and unit. Defaults to if null. + public static bool TryParseUnit(string str, IFormatProvider? provider, out RadiationEquivalentDoseUnit unit) + { + return UnitParser.Default.TryParse(str, provider, out unit); + } + + #endregion + + #region Arithmetic Operators + + /// Negate the value. + public static RadiationEquivalentDose operator -(RadiationEquivalentDose right) + { + return new RadiationEquivalentDose(-right.Value, right.Unit); + } + + /// Get from adding two . + public static RadiationEquivalentDose operator +(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return new RadiationEquivalentDose(left.Value + right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from subtracting two . + public static RadiationEquivalentDose operator -(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return new RadiationEquivalentDose(left.Value - right.ToUnit(left.Unit).Value, left.Unit); + } + + /// Get from multiplying value and . + public static RadiationEquivalentDose operator *(QuantityValue left, RadiationEquivalentDose right) + { + return new RadiationEquivalentDose(left * right.Value, right.Unit); + } + + /// Get from multiplying value and . + public static RadiationEquivalentDose operator *(RadiationEquivalentDose left, QuantityValue right) + { + return new RadiationEquivalentDose(left.Value * right, left.Unit); + } + + /// Get from dividing by value. + public static RadiationEquivalentDose operator /(RadiationEquivalentDose left, QuantityValue right) + { + return new RadiationEquivalentDose(left.Value / right, left.Unit); + } + + /// Get ratio value from dividing by . + public static QuantityValue operator /(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Sieverts / right.Sieverts; + } + + #endregion + + #region Equality / IComparable + + /// Returns true if less or equal to. + public static bool operator <=(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Value <= right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than or equal to. + public static bool operator >=(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Value >= right.ToUnit(left.Unit).Value; + } + + /// Returns true if less than. + public static bool operator <(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Value < right.ToUnit(left.Unit).Value; + } + + /// Returns true if greater than. + public static bool operator >(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Value > right.ToUnit(left.Unit).Value; + } + + /// Indicates strict equality of two quantities. + public static bool operator ==(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return left.Equals(right); + } + + /// Indicates strict inequality of two quantities. + public static bool operator !=(RadiationEquivalentDose left, RadiationEquivalentDose right) + { + return !(left == right); + } + + /// + /// Indicates strict equality of two quantities. + public override bool Equals(object? obj) + { + if (obj is null || !(obj is RadiationEquivalentDose otherQuantity)) + return false; + + return Equals(otherQuantity); + } + + /// + /// Indicates strict equality of two quantities. + public bool Equals(RadiationEquivalentDose other) + { + return _value.Equals(other.As(this.Unit)); + } + + /// Compares the current with another object of the same type and returns an integer that indicates whether 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. + /// + /// is not the same type as this instance. + /// + /// A value that indicates the relative order of the quantities being compared. The return value has these meanings: + /// + /// Value Meaning + /// Less than zero This instance precedes in the sort order. + /// Zero This instance occurs in the same position in the sort order as . + /// Greater than zero This instance follows in the sort order. + /// + /// + public int CompareTo(object? obj) + { + if (obj is null) throw new ArgumentNullException(nameof(obj)); + if (!(obj is RadiationEquivalentDose otherQuantity)) throw new ArgumentException("Expected type RadiationEquivalentDose.", nameof(obj)); + + return CompareTo(otherQuantity); + } + + /// Compares the current with another and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other when converted to the same unit. + /// A quantity to compare with this instance. + /// A value that indicates the relative order of the quantities being compared. The return value has these meanings: + /// + /// Value Meaning + /// Less than zero This instance precedes in the sort order. + /// Zero This instance occurs in the same position in the sort order as . + /// Greater than zero This instance follows in the sort order. + /// + /// + 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.QuantityValueComparison.Equals( + referenceValue: this.Value, + otherValue: other.As(this.Unit), + tolerance: (QuantityValue)tolerance, + comparisonType: ComparisonType.Absolute); + } + + /// + 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.QuantityValueComparison.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() + { + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif + } + + #endregion + + #region Conversion Methods + + /// + /// Convert to the unit representation . + /// + /// Value converted to the specified unit. + public QuantityValue As(RadiationEquivalentDoseUnit unit) + { + if (Unit == unit) + return Value; + + return ToUnit(unit).Value; + } + + /// + public QuantityValue As(UnitSystem unitSystem) + { + if (unitSystem is null) + throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + + var firstUnitInfo = unitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + + return As(firstUnitInfo.Value); + } + + /// + QuantityValue IQuantity.As(Enum unit) + { + if (!(unit is RadiationEquivalentDoseUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseUnit)} is supported.", nameof(unit)); + + return As(typedUnit); + } + + /// + /// Converts this RadiationEquivalentDose to another RadiationEquivalentDose with the unit representation . + /// + /// The unit to convert to. + /// A RadiationEquivalentDose with the specified unit. + public RadiationEquivalentDose ToUnit(RadiationEquivalentDoseUnit unit) + { + return ToUnit(unit, DefaultConversionFunctions); + } + + /// + /// Converts this to another using the given with the unit representation . + /// + /// The unit to convert to. + /// The to use for the conversion. + /// A RadiationEquivalentDose with the specified unit. + public RadiationEquivalentDose ToUnit(RadiationEquivalentDoseUnit unit, UnitConverter unitConverter) + { + if (TryToUnit(unit, out var converted)) + { + // Try to convert using the auto-generated conversion methods. + return converted!.Value; + } + else if (unitConverter.TryGetConversionFunction((typeof(RadiationEquivalentDose), Unit, typeof(RadiationEquivalentDose), unit), out var conversionFunction)) + { + // See if the unit converter has an extensibility conversion registered. + return (RadiationEquivalentDose)conversionFunction(this); + } + else if (Unit != BaseUnit) + { + // Conversion to requested unit NOT found. Try to convert to BaseUnit, and then from BaseUnit to requested unit. + var inBaseUnits = ToUnit(BaseUnit); + return inBaseUnits.ToUnit(unit); + } + else + { + // No possible conversion + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + } + } + + /// + /// Attempts to convert this to another with the unit representation . + /// + /// The unit to convert to. + /// The converted in , if successful. + /// True if successful, otherwise false. + private bool TryToUnit(RadiationEquivalentDoseUnit unit, [NotNullWhen(true)] out RadiationEquivalentDose? converted) + { + if (Unit == unit) + { + converted = this; + return true; + } + + RadiationEquivalentDose? convertedOrNull = (Unit, unit) switch + { + // RadiationEquivalentDoseUnit -> BaseUnit + (RadiationEquivalentDoseUnit.Microsievert, RadiationEquivalentDoseUnit.Sievert) => new RadiationEquivalentDose(_value / 1000000, RadiationEquivalentDoseUnit.Sievert), + (RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan, RadiationEquivalentDoseUnit.Sievert) => new RadiationEquivalentDose(_value / 100000, RadiationEquivalentDoseUnit.Sievert), + (RadiationEquivalentDoseUnit.Millisievert, RadiationEquivalentDoseUnit.Sievert) => new RadiationEquivalentDose(_value / 1000, RadiationEquivalentDoseUnit.Sievert), + (RadiationEquivalentDoseUnit.Nanosievert, RadiationEquivalentDoseUnit.Sievert) => new RadiationEquivalentDose(_value / 1000000000, RadiationEquivalentDoseUnit.Sievert), + (RadiationEquivalentDoseUnit.RoentgenEquivalentMan, RadiationEquivalentDoseUnit.Sievert) => new RadiationEquivalentDose(_value / 100, RadiationEquivalentDoseUnit.Sievert), + + // BaseUnit -> RadiationEquivalentDoseUnit + (RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Microsievert) => new RadiationEquivalentDose(_value * 1000000, RadiationEquivalentDoseUnit.Microsievert), + (RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan) => new RadiationEquivalentDose(_value * 100000, RadiationEquivalentDoseUnit.MilliroentgenEquivalentMan), + (RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Millisievert) => new RadiationEquivalentDose(_value * 1000, RadiationEquivalentDoseUnit.Millisievert), + (RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.Nanosievert) => new RadiationEquivalentDose(_value * 1000000000, RadiationEquivalentDoseUnit.Nanosievert), + (RadiationEquivalentDoseUnit.Sievert, RadiationEquivalentDoseUnit.RoentgenEquivalentMan) => new RadiationEquivalentDose(_value * 100, RadiationEquivalentDoseUnit.RoentgenEquivalentMan), + + _ => null + }; + + if (convertedOrNull is null) + { + converted = default; + return false; + } + + converted = convertedOrNull.Value; + return true; + } + + /// + IQuantity IQuantity.ToUnit(Enum unit) + { + if (!(unit is RadiationEquivalentDoseUnit typedUnit)) + throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationEquivalentDoseUnit)} is supported.", nameof(unit)); + + return ToUnit(typedUnit, DefaultConversionFunctions); + } + + /// + public RadiationEquivalentDose ToUnit(UnitSystem unitSystem) + { + if (unitSystem is null) + throw new ArgumentNullException(nameof(unitSystem)); + + var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); + + var firstUnitInfo = unitInfos.FirstOrDefault(); + if (firstUnitInfo == null) + throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); + + return ToUnit(firstUnitInfo.Value); + } + + /// + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + /// + IQuantity IQuantity.ToUnit(RadiationEquivalentDoseUnit unit) => ToUnit(unit); + + /// + IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + + #endregion + + #region ToString Methods + + /// + /// Gets the default string representation of value and unit. + /// + /// String representation. + public override string ToString() + { + return ToString("g"); + } + + /// + /// 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("g", 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, CultureInfo.CurrentCulture); + } + + /// + /// + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// + /// The format string. + /// Format to use for localization and number formatting. Defaults to if null. + /// The string representation. + public string ToString(string? format, IFormatProvider? provider) + { + return QuantityFormatter.Format(this, format, provider); + } + + #endregion + + #region IConvertible Methods + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Object; + } + + bool IConvertible.ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(RadiationEquivalentDose)} to bool is not supported."); + } + + byte IConvertible.ToByte(IFormatProvider? provider) + { + return Convert.ToByte(_value); + } + + char IConvertible.ToChar(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(RadiationEquivalentDose)} to char is not supported."); + } + + DateTime IConvertible.ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(RadiationEquivalentDose)} to DateTime is not supported."); + } + + decimal IConvertible.ToDecimal(IFormatProvider? provider) + { + return Convert.ToDecimal(_value); + } + + double IConvertible.ToDouble(IFormatProvider? provider) + { + return Convert.ToDouble(_value); + } + + short IConvertible.ToInt16(IFormatProvider? provider) + { + return Convert.ToInt16(_value); + } + + int IConvertible.ToInt32(IFormatProvider? provider) + { + return Convert.ToInt32(_value); + } + + long IConvertible.ToInt64(IFormatProvider? provider) + { + return Convert.ToInt64(_value); + } + + sbyte IConvertible.ToSByte(IFormatProvider? provider) + { + return Convert.ToSByte(_value); + } + + float IConvertible.ToSingle(IFormatProvider? provider) + { + return Convert.ToSingle(_value); + } + + string IConvertible.ToString(IFormatProvider? provider) + { + return ToString("g", provider); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == typeof(RadiationEquivalentDose)) + return this; + else if (conversionType == typeof(RadiationEquivalentDoseUnit)) + return Unit; + else if (conversionType == typeof(QuantityInfo)) + return RadiationEquivalentDose.Info; + else if (conversionType == typeof(BaseDimensions)) + return RadiationEquivalentDose.BaseDimensions; + else + throw new InvalidCastException($"Converting {typeof(RadiationEquivalentDose)} to {conversionType} is not supported."); + } + + ushort IConvertible.ToUInt16(IFormatProvider? provider) + { + return Convert.ToUInt16(_value); + } + + uint IConvertible.ToUInt32(IFormatProvider? provider) + { + return Convert.ToUInt32(_value); + } + + ulong IConvertible.ToUInt64(IFormatProvider? provider) + { + return Convert.ToUInt64(_value); + } + + #endregion + } +} diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs index e0ba3575a0..c1f435b182 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationExposure.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,7 +86,7 @@ static RadiationExposure() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RadiationExposure(double value, RadiationExposureUnit unit) + public RadiationExposure(QuantityValue value, RadiationExposureUnit unit) { _value = value; _unit = unit; @@ -99,7 +100,7 @@ public RadiationExposure(double value, RadiationExposureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RadiationExposure(double value, UnitSystem unitSystem) + public RadiationExposure(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -150,10 +151,10 @@ public RadiationExposure(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -178,42 +179,42 @@ public RadiationExposure(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CoulombsPerKilogram => As(RadiationExposureUnit.CoulombPerKilogram); + public QuantityValue CoulombsPerKilogram => As(RadiationExposureUnit.CoulombPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MicrocoulombsPerKilogram => As(RadiationExposureUnit.MicrocoulombPerKilogram); + public QuantityValue MicrocoulombsPerKilogram => As(RadiationExposureUnit.MicrocoulombPerKilogram); /// /// Gets a value of this quantity converted into /// - public double Microroentgens => As(RadiationExposureUnit.Microroentgen); + public QuantityValue Microroentgens => As(RadiationExposureUnit.Microroentgen); /// /// Gets a value of this quantity converted into /// - public double MillicoulombsPerKilogram => As(RadiationExposureUnit.MillicoulombPerKilogram); + public QuantityValue MillicoulombsPerKilogram => As(RadiationExposureUnit.MillicoulombPerKilogram); /// /// Gets a value of this quantity converted into /// - public double Milliroentgens => As(RadiationExposureUnit.Milliroentgen); + public QuantityValue Milliroentgens => As(RadiationExposureUnit.Milliroentgen); /// /// Gets a value of this quantity converted into /// - public double NanocoulombsPerKilogram => As(RadiationExposureUnit.NanocoulombPerKilogram); + public QuantityValue NanocoulombsPerKilogram => As(RadiationExposureUnit.NanocoulombPerKilogram); /// /// Gets a value of this quantity converted into /// - public double PicocoulombsPerKilogram => As(RadiationExposureUnit.PicocoulombPerKilogram); + public QuantityValue PicocoulombsPerKilogram => As(RadiationExposureUnit.PicocoulombPerKilogram); /// /// Gets a value of this quantity converted into /// - public double Roentgens => As(RadiationExposureUnit.Roentgen); + public QuantityValue Roentgens => As(RadiationExposureUnit.Roentgen); #endregion @@ -275,7 +276,7 @@ public static string GetAbbreviation(RadiationExposureUnit unit, IFormatProvider /// /// Creates a from . /// - public static RadiationExposure FromCoulombsPerKilogram(double value) + public static RadiationExposure FromCoulombsPerKilogram(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.CoulombPerKilogram); } @@ -283,7 +284,7 @@ public static RadiationExposure FromCoulombsPerKilogram(double value) /// /// Creates a from . /// - public static RadiationExposure FromMicrocoulombsPerKilogram(double value) + public static RadiationExposure FromMicrocoulombsPerKilogram(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.MicrocoulombPerKilogram); } @@ -291,7 +292,7 @@ public static RadiationExposure FromMicrocoulombsPerKilogram(double value) /// /// Creates a from . /// - public static RadiationExposure FromMicroroentgens(double value) + public static RadiationExposure FromMicroroentgens(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.Microroentgen); } @@ -299,7 +300,7 @@ public static RadiationExposure FromMicroroentgens(double value) /// /// Creates a from . /// - public static RadiationExposure FromMillicoulombsPerKilogram(double value) + public static RadiationExposure FromMillicoulombsPerKilogram(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.MillicoulombPerKilogram); } @@ -307,7 +308,7 @@ public static RadiationExposure FromMillicoulombsPerKilogram(double value) /// /// Creates a from . /// - public static RadiationExposure FromMilliroentgens(double value) + public static RadiationExposure FromMilliroentgens(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.Milliroentgen); } @@ -315,7 +316,7 @@ public static RadiationExposure FromMilliroentgens(double value) /// /// Creates a from . /// - public static RadiationExposure FromNanocoulombsPerKilogram(double value) + public static RadiationExposure FromNanocoulombsPerKilogram(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.NanocoulombPerKilogram); } @@ -323,7 +324,7 @@ public static RadiationExposure FromNanocoulombsPerKilogram(double value) /// /// Creates a from . /// - public static RadiationExposure FromPicocoulombsPerKilogram(double value) + public static RadiationExposure FromPicocoulombsPerKilogram(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.PicocoulombPerKilogram); } @@ -331,7 +332,7 @@ public static RadiationExposure FromPicocoulombsPerKilogram(double value) /// /// Creates a from . /// - public static RadiationExposure FromRoentgens(double value) + public static RadiationExposure FromRoentgens(QuantityValue value) { return new RadiationExposure(value, RadiationExposureUnit.Roentgen); } @@ -342,7 +343,7 @@ public static RadiationExposure FromRoentgens(double value) /// Value to convert from. /// Unit to convert from. /// RadiationExposure unit value. - public static RadiationExposure From(double value, RadiationExposureUnit fromUnit) + public static RadiationExposure From(QuantityValue value, RadiationExposureUnit fromUnit) { return new RadiationExposure(value, fromUnit); } @@ -514,25 +515,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Radia } /// Get from multiplying value and . - public static RadiationExposure operator *(double left, RadiationExposure right) + public static RadiationExposure operator *(QuantityValue left, RadiationExposure right) { return new RadiationExposure(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RadiationExposure operator *(RadiationExposure left, double right) + public static RadiationExposure operator *(RadiationExposure left, QuantityValue right) { return new RadiationExposure(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RadiationExposure operator /(RadiationExposure left, double right) + public static RadiationExposure operator /(RadiationExposure left, QuantityValue right) { return new RadiationExposure(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RadiationExposure left, RadiationExposure right) + public static QuantityValue operator /(RadiationExposure left, RadiationExposure right) { return left.CoulombsPerKilogram / right.CoulombsPerKilogram; } @@ -565,27 +566,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Radia return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RadiationExposure left, RadiationExposure right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RadiationExposure left, RadiationExposure right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RadiationExposure otherQuantity)) @@ -595,15 +589,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RadiationExposure other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -686,10 +677,10 @@ public bool Equals(RadiationExposure other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -706,7 +697,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RadiationExposure other, RadiationExposure tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -719,7 +710,12 @@ public bool Equals(RadiationExposure other, RadiationExposure tolerance) /// A hash code for the current RadiationExposure. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -730,7 +726,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RadiationExposureUnit unit) + public QuantityValue As(RadiationExposureUnit unit) { if (Unit == unit) return Value; @@ -739,7 +735,7 @@ public double As(RadiationExposureUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -754,7 +750,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RadiationExposureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadiationExposureUnit)} is supported.", nameof(unit)); @@ -820,22 +816,22 @@ private bool TryToUnit(RadiationExposureUnit unit, [NotNullWhen(true)] out Radia RadiationExposure? convertedOrNull = (Unit, unit) switch { // RadiationExposureUnit -> BaseUnit - (RadiationExposureUnit.MicrocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value) * 1e-6d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.Microroentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value * 2.58e-4) * 1e-6d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.MillicoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value) * 1e-3d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.Milliroentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value * 2.58e-4) * 1e-3d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.NanocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value) * 1e-9d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.PicocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure((_value) * 1e-12d, RadiationExposureUnit.CoulombPerKilogram), - (RadiationExposureUnit.Roentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value * 2.58e-4, RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.MicrocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value / 1000000, RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.Microroentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value * new QuantityValue(129, 500000000000, false), RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.MillicoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value / 1000, RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.Milliroentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value * new QuantityValue(129, 500000000, false), RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.NanocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value / 1000000000, RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.PicocoulombPerKilogram, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value / 1000000000000, RadiationExposureUnit.CoulombPerKilogram), + (RadiationExposureUnit.Roentgen, RadiationExposureUnit.CoulombPerKilogram) => new RadiationExposure(_value * new QuantityValue(129, 500000, false), RadiationExposureUnit.CoulombPerKilogram), // BaseUnit -> RadiationExposureUnit - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.MicrocoulombPerKilogram) => new RadiationExposure((_value) / 1e-6d, RadiationExposureUnit.MicrocoulombPerKilogram), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Microroentgen) => new RadiationExposure((_value / 2.58e-4) / 1e-6d, RadiationExposureUnit.Microroentgen), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.MillicoulombPerKilogram) => new RadiationExposure((_value) / 1e-3d, RadiationExposureUnit.MillicoulombPerKilogram), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Milliroentgen) => new RadiationExposure((_value / 2.58e-4) / 1e-3d, RadiationExposureUnit.Milliroentgen), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.NanocoulombPerKilogram) => new RadiationExposure((_value) / 1e-9d, RadiationExposureUnit.NanocoulombPerKilogram), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.PicocoulombPerKilogram) => new RadiationExposure((_value) / 1e-12d, RadiationExposureUnit.PicocoulombPerKilogram), - (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Roentgen) => new RadiationExposure(_value / 2.58e-4, RadiationExposureUnit.Roentgen), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.MicrocoulombPerKilogram) => new RadiationExposure(_value * 1000000, RadiationExposureUnit.MicrocoulombPerKilogram), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Microroentgen) => new RadiationExposure(_value * new QuantityValue(500000000000, 129, false), RadiationExposureUnit.Microroentgen), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.MillicoulombPerKilogram) => new RadiationExposure(_value * 1000, RadiationExposureUnit.MillicoulombPerKilogram), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Milliroentgen) => new RadiationExposure(_value * new QuantityValue(500000000, 129, false), RadiationExposureUnit.Milliroentgen), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.NanocoulombPerKilogram) => new RadiationExposure(_value * 1000000000, RadiationExposureUnit.NanocoulombPerKilogram), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.PicocoulombPerKilogram) => new RadiationExposure(_value * 1000000000000, RadiationExposureUnit.PicocoulombPerKilogram), + (RadiationExposureUnit.CoulombPerKilogram, RadiationExposureUnit.Roentgen) => new RadiationExposure(_value * new QuantityValue(500000, 129, false), RadiationExposureUnit.Roentgen), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs index 68c3295726..3b90bf49da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Radioactivity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -106,7 +107,7 @@ static Radioactivity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Radioactivity(double value, RadioactivityUnit unit) + public Radioactivity(QuantityValue value, RadioactivityUnit unit) { _value = value; _unit = unit; @@ -120,7 +121,7 @@ public Radioactivity(double value, RadioactivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Radioactivity(double value, UnitSystem unitSystem) + public Radioactivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -171,10 +172,10 @@ public Radioactivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -199,147 +200,147 @@ public Radioactivity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Becquerels => As(RadioactivityUnit.Becquerel); + public QuantityValue Becquerels => As(RadioactivityUnit.Becquerel); /// /// Gets a value of this quantity converted into /// - public double Curies => As(RadioactivityUnit.Curie); + public QuantityValue Curies => As(RadioactivityUnit.Curie); /// /// Gets a value of this quantity converted into /// - public double Exabecquerels => As(RadioactivityUnit.Exabecquerel); + public QuantityValue Exabecquerels => As(RadioactivityUnit.Exabecquerel); /// /// Gets a value of this quantity converted into /// - public double Gigabecquerels => As(RadioactivityUnit.Gigabecquerel); + public QuantityValue Gigabecquerels => As(RadioactivityUnit.Gigabecquerel); /// /// Gets a value of this quantity converted into /// - public double Gigacuries => As(RadioactivityUnit.Gigacurie); + public QuantityValue Gigacuries => As(RadioactivityUnit.Gigacurie); /// /// Gets a value of this quantity converted into /// - public double Gigarutherfords => As(RadioactivityUnit.Gigarutherford); + public QuantityValue Gigarutherfords => As(RadioactivityUnit.Gigarutherford); /// /// Gets a value of this quantity converted into /// - public double Kilobecquerels => As(RadioactivityUnit.Kilobecquerel); + public QuantityValue Kilobecquerels => As(RadioactivityUnit.Kilobecquerel); /// /// Gets a value of this quantity converted into /// - public double Kilocuries => As(RadioactivityUnit.Kilocurie); + public QuantityValue Kilocuries => As(RadioactivityUnit.Kilocurie); /// /// Gets a value of this quantity converted into /// - public double Kilorutherfords => As(RadioactivityUnit.Kilorutherford); + public QuantityValue Kilorutherfords => As(RadioactivityUnit.Kilorutherford); /// /// Gets a value of this quantity converted into /// - public double Megabecquerels => As(RadioactivityUnit.Megabecquerel); + public QuantityValue Megabecquerels => As(RadioactivityUnit.Megabecquerel); /// /// Gets a value of this quantity converted into /// - public double Megacuries => As(RadioactivityUnit.Megacurie); + public QuantityValue Megacuries => As(RadioactivityUnit.Megacurie); /// /// Gets a value of this quantity converted into /// - public double Megarutherfords => As(RadioactivityUnit.Megarutherford); + public QuantityValue Megarutherfords => As(RadioactivityUnit.Megarutherford); /// /// Gets a value of this quantity converted into /// - public double Microbecquerels => As(RadioactivityUnit.Microbecquerel); + public QuantityValue Microbecquerels => As(RadioactivityUnit.Microbecquerel); /// /// Gets a value of this quantity converted into /// - public double Microcuries => As(RadioactivityUnit.Microcurie); + public QuantityValue Microcuries => As(RadioactivityUnit.Microcurie); /// /// Gets a value of this quantity converted into /// - public double Microrutherfords => As(RadioactivityUnit.Microrutherford); + public QuantityValue Microrutherfords => As(RadioactivityUnit.Microrutherford); /// /// Gets a value of this quantity converted into /// - public double Millibecquerels => As(RadioactivityUnit.Millibecquerel); + public QuantityValue Millibecquerels => As(RadioactivityUnit.Millibecquerel); /// /// Gets a value of this quantity converted into /// - public double Millicuries => As(RadioactivityUnit.Millicurie); + public QuantityValue Millicuries => As(RadioactivityUnit.Millicurie); /// /// Gets a value of this quantity converted into /// - public double Millirutherfords => As(RadioactivityUnit.Millirutherford); + public QuantityValue Millirutherfords => As(RadioactivityUnit.Millirutherford); /// /// Gets a value of this quantity converted into /// - public double Nanobecquerels => As(RadioactivityUnit.Nanobecquerel); + public QuantityValue Nanobecquerels => As(RadioactivityUnit.Nanobecquerel); /// /// Gets a value of this quantity converted into /// - public double Nanocuries => As(RadioactivityUnit.Nanocurie); + public QuantityValue Nanocuries => As(RadioactivityUnit.Nanocurie); /// /// Gets a value of this quantity converted into /// - public double Nanorutherfords => As(RadioactivityUnit.Nanorutherford); + public QuantityValue Nanorutherfords => As(RadioactivityUnit.Nanorutherford); /// /// Gets a value of this quantity converted into /// - public double Petabecquerels => As(RadioactivityUnit.Petabecquerel); + public QuantityValue Petabecquerels => As(RadioactivityUnit.Petabecquerel); /// /// Gets a value of this quantity converted into /// - public double Picobecquerels => As(RadioactivityUnit.Picobecquerel); + public QuantityValue Picobecquerels => As(RadioactivityUnit.Picobecquerel); /// /// Gets a value of this quantity converted into /// - public double Picocuries => As(RadioactivityUnit.Picocurie); + public QuantityValue Picocuries => As(RadioactivityUnit.Picocurie); /// /// Gets a value of this quantity converted into /// - public double Picorutherfords => As(RadioactivityUnit.Picorutherford); + public QuantityValue Picorutherfords => As(RadioactivityUnit.Picorutherford); /// /// Gets a value of this quantity converted into /// - public double Rutherfords => As(RadioactivityUnit.Rutherford); + public QuantityValue Rutherfords => As(RadioactivityUnit.Rutherford); /// /// Gets a value of this quantity converted into /// - public double Terabecquerels => As(RadioactivityUnit.Terabecquerel); + public QuantityValue Terabecquerels => As(RadioactivityUnit.Terabecquerel); /// /// Gets a value of this quantity converted into /// - public double Teracuries => As(RadioactivityUnit.Teracurie); + public QuantityValue Teracuries => As(RadioactivityUnit.Teracurie); /// /// Gets a value of this quantity converted into /// - public double Terarutherfords => As(RadioactivityUnit.Terarutherford); + public QuantityValue Terarutherfords => As(RadioactivityUnit.Terarutherford); #endregion @@ -443,7 +444,7 @@ public static string GetAbbreviation(RadioactivityUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static Radioactivity FromBecquerels(double value) + public static Radioactivity FromBecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Becquerel); } @@ -451,7 +452,7 @@ public static Radioactivity FromBecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromCuries(double value) + public static Radioactivity FromCuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Curie); } @@ -459,7 +460,7 @@ public static Radioactivity FromCuries(double value) /// /// Creates a from . /// - public static Radioactivity FromExabecquerels(double value) + public static Radioactivity FromExabecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Exabecquerel); } @@ -467,7 +468,7 @@ public static Radioactivity FromExabecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromGigabecquerels(double value) + public static Radioactivity FromGigabecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Gigabecquerel); } @@ -475,7 +476,7 @@ public static Radioactivity FromGigabecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromGigacuries(double value) + public static Radioactivity FromGigacuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Gigacurie); } @@ -483,7 +484,7 @@ public static Radioactivity FromGigacuries(double value) /// /// Creates a from . /// - public static Radioactivity FromGigarutherfords(double value) + public static Radioactivity FromGigarutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Gigarutherford); } @@ -491,7 +492,7 @@ public static Radioactivity FromGigarutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromKilobecquerels(double value) + public static Radioactivity FromKilobecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Kilobecquerel); } @@ -499,7 +500,7 @@ public static Radioactivity FromKilobecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromKilocuries(double value) + public static Radioactivity FromKilocuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Kilocurie); } @@ -507,7 +508,7 @@ public static Radioactivity FromKilocuries(double value) /// /// Creates a from . /// - public static Radioactivity FromKilorutherfords(double value) + public static Radioactivity FromKilorutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Kilorutherford); } @@ -515,7 +516,7 @@ public static Radioactivity FromKilorutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromMegabecquerels(double value) + public static Radioactivity FromMegabecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Megabecquerel); } @@ -523,7 +524,7 @@ public static Radioactivity FromMegabecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromMegacuries(double value) + public static Radioactivity FromMegacuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Megacurie); } @@ -531,7 +532,7 @@ public static Radioactivity FromMegacuries(double value) /// /// Creates a from . /// - public static Radioactivity FromMegarutherfords(double value) + public static Radioactivity FromMegarutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Megarutherford); } @@ -539,7 +540,7 @@ public static Radioactivity FromMegarutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromMicrobecquerels(double value) + public static Radioactivity FromMicrobecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Microbecquerel); } @@ -547,7 +548,7 @@ public static Radioactivity FromMicrobecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromMicrocuries(double value) + public static Radioactivity FromMicrocuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Microcurie); } @@ -555,7 +556,7 @@ public static Radioactivity FromMicrocuries(double value) /// /// Creates a from . /// - public static Radioactivity FromMicrorutherfords(double value) + public static Radioactivity FromMicrorutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Microrutherford); } @@ -563,7 +564,7 @@ public static Radioactivity FromMicrorutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromMillibecquerels(double value) + public static Radioactivity FromMillibecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Millibecquerel); } @@ -571,7 +572,7 @@ public static Radioactivity FromMillibecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromMillicuries(double value) + public static Radioactivity FromMillicuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Millicurie); } @@ -579,7 +580,7 @@ public static Radioactivity FromMillicuries(double value) /// /// Creates a from . /// - public static Radioactivity FromMillirutherfords(double value) + public static Radioactivity FromMillirutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Millirutherford); } @@ -587,7 +588,7 @@ public static Radioactivity FromMillirutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromNanobecquerels(double value) + public static Radioactivity FromNanobecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Nanobecquerel); } @@ -595,7 +596,7 @@ public static Radioactivity FromNanobecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromNanocuries(double value) + public static Radioactivity FromNanocuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Nanocurie); } @@ -603,7 +604,7 @@ public static Radioactivity FromNanocuries(double value) /// /// Creates a from . /// - public static Radioactivity FromNanorutherfords(double value) + public static Radioactivity FromNanorutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Nanorutherford); } @@ -611,7 +612,7 @@ public static Radioactivity FromNanorutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromPetabecquerels(double value) + public static Radioactivity FromPetabecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Petabecquerel); } @@ -619,7 +620,7 @@ public static Radioactivity FromPetabecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromPicobecquerels(double value) + public static Radioactivity FromPicobecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Picobecquerel); } @@ -627,7 +628,7 @@ public static Radioactivity FromPicobecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromPicocuries(double value) + public static Radioactivity FromPicocuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Picocurie); } @@ -635,7 +636,7 @@ public static Radioactivity FromPicocuries(double value) /// /// Creates a from . /// - public static Radioactivity FromPicorutherfords(double value) + public static Radioactivity FromPicorutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Picorutherford); } @@ -643,7 +644,7 @@ public static Radioactivity FromPicorutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromRutherfords(double value) + public static Radioactivity FromRutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Rutherford); } @@ -651,7 +652,7 @@ public static Radioactivity FromRutherfords(double value) /// /// Creates a from . /// - public static Radioactivity FromTerabecquerels(double value) + public static Radioactivity FromTerabecquerels(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Terabecquerel); } @@ -659,7 +660,7 @@ public static Radioactivity FromTerabecquerels(double value) /// /// Creates a from . /// - public static Radioactivity FromTeracuries(double value) + public static Radioactivity FromTeracuries(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Teracurie); } @@ -667,7 +668,7 @@ public static Radioactivity FromTeracuries(double value) /// /// Creates a from . /// - public static Radioactivity FromTerarutherfords(double value) + public static Radioactivity FromTerarutherfords(QuantityValue value) { return new Radioactivity(value, RadioactivityUnit.Terarutherford); } @@ -678,7 +679,7 @@ public static Radioactivity FromTerarutherfords(double value) /// Value to convert from. /// Unit to convert from. /// Radioactivity unit value. - public static Radioactivity From(double value, RadioactivityUnit fromUnit) + public static Radioactivity From(QuantityValue value, RadioactivityUnit fromUnit) { return new Radioactivity(value, fromUnit); } @@ -850,25 +851,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Radio } /// Get from multiplying value and . - public static Radioactivity operator *(double left, Radioactivity right) + public static Radioactivity operator *(QuantityValue left, Radioactivity right) { return new Radioactivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Radioactivity operator *(Radioactivity left, double right) + public static Radioactivity operator *(Radioactivity left, QuantityValue right) { return new Radioactivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Radioactivity operator /(Radioactivity left, double right) + public static Radioactivity operator /(Radioactivity left, QuantityValue right) { return new Radioactivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Radioactivity left, Radioactivity right) + public static QuantityValue operator /(Radioactivity left, Radioactivity right) { return left.Becquerels / right.Becquerels; } @@ -901,27 +902,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Radio return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Radioactivity left, Radioactivity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, 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.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Radioactivity left, Radioactivity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Radioactivity otherQuantity)) @@ -931,15 +925,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Radioactivity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1022,10 +1013,10 @@ public bool Equals(Radioactivity other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1042,7 +1033,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Radioactivity other, Radioactivity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1055,7 +1046,12 @@ public bool Equals(Radioactivity other, Radioactivity tolerance) /// A hash code for the current Radioactivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1066,7 +1062,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RadioactivityUnit unit) + public QuantityValue As(RadioactivityUnit unit) { if (Unit == unit) return Value; @@ -1075,7 +1071,7 @@ public double As(RadioactivityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1090,7 +1086,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RadioactivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RadioactivityUnit)} is supported.", nameof(unit)); @@ -1156,64 +1152,64 @@ private bool TryToUnit(RadioactivityUnit unit, [NotNullWhen(true)] out Radioacti Radioactivity? convertedOrNull = (Unit, unit) switch { // RadioactivityUnit -> BaseUnit - (RadioactivityUnit.Curie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 3.7e10, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Exabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e18d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Gigabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Gigacurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Gigarutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Kilobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Kilocurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Kilorutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Megabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Megacurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Megarutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Microbecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e-6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Microcurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e-6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Microrutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e-6d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Millibecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e-3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Millicurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e-3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Millirutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e-3d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Nanobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e-9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Nanocurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e-9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Nanorutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e-9d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Petabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e15d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Picobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e-12d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Picocurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e-12d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Picorutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e-12d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Rutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1e6, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Terabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity((_value) * 1e12d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Teracurie, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 3.7e10) * 1e12d, RadioactivityUnit.Becquerel), - (RadioactivityUnit.Terarutherford, RadioactivityUnit.Becquerel) => new Radioactivity((_value * 1e6) * 1e12d, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Curie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Exabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Gigabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Gigacurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * new QuantityValue(37, 10, false) * BigInteger.Pow(10, 19), RadioactivityUnit.Becquerel), + (RadioactivityUnit.Gigarutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Kilobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Kilocurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Kilorutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Megabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Megacurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37000000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Megarutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Microbecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Microcurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Microrutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Millibecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Millicurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Millirutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Nanobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Nanocurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 37, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Nanorutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Petabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Picobecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Picocurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * new QuantityValue(37, 1000, false), RadioactivityUnit.Becquerel), + (RadioactivityUnit.Picorutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value / 1000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Rutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Terabecquerel, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000, RadioactivityUnit.Becquerel), + (RadioactivityUnit.Teracurie, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 3700 * BigInteger.Pow(10, 19), RadioactivityUnit.Becquerel), + (RadioactivityUnit.Terarutherford, RadioactivityUnit.Becquerel) => new Radioactivity(_value * 1000000000000000000, RadioactivityUnit.Becquerel), // BaseUnit -> RadioactivityUnit - (RadioactivityUnit.Becquerel, RadioactivityUnit.Curie) => new Radioactivity(_value / 3.7e10, RadioactivityUnit.Curie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Exabecquerel) => new Radioactivity((_value) / 1e18d, RadioactivityUnit.Exabecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigabecquerel) => new Radioactivity((_value) / 1e9d, RadioactivityUnit.Gigabecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigacurie) => new Radioactivity((_value / 3.7e10) / 1e9d, RadioactivityUnit.Gigacurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigarutherford) => new Radioactivity((_value / 1e6) / 1e9d, RadioactivityUnit.Gigarutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilobecquerel) => new Radioactivity((_value) / 1e3d, RadioactivityUnit.Kilobecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilocurie) => new Radioactivity((_value / 3.7e10) / 1e3d, RadioactivityUnit.Kilocurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilorutherford) => new Radioactivity((_value / 1e6) / 1e3d, RadioactivityUnit.Kilorutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Megabecquerel) => new Radioactivity((_value) / 1e6d, RadioactivityUnit.Megabecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Megacurie) => new Radioactivity((_value / 3.7e10) / 1e6d, RadioactivityUnit.Megacurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Megarutherford) => new Radioactivity((_value / 1e6) / 1e6d, RadioactivityUnit.Megarutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Microbecquerel) => new Radioactivity((_value) / 1e-6d, RadioactivityUnit.Microbecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Microcurie) => new Radioactivity((_value / 3.7e10) / 1e-6d, RadioactivityUnit.Microcurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Microrutherford) => new Radioactivity((_value / 1e6) / 1e-6d, RadioactivityUnit.Microrutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Millibecquerel) => new Radioactivity((_value) / 1e-3d, RadioactivityUnit.Millibecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Millicurie) => new Radioactivity((_value / 3.7e10) / 1e-3d, RadioactivityUnit.Millicurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Millirutherford) => new Radioactivity((_value / 1e6) / 1e-3d, RadioactivityUnit.Millirutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanobecquerel) => new Radioactivity((_value) / 1e-9d, RadioactivityUnit.Nanobecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanocurie) => new Radioactivity((_value / 3.7e10) / 1e-9d, RadioactivityUnit.Nanocurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanorutherford) => new Radioactivity((_value / 1e6) / 1e-9d, RadioactivityUnit.Nanorutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Petabecquerel) => new Radioactivity((_value) / 1e15d, RadioactivityUnit.Petabecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Picobecquerel) => new Radioactivity((_value) / 1e-12d, RadioactivityUnit.Picobecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Picocurie) => new Radioactivity((_value / 3.7e10) / 1e-12d, RadioactivityUnit.Picocurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Picorutherford) => new Radioactivity((_value / 1e6) / 1e-12d, RadioactivityUnit.Picorutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Rutherford) => new Radioactivity(_value / 1e6, RadioactivityUnit.Rutherford), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Terabecquerel) => new Radioactivity((_value) / 1e12d, RadioactivityUnit.Terabecquerel), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Teracurie) => new Radioactivity((_value / 3.7e10) / 1e12d, RadioactivityUnit.Teracurie), - (RadioactivityUnit.Becquerel, RadioactivityUnit.Terarutherford) => new Radioactivity((_value / 1e6) / 1e12d, RadioactivityUnit.Terarutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Curie) => new Radioactivity(_value / 37000000000, RadioactivityUnit.Curie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Exabecquerel) => new Radioactivity(_value / 1000000000000000000, RadioactivityUnit.Exabecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigabecquerel) => new Radioactivity(_value / 1000000000, RadioactivityUnit.Gigabecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigacurie) => new Radioactivity(_value * new QuantityValue(10, 37, false) / BigInteger.Pow(10, 19), RadioactivityUnit.Gigacurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Gigarutherford) => new Radioactivity(_value / 1000000000000000, RadioactivityUnit.Gigarutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilobecquerel) => new Radioactivity(_value / 1000, RadioactivityUnit.Kilobecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilocurie) => new Radioactivity(_value / 37000000000000, RadioactivityUnit.Kilocurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Kilorutherford) => new Radioactivity(_value / 1000000000, RadioactivityUnit.Kilorutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Megabecquerel) => new Radioactivity(_value / 1000000, RadioactivityUnit.Megabecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Megacurie) => new Radioactivity(_value / 37000000000000000, RadioactivityUnit.Megacurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Megarutherford) => new Radioactivity(_value / 1000000000000, RadioactivityUnit.Megarutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Microbecquerel) => new Radioactivity(_value * 1000000, RadioactivityUnit.Microbecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Microcurie) => new Radioactivity(_value / 37000, RadioactivityUnit.Microcurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Microrutherford) => new Radioactivity(_value, RadioactivityUnit.Microrutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Millibecquerel) => new Radioactivity(_value * 1000, RadioactivityUnit.Millibecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Millicurie) => new Radioactivity(_value / 37000000, RadioactivityUnit.Millicurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Millirutherford) => new Radioactivity(_value / 1000, RadioactivityUnit.Millirutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanobecquerel) => new Radioactivity(_value * 1000000000, RadioactivityUnit.Nanobecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanocurie) => new Radioactivity(_value / 37, RadioactivityUnit.Nanocurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Nanorutherford) => new Radioactivity(_value * 1000, RadioactivityUnit.Nanorutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Petabecquerel) => new Radioactivity(_value / 1000000000000000, RadioactivityUnit.Petabecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Picobecquerel) => new Radioactivity(_value * 1000000000000, RadioactivityUnit.Picobecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Picocurie) => new Radioactivity(_value * new QuantityValue(1000, 37, false), RadioactivityUnit.Picocurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Picorutherford) => new Radioactivity(_value * 1000000, RadioactivityUnit.Picorutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Rutherford) => new Radioactivity(_value / 1000000, RadioactivityUnit.Rutherford), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Terabecquerel) => new Radioactivity(_value / 1000000000000, RadioactivityUnit.Terabecquerel), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Teracurie) => new Radioactivity(_value / 3700 / BigInteger.Pow(10, 19), RadioactivityUnit.Teracurie), + (RadioactivityUnit.Becquerel, RadioactivityUnit.Terarutherford) => new Radioactivity(_value / 1000000000000000000, RadioactivityUnit.Terarutherford), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index b796ef11fa..26d4bf4aca 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -90,7 +88,7 @@ static Ratio() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Ratio(double value, RatioUnit unit) + public Ratio(QuantityValue value, RatioUnit unit) { _value = value; _unit = unit; @@ -104,7 +102,7 @@ public Ratio(double value, RatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Ratio(double value, UnitSystem unitSystem) + public Ratio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -155,10 +153,10 @@ public Ratio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,32 +181,32 @@ public Ratio(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DecimalFractions => As(RatioUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(RatioUnit.DecimalFraction); /// /// Gets a value of this quantity converted into /// - public double PartsPerBillion => As(RatioUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(RatioUnit.PartPerBillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerMillion => As(RatioUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(RatioUnit.PartPerMillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerThousand => As(RatioUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(RatioUnit.PartPerThousand); /// /// Gets a value of this quantity converted into /// - public double PartsPerTrillion => As(RatioUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(RatioUnit.PartPerTrillion); /// /// Gets a value of this quantity converted into /// - public double Percent => As(RatioUnit.Percent); + public QuantityValue Percent => As(RatioUnit.Percent); #endregion @@ -266,7 +264,7 @@ public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Ratio FromDecimalFractions(double value) + public static Ratio FromDecimalFractions(QuantityValue value) { return new Ratio(value, RatioUnit.DecimalFraction); } @@ -274,7 +272,7 @@ public static Ratio FromDecimalFractions(double value) /// /// Creates a from . /// - public static Ratio FromPartsPerBillion(double value) + public static Ratio FromPartsPerBillion(QuantityValue value) { return new Ratio(value, RatioUnit.PartPerBillion); } @@ -282,7 +280,7 @@ public static Ratio FromPartsPerBillion(double value) /// /// Creates a from . /// - public static Ratio FromPartsPerMillion(double value) + public static Ratio FromPartsPerMillion(QuantityValue value) { return new Ratio(value, RatioUnit.PartPerMillion); } @@ -290,7 +288,7 @@ public static Ratio FromPartsPerMillion(double value) /// /// Creates a from . /// - public static Ratio FromPartsPerThousand(double value) + public static Ratio FromPartsPerThousand(QuantityValue value) { return new Ratio(value, RatioUnit.PartPerThousand); } @@ -298,7 +296,7 @@ public static Ratio FromPartsPerThousand(double value) /// /// Creates a from . /// - public static Ratio FromPartsPerTrillion(double value) + public static Ratio FromPartsPerTrillion(QuantityValue value) { return new Ratio(value, RatioUnit.PartPerTrillion); } @@ -306,7 +304,7 @@ public static Ratio FromPartsPerTrillion(double value) /// /// Creates a from . /// - public static Ratio FromPercent(double value) + public static Ratio FromPercent(QuantityValue value) { return new Ratio(value, RatioUnit.Percent); } @@ -317,7 +315,7 @@ public static Ratio FromPercent(double value) /// Value to convert from. /// Unit to convert from. /// Ratio unit value. - public static Ratio From(double value, RatioUnit fromUnit) + public static Ratio From(QuantityValue value, RatioUnit fromUnit) { return new Ratio(value, fromUnit); } @@ -489,25 +487,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static Ratio operator *(double left, Ratio right) + public static Ratio operator *(QuantityValue left, Ratio right) { return new Ratio(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Ratio operator *(Ratio left, double right) + public static Ratio operator *(Ratio left, QuantityValue right) { return new Ratio(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Ratio operator /(Ratio left, double right) + public static Ratio operator /(Ratio left, QuantityValue right) { return new Ratio(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Ratio left, Ratio right) + public static QuantityValue operator /(Ratio left, Ratio right) { return left.DecimalFractions / right.DecimalFractions; } @@ -556,27 +554,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Ratio left, Ratio right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Ratio other, Ratio tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Ratio left, Ratio right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Ratio otherQuantity)) @@ -586,15 +577,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Ratio other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -677,10 +665,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -697,7 +685,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Ratio other, Ratio tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -710,7 +698,12 @@ public bool Equals(Ratio other, Ratio tolerance) /// A hash code for the current Ratio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -721,7 +714,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioUnit unit) + public QuantityValue As(RatioUnit unit) { if (Unit == unit) return Value; @@ -730,7 +723,7 @@ public double As(RatioUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -745,7 +738,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); @@ -811,18 +804,18 @@ private bool TryToUnit(RatioUnit unit, [NotNullWhen(true)] out Ratio? converted) Ratio? convertedOrNull = (Unit, unit) switch { // RatioUnit -> BaseUnit - (RatioUnit.PartPerBillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1e9, RatioUnit.DecimalFraction), - (RatioUnit.PartPerMillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1e6, RatioUnit.DecimalFraction), - (RatioUnit.PartPerThousand, RatioUnit.DecimalFraction) => new Ratio(_value / 1e3, RatioUnit.DecimalFraction), - (RatioUnit.PartPerTrillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1e12, RatioUnit.DecimalFraction), - (RatioUnit.Percent, RatioUnit.DecimalFraction) => new Ratio(_value / 1e2, RatioUnit.DecimalFraction), + (RatioUnit.PartPerBillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1000000000, RatioUnit.DecimalFraction), + (RatioUnit.PartPerMillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1000000, RatioUnit.DecimalFraction), + (RatioUnit.PartPerThousand, RatioUnit.DecimalFraction) => new Ratio(_value / 1000, RatioUnit.DecimalFraction), + (RatioUnit.PartPerTrillion, RatioUnit.DecimalFraction) => new Ratio(_value / 1000000000000, RatioUnit.DecimalFraction), + (RatioUnit.Percent, RatioUnit.DecimalFraction) => new Ratio(_value / 100, RatioUnit.DecimalFraction), // BaseUnit -> RatioUnit - (RatioUnit.DecimalFraction, RatioUnit.PartPerBillion) => new Ratio(_value * 1e9, RatioUnit.PartPerBillion), - (RatioUnit.DecimalFraction, RatioUnit.PartPerMillion) => new Ratio(_value * 1e6, RatioUnit.PartPerMillion), - (RatioUnit.DecimalFraction, RatioUnit.PartPerThousand) => new Ratio(_value * 1e3, RatioUnit.PartPerThousand), - (RatioUnit.DecimalFraction, RatioUnit.PartPerTrillion) => new Ratio(_value * 1e12, RatioUnit.PartPerTrillion), - (RatioUnit.DecimalFraction, RatioUnit.Percent) => new Ratio(_value * 1e2, RatioUnit.Percent), + (RatioUnit.DecimalFraction, RatioUnit.PartPerBillion) => new Ratio(_value * 1000000000, RatioUnit.PartPerBillion), + (RatioUnit.DecimalFraction, RatioUnit.PartPerMillion) => new Ratio(_value * 1000000, RatioUnit.PartPerMillion), + (RatioUnit.DecimalFraction, RatioUnit.PartPerThousand) => new Ratio(_value * 1000, RatioUnit.PartPerThousand), + (RatioUnit.DecimalFraction, RatioUnit.PartPerTrillion) => new Ratio(_value * 1000000000000, RatioUnit.PartPerTrillion), + (RatioUnit.DecimalFraction, RatioUnit.Percent) => new Ratio(_value * 100, RatioUnit.Percent), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index f2471a2a5f..6af583042d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,7 +80,7 @@ static RatioChangeRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RatioChangeRate(double value, RatioChangeRateUnit unit) + public RatioChangeRate(QuantityValue value, RatioChangeRateUnit unit) { _value = value; _unit = unit; @@ -93,7 +94,7 @@ public RatioChangeRate(double value, RatioChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RatioChangeRate(double value, UnitSystem unitSystem) + public RatioChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -144,10 +145,10 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -172,12 +173,12 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); + public QuantityValue DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); /// /// Gets a value of this quantity converted into /// - public double PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); + public QuantityValue PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); #endregion @@ -227,7 +228,7 @@ public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? /// /// Creates a from . /// - public static RatioChangeRate FromDecimalFractionsPerSecond(double value) + public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue value) { return new RatioChangeRate(value, RatioChangeRateUnit.DecimalFractionPerSecond); } @@ -235,7 +236,7 @@ public static RatioChangeRate FromDecimalFractionsPerSecond(double value) /// /// Creates a from . /// - public static RatioChangeRate FromPercentsPerSecond(double value) + public static RatioChangeRate FromPercentsPerSecond(QuantityValue value) { return new RatioChangeRate(value, RatioChangeRateUnit.PercentPerSecond); } @@ -246,7 +247,7 @@ public static RatioChangeRate FromPercentsPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// RatioChangeRate unit value. - public static RatioChangeRate From(double value, RatioChangeRateUnit fromUnit) + public static RatioChangeRate From(QuantityValue value, RatioChangeRateUnit fromUnit) { return new RatioChangeRate(value, fromUnit); } @@ -418,25 +419,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static RatioChangeRate operator *(double left, RatioChangeRate right) + public static RatioChangeRate operator *(QuantityValue left, RatioChangeRate right) { return new RatioChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RatioChangeRate operator *(RatioChangeRate left, double right) + public static RatioChangeRate operator *(RatioChangeRate left, QuantityValue right) { return new RatioChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RatioChangeRate operator /(RatioChangeRate left, double right) + public static RatioChangeRate operator /(RatioChangeRate left, QuantityValue right) { return new RatioChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RatioChangeRate left, RatioChangeRate right) + public static QuantityValue operator /(RatioChangeRate left, RatioChangeRate right) { return left.DecimalFractionsPerSecond / right.DecimalFractionsPerSecond; } @@ -469,27 +470,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RatioChangeRate left, RatioChangeRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RatioChangeRate other, RatioChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RatioChangeRate left, RatioChangeRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RatioChangeRate otherQuantity)) @@ -499,15 +493,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RatioChangeRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -590,10 +581,10 @@ public bool Equals(RatioChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -610,7 +601,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RatioChangeRate other, RatioChangeRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -623,7 +614,12 @@ public bool Equals(RatioChangeRate other, RatioChangeRate tolerance) /// A hash code for the current RatioChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -634,7 +630,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioChangeRateUnit unit) + public QuantityValue As(RatioChangeRateUnit unit) { if (Unit == unit) return Value; @@ -643,7 +639,7 @@ public double As(RatioChangeRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,7 +654,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); @@ -724,10 +720,10 @@ private bool TryToUnit(RatioChangeRateUnit unit, [NotNullWhen(true)] out RatioCh RatioChangeRate? convertedOrNull = (Unit, unit) switch { // RatioChangeRateUnit -> BaseUnit - (RatioChangeRateUnit.PercentPerSecond, RatioChangeRateUnit.DecimalFractionPerSecond) => new RatioChangeRate(_value / 1e2, RatioChangeRateUnit.DecimalFractionPerSecond), + (RatioChangeRateUnit.PercentPerSecond, RatioChangeRateUnit.DecimalFractionPerSecond) => new RatioChangeRate(_value / 100, RatioChangeRateUnit.DecimalFractionPerSecond), // BaseUnit -> RatioChangeRateUnit - (RatioChangeRateUnit.DecimalFractionPerSecond, RatioChangeRateUnit.PercentPerSecond) => new RatioChangeRate(_value * 1e2, RatioChangeRateUnit.PercentPerSecond), + (RatioChangeRateUnit.DecimalFractionPerSecond, RatioChangeRateUnit.PercentPerSecond) => new RatioChangeRate(_value * 100, RatioChangeRateUnit.PercentPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 307882e58b..5d5114d763 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,7 +81,7 @@ static ReactiveEnergy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ReactiveEnergy(double value, ReactiveEnergyUnit unit) + public ReactiveEnergy(QuantityValue value, ReactiveEnergyUnit unit) { _value = value; _unit = unit; @@ -94,7 +95,7 @@ public ReactiveEnergy(double value, ReactiveEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactiveEnergy(double value, UnitSystem unitSystem) + public ReactiveEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -145,10 +146,10 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,17 +174,17 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); + public QuantityValue KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); /// /// Gets a value of this quantity converted into /// - public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); + public QuantityValue MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); /// /// Gets a value of this quantity converted into /// - public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); + public QuantityValue VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); #endregion @@ -235,7 +236,7 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static ReactiveEnergy FromKilovoltampereReactiveHours(double value) + public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue value) { return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour); } @@ -243,7 +244,7 @@ public static ReactiveEnergy FromKilovoltampereReactiveHours(double value) /// /// Creates a from . /// - public static ReactiveEnergy FromMegavoltampereReactiveHours(double value) + public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue value) { return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour); } @@ -251,7 +252,7 @@ public static ReactiveEnergy FromMegavoltampereReactiveHours(double value) /// /// Creates a from . /// - public static ReactiveEnergy FromVoltampereReactiveHours(double value) + public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue value) { return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour); } @@ -262,7 +263,7 @@ public static ReactiveEnergy FromVoltampereReactiveHours(double value) /// Value to convert from. /// Unit to convert from. /// ReactiveEnergy unit value. - public static ReactiveEnergy From(double value, ReactiveEnergyUnit fromUnit) + public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUnit) { return new ReactiveEnergy(value, fromUnit); } @@ -434,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactiveEnergy operator *(double left, ReactiveEnergy right) + public static ReactiveEnergy operator *(QuantityValue left, ReactiveEnergy right) { return new ReactiveEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactiveEnergy operator *(ReactiveEnergy left, double right) + public static ReactiveEnergy operator *(ReactiveEnergy left, QuantityValue right) { return new ReactiveEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactiveEnergy operator /(ReactiveEnergy left, double right) + public static ReactiveEnergy operator /(ReactiveEnergy left, QuantityValue right) { return new ReactiveEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReactiveEnergy left, ReactiveEnergy right) + public static QuantityValue operator /(ReactiveEnergy left, ReactiveEnergy right) { return left.VoltampereReactiveHours / right.VoltampereReactiveHours; } @@ -485,27 +486,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ReactiveEnergy otherQuantity)) @@ -515,15 +509,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ReactiveEnergy other, ReactiveEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ReactiveEnergy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -606,10 +597,10 @@ public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -626,7 +617,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReactiveEnergy other, ReactiveEnergy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -639,7 +630,12 @@ public bool Equals(ReactiveEnergy other, ReactiveEnergy tolerance) /// A hash code for the current ReactiveEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -650,7 +646,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactiveEnergyUnit unit) + public QuantityValue As(ReactiveEnergyUnit unit) { if (Unit == unit) return Value; @@ -659,7 +655,7 @@ public double As(ReactiveEnergyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,7 +670,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); @@ -740,12 +736,12 @@ private bool TryToUnit(ReactiveEnergyUnit unit, [NotNullWhen(true)] out Reactive ReactiveEnergy? convertedOrNull = (Unit, unit) switch { // ReactiveEnergyUnit -> BaseUnit - (ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergyUnit.VoltampereReactiveHour) => new ReactiveEnergy((_value) * 1e3d, ReactiveEnergyUnit.VoltampereReactiveHour), - (ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergyUnit.VoltampereReactiveHour) => new ReactiveEnergy((_value) * 1e6d, ReactiveEnergyUnit.VoltampereReactiveHour), + (ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergyUnit.VoltampereReactiveHour) => new ReactiveEnergy(_value * 1000, ReactiveEnergyUnit.VoltampereReactiveHour), + (ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergyUnit.VoltampereReactiveHour) => new ReactiveEnergy(_value * 1000000, ReactiveEnergyUnit.VoltampereReactiveHour), // BaseUnit -> ReactiveEnergyUnit - (ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.KilovoltampereReactiveHour) => new ReactiveEnergy((_value) / 1e3d, ReactiveEnergyUnit.KilovoltampereReactiveHour), - (ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.MegavoltampereReactiveHour) => new ReactiveEnergy((_value) / 1e6d, ReactiveEnergyUnit.MegavoltampereReactiveHour), + (ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.KilovoltampereReactiveHour) => new ReactiveEnergy(_value / 1000, ReactiveEnergyUnit.KilovoltampereReactiveHour), + (ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.MegavoltampereReactiveHour) => new ReactiveEnergy(_value / 1000000, ReactiveEnergyUnit.MegavoltampereReactiveHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 44d0f391d1..c4831af323 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static ReactivePower() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ReactivePower(double value, ReactivePowerUnit unit) + public ReactivePower(QuantityValue value, ReactivePowerUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public ReactivePower(double value, ReactivePowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactivePower(double value, UnitSystem unitSystem) + public ReactivePower(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,22 +175,22 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); + public QuantityValue GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); /// /// Gets a value of this quantity converted into /// - public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); + public QuantityValue KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); /// /// Gets a value of this quantity converted into /// - public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); + public QuantityValue MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); /// /// Gets a value of this quantity converted into /// - public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); + public QuantityValue VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); #endregion @@ -243,7 +244,7 @@ public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? pr /// /// Creates a from . /// - public static ReactivePower FromGigavoltamperesReactive(double value) + public static ReactivePower FromGigavoltamperesReactive(QuantityValue value) { return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive); } @@ -251,7 +252,7 @@ public static ReactivePower FromGigavoltamperesReactive(double value) /// /// Creates a from . /// - public static ReactivePower FromKilovoltamperesReactive(double value) + public static ReactivePower FromKilovoltamperesReactive(QuantityValue value) { return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive); } @@ -259,7 +260,7 @@ public static ReactivePower FromKilovoltamperesReactive(double value) /// /// Creates a from . /// - public static ReactivePower FromMegavoltamperesReactive(double value) + public static ReactivePower FromMegavoltamperesReactive(QuantityValue value) { return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive); } @@ -267,7 +268,7 @@ public static ReactivePower FromMegavoltamperesReactive(double value) /// /// Creates a from . /// - public static ReactivePower FromVoltamperesReactive(double value) + public static ReactivePower FromVoltamperesReactive(QuantityValue value) { return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive); } @@ -278,7 +279,7 @@ public static ReactivePower FromVoltamperesReactive(double value) /// Value to convert from. /// Unit to convert from. /// ReactivePower unit value. - public static ReactivePower From(double value, ReactivePowerUnit fromUnit) + public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit) { return new ReactivePower(value, fromUnit); } @@ -450,25 +451,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactivePower operator *(double left, ReactivePower right) + public static ReactivePower operator *(QuantityValue left, ReactivePower right) { return new ReactivePower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactivePower operator *(ReactivePower left, double right) + public static ReactivePower operator *(ReactivePower left, QuantityValue right) { return new ReactivePower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactivePower operator /(ReactivePower left, double right) + public static ReactivePower operator /(ReactivePower left, QuantityValue right) { return new ReactivePower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReactivePower left, ReactivePower right) + public static QuantityValue operator /(ReactivePower left, ReactivePower right) { return left.VoltamperesReactive / right.VoltamperesReactive; } @@ -501,27 +502,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ReactivePower left, ReactivePower right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ReactivePower left, ReactivePower right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ReactivePower otherQuantity)) @@ -531,15 +525,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(ReactivePower other, ReactivePower tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(ReactivePower other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -622,10 +613,10 @@ public bool Equals(ReactivePower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -642,7 +633,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReactivePower other, ReactivePower tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -655,7 +646,12 @@ public bool Equals(ReactivePower other, ReactivePower tolerance) /// A hash code for the current ReactivePower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -666,7 +662,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactivePowerUnit unit) + public QuantityValue As(ReactivePowerUnit unit) { if (Unit == unit) return Value; @@ -675,7 +671,7 @@ public double As(ReactivePowerUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -690,7 +686,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); @@ -756,14 +752,14 @@ private bool TryToUnit(ReactivePowerUnit unit, [NotNullWhen(true)] out ReactiveP ReactivePower? convertedOrNull = (Unit, unit) switch { // ReactivePowerUnit -> BaseUnit - (ReactivePowerUnit.GigavoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower((_value) * 1e9d, ReactivePowerUnit.VoltampereReactive), - (ReactivePowerUnit.KilovoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower((_value) * 1e3d, ReactivePowerUnit.VoltampereReactive), - (ReactivePowerUnit.MegavoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower((_value) * 1e6d, ReactivePowerUnit.VoltampereReactive), + (ReactivePowerUnit.GigavoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower(_value * 1000000000, ReactivePowerUnit.VoltampereReactive), + (ReactivePowerUnit.KilovoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower(_value * 1000, ReactivePowerUnit.VoltampereReactive), + (ReactivePowerUnit.MegavoltampereReactive, ReactivePowerUnit.VoltampereReactive) => new ReactivePower(_value * 1000000, ReactivePowerUnit.VoltampereReactive), // BaseUnit -> ReactivePowerUnit - (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.GigavoltampereReactive) => new ReactivePower((_value) / 1e9d, ReactivePowerUnit.GigavoltampereReactive), - (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.KilovoltampereReactive) => new ReactivePower((_value) / 1e3d, ReactivePowerUnit.KilovoltampereReactive), - (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.MegavoltampereReactive) => new ReactivePower((_value) / 1e6d, ReactivePowerUnit.MegavoltampereReactive), + (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.GigavoltampereReactive) => new ReactivePower(_value / 1000000000, ReactivePowerUnit.GigavoltampereReactive), + (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.KilovoltampereReactive) => new ReactivePower(_value / 1000, ReactivePowerUnit.KilovoltampereReactive), + (ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.MegavoltampereReactive) => new ReactivePower(_value / 1000000, ReactivePowerUnit.MegavoltampereReactive), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 8bf4af8a24..6b549f8d64 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -45,6 +43,7 @@ namespace UnitsNet public readonly partial struct ReciprocalArea : IArithmeticQuantity, #if NET7_0_OR_GREATER + IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, IMultiplyOperators, @@ -60,7 +59,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -100,7 +99,7 @@ static ReciprocalArea() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ReciprocalArea(double value, ReciprocalAreaUnit unit) + public ReciprocalArea(QuantityValue value, ReciprocalAreaUnit unit) { _value = value; _unit = unit; @@ -114,7 +113,7 @@ public ReciprocalArea(double value, ReciprocalAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalArea(double value, UnitSystem unitSystem) + public ReciprocalArea(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -165,10 +164,10 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -193,57 +192,57 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); + public QuantityValue InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); /// /// Gets a value of this quantity converted into /// - public double InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); + public QuantityValue InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); /// /// Gets a value of this quantity converted into /// - public double InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); + public QuantityValue InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); /// /// Gets a value of this quantity converted into /// - public double InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); + public QuantityValue InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); /// /// Gets a value of this quantity converted into /// - public double InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); + public QuantityValue InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); /// /// Gets a value of this quantity converted into /// - public double InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); + public QuantityValue InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); /// /// Gets a value of this quantity converted into /// - public double InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); + public QuantityValue InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); /// /// Gets a value of this quantity converted into /// - public double InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); + public QuantityValue InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); /// /// Gets a value of this quantity converted into /// - public double InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); + public QuantityValue InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); /// /// Gets a value of this quantity converted into /// - public double InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); + public QuantityValue InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); /// /// Gets a value of this quantity converted into /// - public double InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); + public QuantityValue InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); #endregion @@ -311,7 +310,7 @@ public static string GetAbbreviation(ReciprocalAreaUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareCentimeters(double value) + public static ReciprocalArea FromInverseSquareCentimeters(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareCentimeter); } @@ -319,7 +318,7 @@ public static ReciprocalArea FromInverseSquareCentimeters(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareDecimeters(double value) + public static ReciprocalArea FromInverseSquareDecimeters(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareDecimeter); } @@ -327,7 +326,7 @@ public static ReciprocalArea FromInverseSquareDecimeters(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareFeet(double value) + public static ReciprocalArea FromInverseSquareFeet(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareFoot); } @@ -335,7 +334,7 @@ public static ReciprocalArea FromInverseSquareFeet(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareInches(double value) + public static ReciprocalArea FromInverseSquareInches(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareInch); } @@ -343,7 +342,7 @@ public static ReciprocalArea FromInverseSquareInches(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareKilometers(double value) + public static ReciprocalArea FromInverseSquareKilometers(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareKilometer); } @@ -351,7 +350,7 @@ public static ReciprocalArea FromInverseSquareKilometers(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareMeters(double value) + public static ReciprocalArea FromInverseSquareMeters(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMeter); } @@ -359,7 +358,7 @@ public static ReciprocalArea FromInverseSquareMeters(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareMicrometers(double value) + public static ReciprocalArea FromInverseSquareMicrometers(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMicrometer); } @@ -367,7 +366,7 @@ public static ReciprocalArea FromInverseSquareMicrometers(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareMiles(double value) + public static ReciprocalArea FromInverseSquareMiles(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMile); } @@ -375,7 +374,7 @@ public static ReciprocalArea FromInverseSquareMiles(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareMillimeters(double value) + public static ReciprocalArea FromInverseSquareMillimeters(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMillimeter); } @@ -383,7 +382,7 @@ public static ReciprocalArea FromInverseSquareMillimeters(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseSquareYards(double value) + public static ReciprocalArea FromInverseSquareYards(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareYard); } @@ -391,7 +390,7 @@ public static ReciprocalArea FromInverseSquareYards(double value) /// /// Creates a from . /// - public static ReciprocalArea FromInverseUsSurveySquareFeet(double value) + public static ReciprocalArea FromInverseUsSurveySquareFeet(QuantityValue value) { return new ReciprocalArea(value, ReciprocalAreaUnit.InverseUsSurveySquareFoot); } @@ -402,7 +401,7 @@ public static ReciprocalArea FromInverseUsSurveySquareFeet(double value) /// Value to convert from. /// Unit to convert from. /// ReciprocalArea unit value. - public static ReciprocalArea From(double value, ReciprocalAreaUnit fromUnit) + public static ReciprocalArea From(QuantityValue value, ReciprocalAreaUnit fromUnit) { return new ReciprocalArea(value, fromUnit); } @@ -574,25 +573,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalArea operator *(double left, ReciprocalArea right) + public static ReciprocalArea operator *(QuantityValue left, ReciprocalArea right) { return new ReciprocalArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalArea operator *(ReciprocalArea left, double right) + public static ReciprocalArea operator *(ReciprocalArea left, QuantityValue right) { return new ReciprocalArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalArea operator /(ReciprocalArea left, double right) + public static ReciprocalArea operator /(ReciprocalArea left, QuantityValue right) { return new ReciprocalArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReciprocalArea left, ReciprocalArea right) + public static QuantityValue operator /(ReciprocalArea left, ReciprocalArea right) { return left.InverseSquareMeters / right.InverseSquareMeters; } @@ -605,7 +604,13 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip /// The corresponding inverse quantity, . public Area Inverse() { - return InverseSquareMeters == 0.0 ? Area.Zero : Area.FromSquareMeters(1 / InverseSquareMeters); + return Area.FromSquareMeters(QuantityValue.Inverse(InverseSquareMeters)); + } + + /// Get from * . + public static Length operator *(ReciprocalArea reciprocalArea, Volume volume) + { + return Length.FromMeters(reciprocalArea.InverseSquareMeters * volume.CubicMeters); } /// Get from * . @@ -660,27 +665,20 @@ public Area Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ReciprocalArea left, ReciprocalArea right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalArea other, ReciprocalArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ReciprocalArea left, ReciprocalArea right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ReciprocalArea otherQuantity)) @@ -690,15 +688,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ReciprocalArea other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -781,10 +776,10 @@ public bool Equals(ReciprocalArea other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -801,7 +796,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReciprocalArea other, ReciprocalArea tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -814,7 +809,12 @@ public bool Equals(ReciprocalArea other, ReciprocalArea tolerance) /// A hash code for the current ReciprocalArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -825,7 +825,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalAreaUnit unit) + public QuantityValue As(ReciprocalAreaUnit unit) { if (Unit == unit) return Value; @@ -834,7 +834,7 @@ public double As(ReciprocalAreaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -849,7 +849,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); @@ -915,28 +915,28 @@ private bool TryToUnit(ReciprocalAreaUnit unit, [NotNullWhen(true)] out Reciproc ReciprocalArea? convertedOrNull = (Unit, unit) switch { // ReciprocalAreaUnit -> BaseUnit - (ReciprocalAreaUnit.InverseSquareCentimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1e-4, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareDecimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1e-2, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareFoot, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 0.092903, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareInch, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 0.00064516, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareKilometer, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1e6, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareMicrometer, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1e-12, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareMile, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 2.59e6, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareMillimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1e-6, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseSquareYard, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 0.836127, ReciprocalAreaUnit.InverseSquareMeter), - (ReciprocalAreaUnit.InverseUsSurveySquareFoot, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 0.09290341161, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareCentimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * 10000, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareDecimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * 100, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareFoot, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * new QuantityValue(1000000, 92903, false), ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareInch, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * new QuantityValue(25000000, 16129, false), ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareKilometer, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 1000000, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareMicrometer, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * 1000000000000, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareMile, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value / 2590000, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareMillimeter, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * 1000000, ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseSquareYard, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * new QuantityValue(1000000, 836127, false), ReciprocalAreaUnit.InverseSquareMeter), + (ReciprocalAreaUnit.InverseUsSurveySquareFoot, ReciprocalAreaUnit.InverseSquareMeter) => new ReciprocalArea(_value * new QuantityValue(100000000000, 9290341161, false), ReciprocalAreaUnit.InverseSquareMeter), // BaseUnit -> ReciprocalAreaUnit - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareCentimeter) => new ReciprocalArea(_value * 1e-4, ReciprocalAreaUnit.InverseSquareCentimeter), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareDecimeter) => new ReciprocalArea(_value * 1e-2, ReciprocalAreaUnit.InverseSquareDecimeter), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareFoot) => new ReciprocalArea(_value * 0.092903, ReciprocalAreaUnit.InverseSquareFoot), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareInch) => new ReciprocalArea(_value * 0.00064516, ReciprocalAreaUnit.InverseSquareInch), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareKilometer) => new ReciprocalArea(_value * 1e6, ReciprocalAreaUnit.InverseSquareKilometer), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMicrometer) => new ReciprocalArea(_value * 1e-12, ReciprocalAreaUnit.InverseSquareMicrometer), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMile) => new ReciprocalArea(_value * 2.59e6, ReciprocalAreaUnit.InverseSquareMile), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMillimeter) => new ReciprocalArea(_value * 1e-6, ReciprocalAreaUnit.InverseSquareMillimeter), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareYard) => new ReciprocalArea(_value * 0.836127, ReciprocalAreaUnit.InverseSquareYard), - (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseUsSurveySquareFoot) => new ReciprocalArea(_value * 0.09290341161, ReciprocalAreaUnit.InverseUsSurveySquareFoot), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareCentimeter) => new ReciprocalArea(_value / 10000, ReciprocalAreaUnit.InverseSquareCentimeter), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareDecimeter) => new ReciprocalArea(_value / 100, ReciprocalAreaUnit.InverseSquareDecimeter), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareFoot) => new ReciprocalArea(_value * new QuantityValue(92903, 1000000, false), ReciprocalAreaUnit.InverseSquareFoot), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareInch) => new ReciprocalArea(_value * new QuantityValue(16129, 25000000, false), ReciprocalAreaUnit.InverseSquareInch), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareKilometer) => new ReciprocalArea(_value * 1000000, ReciprocalAreaUnit.InverseSquareKilometer), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMicrometer) => new ReciprocalArea(_value / 1000000000000, ReciprocalAreaUnit.InverseSquareMicrometer), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMile) => new ReciprocalArea(_value * 2590000, ReciprocalAreaUnit.InverseSquareMile), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMillimeter) => new ReciprocalArea(_value / 1000000, ReciprocalAreaUnit.InverseSquareMillimeter), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareYard) => new ReciprocalArea(_value * new QuantityValue(836127, 1000000, false), ReciprocalAreaUnit.InverseSquareYard), + (ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseUsSurveySquareFoot) => new ReciprocalArea(_value * new QuantityValue(9290341161, 100000000000, false), ReciprocalAreaUnit.InverseUsSurveySquareFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 8fa5f8bcd3..4830391a67 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -45,7 +43,9 @@ namespace UnitsNet public readonly partial struct ReciprocalLength : IArithmeticQuantity, #if NET7_0_OR_GREATER + IMultiplyOperators, IMultiplyOperators, + IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, @@ -61,7 +61,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -100,7 +100,7 @@ static ReciprocalLength() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ReciprocalLength(double value, ReciprocalLengthUnit unit) + public ReciprocalLength(QuantityValue value, ReciprocalLengthUnit unit) { _value = value; _unit = unit; @@ -114,7 +114,7 @@ public ReciprocalLength(double value, ReciprocalLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalLength(double value, UnitSystem unitSystem) + public ReciprocalLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -165,10 +165,10 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -193,52 +193,52 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); + public QuantityValue InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); /// /// Gets a value of this quantity converted into /// - public double InverseFeet => As(ReciprocalLengthUnit.InverseFoot); + public QuantityValue InverseFeet => As(ReciprocalLengthUnit.InverseFoot); /// /// Gets a value of this quantity converted into /// - public double InverseInches => As(ReciprocalLengthUnit.InverseInch); + public QuantityValue InverseInches => As(ReciprocalLengthUnit.InverseInch); /// /// Gets a value of this quantity converted into /// - public double InverseMeters => As(ReciprocalLengthUnit.InverseMeter); + public QuantityValue InverseMeters => As(ReciprocalLengthUnit.InverseMeter); /// /// Gets a value of this quantity converted into /// - public double InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); + public QuantityValue InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); /// /// Gets a value of this quantity converted into /// - public double InverseMils => As(ReciprocalLengthUnit.InverseMil); + public QuantityValue InverseMils => As(ReciprocalLengthUnit.InverseMil); /// /// Gets a value of this quantity converted into /// - public double InverseMiles => As(ReciprocalLengthUnit.InverseMile); + public QuantityValue InverseMiles => As(ReciprocalLengthUnit.InverseMile); /// /// Gets a value of this quantity converted into /// - public double InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); + public QuantityValue InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); /// /// Gets a value of this quantity converted into /// - public double InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); + public QuantityValue InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); /// /// Gets a value of this quantity converted into /// - public double InverseYards => As(ReciprocalLengthUnit.InverseYard); + public QuantityValue InverseYards => As(ReciprocalLengthUnit.InverseYard); #endregion @@ -304,7 +304,7 @@ public static string GetAbbreviation(ReciprocalLengthUnit unit, IFormatProvider? /// /// Creates a from . /// - public static ReciprocalLength FromInverseCentimeters(double value) + public static ReciprocalLength FromInverseCentimeters(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseCentimeter); } @@ -312,7 +312,7 @@ public static ReciprocalLength FromInverseCentimeters(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseFeet(double value) + public static ReciprocalLength FromInverseFeet(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseFoot); } @@ -320,7 +320,7 @@ public static ReciprocalLength FromInverseFeet(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseInches(double value) + public static ReciprocalLength FromInverseInches(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseInch); } @@ -328,7 +328,7 @@ public static ReciprocalLength FromInverseInches(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseMeters(double value) + public static ReciprocalLength FromInverseMeters(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMeter); } @@ -336,7 +336,7 @@ public static ReciprocalLength FromInverseMeters(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseMicroinches(double value) + public static ReciprocalLength FromInverseMicroinches(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMicroinch); } @@ -344,7 +344,7 @@ public static ReciprocalLength FromInverseMicroinches(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseMils(double value) + public static ReciprocalLength FromInverseMils(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMil); } @@ -352,7 +352,7 @@ public static ReciprocalLength FromInverseMils(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseMiles(double value) + public static ReciprocalLength FromInverseMiles(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMile); } @@ -360,7 +360,7 @@ public static ReciprocalLength FromInverseMiles(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseMillimeters(double value) + public static ReciprocalLength FromInverseMillimeters(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMillimeter); } @@ -368,7 +368,7 @@ public static ReciprocalLength FromInverseMillimeters(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseUsSurveyFeet(double value) + public static ReciprocalLength FromInverseUsSurveyFeet(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseUsSurveyFoot); } @@ -376,7 +376,7 @@ public static ReciprocalLength FromInverseUsSurveyFeet(double value) /// /// Creates a from . /// - public static ReciprocalLength FromInverseYards(double value) + public static ReciprocalLength FromInverseYards(QuantityValue value) { return new ReciprocalLength(value, ReciprocalLengthUnit.InverseYard); } @@ -387,7 +387,7 @@ public static ReciprocalLength FromInverseYards(double value) /// Value to convert from. /// Unit to convert from. /// ReciprocalLength unit value. - public static ReciprocalLength From(double value, ReciprocalLengthUnit fromUnit) + public static ReciprocalLength From(QuantityValue value, ReciprocalLengthUnit fromUnit) { return new ReciprocalLength(value, fromUnit); } @@ -559,25 +559,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalLength operator *(double left, ReciprocalLength right) + public static ReciprocalLength operator *(QuantityValue left, ReciprocalLength right) { return new ReciprocalLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalLength operator *(ReciprocalLength left, double right) + public static ReciprocalLength operator *(ReciprocalLength left, QuantityValue right) { return new ReciprocalLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalLength operator /(ReciprocalLength left, double right) + public static ReciprocalLength operator /(ReciprocalLength left, QuantityValue right) { return new ReciprocalLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReciprocalLength left, ReciprocalLength right) + public static QuantityValue operator /(ReciprocalLength left, ReciprocalLength right) { return left.InverseMeters / right.InverseMeters; } @@ -590,7 +590,13 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip /// The corresponding inverse quantity, . public Length Inverse() { - return InverseMeters == 0.0 ? Length.Zero : Length.FromMeters(1 / InverseMeters); + return Length.FromMeters(QuantityValue.Inverse(InverseMeters)); + } + + /// Get from * . + public static Area operator *(ReciprocalLength reciprocalLength, Volume volume) + { + return Area.FromSquareMeters(reciprocalLength.InverseMeters * volume.CubicMeters); } /// Get from * . @@ -599,6 +605,12 @@ public Length Inverse() return ForcePerLength.FromNewtonsPerMeter(reciprocalLength.InverseMeters * force.Newtons); } + /// Get from * . + public static Length operator *(ReciprocalLength reciprocalLength, Area area) + { + return Length.FromMeters(reciprocalLength.InverseMeters * area.SquareMeters); + } + /// Get from / . public static Length operator /(ReciprocalLength reciprocalLength, ReciprocalArea reciprocalArea) { @@ -651,27 +663,20 @@ public Length Inverse() return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ReciprocalLength left, ReciprocalLength right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ReciprocalLength other, ReciprocalLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ReciprocalLength left, ReciprocalLength right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ReciprocalLength otherQuantity)) @@ -681,15 +686,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ReciprocalLength other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -772,10 +774,10 @@ public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -792,7 +794,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ReciprocalLength other, ReciprocalLength tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -805,7 +807,12 @@ public bool Equals(ReciprocalLength other, ReciprocalLength tolerance) /// A hash code for the current ReciprocalLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -816,7 +823,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalLengthUnit unit) + public QuantityValue As(ReciprocalLengthUnit unit) { if (Unit == unit) return Value; @@ -825,7 +832,7 @@ public double As(ReciprocalLengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -840,7 +847,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); @@ -906,26 +913,26 @@ private bool TryToUnit(ReciprocalLengthUnit unit, [NotNullWhen(true)] out Recipr ReciprocalLength? convertedOrNull = (Unit, unit) switch { // ReciprocalLengthUnit -> BaseUnit - (ReciprocalLengthUnit.InverseCentimeter, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * 1e2, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseFoot, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 0.3048, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseInch, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 2.54e-2, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseMicroinch, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 2.54e-8, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseMil, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 2.54e-5, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseMile, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 1609.344, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseMillimeter, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * 1e3, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseUsSurveyFoot, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * 3937 / 1200, ReciprocalLengthUnit.InverseMeter), - (ReciprocalLengthUnit.InverseYard, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value / 0.9144, ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseCentimeter, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * 100, ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseFoot, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(1250, 381, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseInch, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(5000, 127, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseMicroinch, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(5000000000, 127, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseMil, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(5000000, 127, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseMile, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(125, 201168, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseMillimeter, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * 1000, ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseUsSurveyFoot, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(3937, 1200, false), ReciprocalLengthUnit.InverseMeter), + (ReciprocalLengthUnit.InverseYard, ReciprocalLengthUnit.InverseMeter) => new ReciprocalLength(_value * new QuantityValue(1250, 1143, false), ReciprocalLengthUnit.InverseMeter), // BaseUnit -> ReciprocalLengthUnit - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseCentimeter) => new ReciprocalLength(_value / 1e2, ReciprocalLengthUnit.InverseCentimeter), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseFoot) => new ReciprocalLength(_value * 0.3048, ReciprocalLengthUnit.InverseFoot), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseInch) => new ReciprocalLength(_value * 2.54e-2, ReciprocalLengthUnit.InverseInch), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMicroinch) => new ReciprocalLength(_value * 2.54e-8, ReciprocalLengthUnit.InverseMicroinch), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMil) => new ReciprocalLength(_value * 2.54e-5, ReciprocalLengthUnit.InverseMil), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMile) => new ReciprocalLength(_value * 1609.344, ReciprocalLengthUnit.InverseMile), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMillimeter) => new ReciprocalLength(_value / 1e3, ReciprocalLengthUnit.InverseMillimeter), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseUsSurveyFoot) => new ReciprocalLength(_value * 1200 / 3937, ReciprocalLengthUnit.InverseUsSurveyFoot), - (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseYard) => new ReciprocalLength(_value * 0.9144, ReciprocalLengthUnit.InverseYard), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseCentimeter) => new ReciprocalLength(_value / 100, ReciprocalLengthUnit.InverseCentimeter), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseFoot) => new ReciprocalLength(_value * new QuantityValue(381, 1250, false), ReciprocalLengthUnit.InverseFoot), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseInch) => new ReciprocalLength(_value * new QuantityValue(127, 5000, false), ReciprocalLengthUnit.InverseInch), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMicroinch) => new ReciprocalLength(_value * new QuantityValue(127, 5000000000, false), ReciprocalLengthUnit.InverseMicroinch), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMil) => new ReciprocalLength(_value * new QuantityValue(127, 5000000, false), ReciprocalLengthUnit.InverseMil), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMile) => new ReciprocalLength(_value * new QuantityValue(201168, 125, false), ReciprocalLengthUnit.InverseMile), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMillimeter) => new ReciprocalLength(_value / 1000, ReciprocalLengthUnit.InverseMillimeter), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseUsSurveyFoot) => new ReciprocalLength(_value * new QuantityValue(1200, 3937, false), ReciprocalLengthUnit.InverseUsSurveyFoot), + (ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseYard) => new ReciprocalLength(_value * new QuantityValue(1143, 1250, false), ReciprocalLengthUnit.InverseYard), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 116c8eb447..ca79afc5eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,7 +79,7 @@ static RelativeHumidity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RelativeHumidity(double value, RelativeHumidityUnit unit) + public RelativeHumidity(QuantityValue value, RelativeHumidityUnit unit) { _value = value; _unit = unit; @@ -92,7 +93,7 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RelativeHumidity(double value, UnitSystem unitSystem) + public RelativeHumidity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -143,10 +144,10 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,7 +172,7 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Percent => As(RelativeHumidityUnit.Percent); + public QuantityValue Percent => As(RelativeHumidityUnit.Percent); #endregion @@ -219,7 +220,7 @@ public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? /// /// Creates a from . /// - public static RelativeHumidity FromPercent(double value) + public static RelativeHumidity FromPercent(QuantityValue value) { return new RelativeHumidity(value, RelativeHumidityUnit.Percent); } @@ -230,7 +231,7 @@ public static RelativeHumidity FromPercent(double value) /// Value to convert from. /// Unit to convert from. /// RelativeHumidity unit value. - public static RelativeHumidity From(double value, RelativeHumidityUnit fromUnit) + public static RelativeHumidity From(QuantityValue value, RelativeHumidityUnit fromUnit) { return new RelativeHumidity(value, fromUnit); } @@ -402,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat } /// Get from multiplying value and . - public static RelativeHumidity operator *(double left, RelativeHumidity right) + public static RelativeHumidity operator *(QuantityValue left, RelativeHumidity right) { return new RelativeHumidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RelativeHumidity operator *(RelativeHumidity left, double right) + public static RelativeHumidity operator *(RelativeHumidity left, QuantityValue right) { return new RelativeHumidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RelativeHumidity operator /(RelativeHumidity left, double right) + public static RelativeHumidity operator /(RelativeHumidity left, QuantityValue right) { return new RelativeHumidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RelativeHumidity left, RelativeHumidity right) + public static QuantityValue operator /(RelativeHumidity left, RelativeHumidity right) { return left.Percent / right.Percent; } @@ -453,27 +454,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RelativeHumidity left, RelativeHumidity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RelativeHumidity other, RelativeHumidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RelativeHumidity left, RelativeHumidity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RelativeHumidity otherQuantity)) @@ -483,15 +477,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RelativeHumidity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +565,10 @@ public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -594,7 +585,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RelativeHumidity other, RelativeHumidity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -607,7 +598,12 @@ public bool Equals(RelativeHumidity other, RelativeHumidity tolerance) /// A hash code for the current RelativeHumidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -618,7 +614,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RelativeHumidityUnit unit) + public QuantityValue As(RelativeHumidityUnit unit) { if (Unit == unit) return Value; @@ -627,7 +623,7 @@ public double As(RelativeHumidityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -642,7 +638,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 27470da99b..5d431301f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static RotationalAcceleration() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RotationalAcceleration(double value, RotationalAccelerationUnit unit) + public RotationalAcceleration(QuantityValue value, RotationalAccelerationUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public RotationalAcceleration(double value, RotationalAccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalAcceleration(double value, UnitSystem unitSystem) + public RotationalAcceleration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,22 +175,22 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); + public QuantityValue DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); + public QuantityValue RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); /// /// Gets a value of this quantity converted into /// - public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + public QuantityValue RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); /// /// Gets a value of this quantity converted into /// - public double RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); + public QuantityValue RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); #endregion @@ -243,7 +244,7 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatPro /// /// Creates a from . /// - public static RotationalAcceleration FromDegreesPerSecondSquared(double value) + public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue value) { return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared); } @@ -251,7 +252,7 @@ public static RotationalAcceleration FromDegreesPerSecondSquared(double value) /// /// Creates a from . /// - public static RotationalAcceleration FromRadiansPerSecondSquared(double value) + public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue value) { return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared); } @@ -259,7 +260,7 @@ public static RotationalAcceleration FromRadiansPerSecondSquared(double value) /// /// Creates a from . /// - public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(double value) + public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityValue value) { return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); } @@ -267,7 +268,7 @@ public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(double va /// /// Creates a from . /// - public static RotationalAcceleration FromRevolutionsPerSecondSquared(double value) + public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityValue value) { return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerSecondSquared); } @@ -278,7 +279,7 @@ public static RotationalAcceleration FromRevolutionsPerSecondSquared(double valu /// Value to convert from. /// Unit to convert from. /// RotationalAcceleration unit value. - public static RotationalAcceleration From(double value, RotationalAccelerationUnit fromUnit) + public static RotationalAcceleration From(QuantityValue value, RotationalAccelerationUnit fromUnit) { return new RotationalAcceleration(value, fromUnit); } @@ -450,25 +451,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalAcceleration operator *(double left, RotationalAcceleration right) + public static RotationalAcceleration operator *(QuantityValue left, RotationalAcceleration right) { return new RotationalAcceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalAcceleration operator *(RotationalAcceleration left, double right) + public static RotationalAcceleration operator *(RotationalAcceleration left, QuantityValue right) { return new RotationalAcceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalAcceleration operator /(RotationalAcceleration left, double right) + public static RotationalAcceleration operator /(RotationalAcceleration left, QuantityValue right) { return new RotationalAcceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalAcceleration left, RotationalAcceleration right) + public static QuantityValue operator /(RotationalAcceleration left, RotationalAcceleration right) { return left.RadiansPerSecondSquared / right.RadiansPerSecondSquared; } @@ -501,27 +502,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalAcceleration other, RotationalAcceleration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalAcceleration otherQuantity)) @@ -531,15 +525,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RotationalAcceleration other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -622,10 +613,10 @@ public bool Equals(RotationalAcceleration other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -642,7 +633,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalAcceleration other, RotationalAcceleration tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -655,7 +646,12 @@ public bool Equals(RotationalAcceleration other, RotationalAcceleration toleranc /// A hash code for the current RotationalAcceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -666,7 +662,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalAccelerationUnit unit) + public QuantityValue As(RotationalAccelerationUnit unit) { if (Unit == unit) return Value; @@ -675,7 +671,7 @@ public double As(RotationalAccelerationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -690,7 +686,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); @@ -756,14 +752,14 @@ private bool TryToUnit(RotationalAccelerationUnit unit, [NotNullWhen(true)] out RotationalAcceleration? convertedOrNull = (Unit, unit) switch { // RotationalAccelerationUnit -> BaseUnit - (RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration((Math.PI / 180) * _value, RotationalAccelerationUnit.RadianPerSecondSquared), - (RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration(((2 * Math.PI) / 60) * _value, RotationalAccelerationUnit.RadianPerSecondSquared), - (RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration((2 * Math.PI) * _value, RotationalAccelerationUnit.RadianPerSecondSquared), + (RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration(_value * new QuantityValue(314159265358979, 18000000000000000, false), RotationalAccelerationUnit.RadianPerSecondSquared), + (RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration(_value * new QuantityValue(314159265358979, 3000000000000000, false), RotationalAccelerationUnit.RadianPerSecondSquared), + (RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAccelerationUnit.RadianPerSecondSquared) => new RotationalAcceleration(_value * new QuantityValue(314159265358979, 50000000000000, false), RotationalAccelerationUnit.RadianPerSecondSquared), // BaseUnit -> RotationalAccelerationUnit - (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.DegreePerSecondSquared) => new RotationalAcceleration((180 / Math.PI) * _value, RotationalAccelerationUnit.DegreePerSecondSquared), - (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerMinutePerSecond) => new RotationalAcceleration((60 / (2 * Math.PI)) * _value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond), - (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerSecondSquared) => new RotationalAcceleration((1 / (2 * Math.PI)) * _value, RotationalAccelerationUnit.RevolutionPerSecondSquared), + (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.DegreePerSecondSquared) => new RotationalAcceleration(_value * new QuantityValue(18000000000000000, 314159265358979, false), RotationalAccelerationUnit.DegreePerSecondSquared), + (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerMinutePerSecond) => new RotationalAcceleration(_value * new QuantityValue(3000000000000000, 314159265358979, false), RotationalAccelerationUnit.RevolutionPerMinutePerSecond), + (RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerSecondSquared) => new RotationalAcceleration(_value * new QuantityValue(50000000000000, 314159265358979, false), RotationalAccelerationUnit.RevolutionPerSecondSquared), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 2f917223fa..8af008ca36 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +95,7 @@ static RotationalSpeed() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RotationalSpeed(double value, RotationalSpeedUnit unit) + public RotationalSpeed(QuantityValue value, RotationalSpeedUnit unit) { _value = value; _unit = unit; @@ -111,7 +109,7 @@ public RotationalSpeed(double value, RotationalSpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalSpeed(double value, UnitSystem unitSystem) + public RotationalSpeed(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,10 +160,10 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -190,67 +188,67 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); + public QuantityValue CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); /// /// Gets a value of this quantity converted into /// - public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); + public QuantityValue DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); /// /// Gets a value of this quantity converted into /// - public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); + public QuantityValue DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); /// /// Gets a value of this quantity converted into /// - public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); + public QuantityValue DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); /// /// Gets a value of this quantity converted into /// - public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); + public QuantityValue MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); /// /// Gets a value of this quantity converted into /// - public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); + public QuantityValue MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); + public QuantityValue MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); /// /// Gets a value of this quantity converted into /// - public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); + public QuantityValue MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); + public QuantityValue NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); /// /// Gets a value of this quantity converted into /// - public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); + public QuantityValue NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); /// /// Gets a value of this quantity converted into /// - public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); + public QuantityValue RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); /// /// Gets a value of this quantity converted into /// - public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); + public QuantityValue RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); /// /// Gets a value of this quantity converted into /// - public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); + public QuantityValue RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); #endregion @@ -322,7 +320,7 @@ public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? /// /// Creates a from . /// - public static RotationalSpeed FromCentiradiansPerSecond(double value) + public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond); } @@ -330,7 +328,7 @@ public static RotationalSpeed FromCentiradiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromDeciradiansPerSecond(double value) + public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond); } @@ -338,7 +336,7 @@ public static RotationalSpeed FromDeciradiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromDegreesPerMinute(double value) + public static RotationalSpeed FromDegreesPerMinute(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute); } @@ -346,7 +344,7 @@ public static RotationalSpeed FromDegreesPerMinute(double value) /// /// Creates a from . /// - public static RotationalSpeed FromDegreesPerSecond(double value) + public static RotationalSpeed FromDegreesPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond); } @@ -354,7 +352,7 @@ public static RotationalSpeed FromDegreesPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromMicrodegreesPerSecond(double value) + public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond); } @@ -362,7 +360,7 @@ public static RotationalSpeed FromMicrodegreesPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromMicroradiansPerSecond(double value) + public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond); } @@ -370,7 +368,7 @@ public static RotationalSpeed FromMicroradiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromMillidegreesPerSecond(double value) + public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond); } @@ -378,7 +376,7 @@ public static RotationalSpeed FromMillidegreesPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromMilliradiansPerSecond(double value) + public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond); } @@ -386,7 +384,7 @@ public static RotationalSpeed FromMilliradiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromNanodegreesPerSecond(double value) + public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond); } @@ -394,7 +392,7 @@ public static RotationalSpeed FromNanodegreesPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromNanoradiansPerSecond(double value) + public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond); } @@ -402,7 +400,7 @@ public static RotationalSpeed FromNanoradiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromRadiansPerSecond(double value) + public static RotationalSpeed FromRadiansPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond); } @@ -410,7 +408,7 @@ public static RotationalSpeed FromRadiansPerSecond(double value) /// /// Creates a from . /// - public static RotationalSpeed FromRevolutionsPerMinute(double value) + public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute); } @@ -418,7 +416,7 @@ public static RotationalSpeed FromRevolutionsPerMinute(double value) /// /// Creates a from . /// - public static RotationalSpeed FromRevolutionsPerSecond(double value) + public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue value) { return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond); } @@ -429,7 +427,7 @@ public static RotationalSpeed FromRevolutionsPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// RotationalSpeed unit value. - public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit) + public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit) { return new RotationalSpeed(value, fromUnit); } @@ -601,25 +599,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalSpeed operator *(double left, RotationalSpeed right) + public static RotationalSpeed operator *(QuantityValue left, RotationalSpeed right) { return new RotationalSpeed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalSpeed operator *(RotationalSpeed left, double right) + public static RotationalSpeed operator *(RotationalSpeed left, QuantityValue right) { return new RotationalSpeed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalSpeed operator /(RotationalSpeed left, double right) + public static RotationalSpeed operator /(RotationalSpeed left, QuantityValue right) { return new RotationalSpeed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalSpeed left, RotationalSpeed right) + public static QuantityValue operator /(RotationalSpeed left, RotationalSpeed right) { return left.RadiansPerSecond / right.RadiansPerSecond; } @@ -668,27 +666,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RotationalSpeed left, RotationalSpeed right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalSpeed other, RotationalSpeed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RotationalSpeed left, RotationalSpeed right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalSpeed otherQuantity)) @@ -698,15 +689,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RotationalSpeed other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +777,10 @@ public bool Equals(RotationalSpeed other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -809,7 +797,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalSpeed other, RotationalSpeed tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -822,7 +810,12 @@ public bool Equals(RotationalSpeed other, RotationalSpeed tolerance) /// A hash code for the current RotationalSpeed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -833,7 +826,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalSpeedUnit unit) + public QuantityValue As(RotationalSpeedUnit unit) { if (Unit == unit) return Value; @@ -842,7 +835,7 @@ public double As(RotationalSpeedUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -857,7 +850,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); @@ -923,32 +916,32 @@ private bool TryToUnit(RotationalSpeedUnit unit, [NotNullWhen(true)] out Rotatio RotationalSpeed? convertedOrNull = (Unit, unit) switch { // RotationalSpeedUnit -> BaseUnit - (RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value) * 1e-2d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value) * 1e-1d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.DegreePerMinute, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((Math.PI / (180 * 60)) * _value, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.DegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((Math.PI / 180) * _value, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(((Math.PI / 180) * _value) * 1e-6d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value) * 1e-6d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(((Math.PI / 180) * _value) * 1e-3d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value) * 1e-3d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(((Math.PI / 180) * _value) * 1e-9d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value) * 1e-9d, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed((_value * 6.2831853072) / 60, RotationalSpeedUnit.RadianPerSecond), - (RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * 6.2831853072, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value / 100, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value / 10, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.DegreePerMinute, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(314159265358979, 1080000000000000000, false), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.DegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(314159265358979, 18000000000000000, false), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(314159265358979, 1800, false) / BigInteger.Pow(10, 19), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value / 1000000, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(1570796326794895, 9, false) / BigInteger.Pow(10, 19), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value / 1000, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(314159265358979, 1800000, false) / BigInteger.Pow(10, 19), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value / 1000000000, RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(1308996939, 12500000000, false), RotationalSpeedUnit.RadianPerSecond), + (RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeedUnit.RadianPerSecond) => new RotationalSpeed(_value * new QuantityValue(3926990817, 625000000, false), RotationalSpeedUnit.RadianPerSecond), // BaseUnit -> RotationalSpeedUnit - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.CentiradianPerSecond) => new RotationalSpeed((_value) / 1e-2d, RotationalSpeedUnit.CentiradianPerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DeciradianPerSecond) => new RotationalSpeed((_value) / 1e-1d, RotationalSpeedUnit.DeciradianPerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DegreePerMinute) => new RotationalSpeed((180 * 60 / Math.PI) * _value, RotationalSpeedUnit.DegreePerMinute), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DegreePerSecond) => new RotationalSpeed((180 / Math.PI) * _value, RotationalSpeedUnit.DegreePerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MicrodegreePerSecond) => new RotationalSpeed(((180 / Math.PI) * _value) / 1e-6d, RotationalSpeedUnit.MicrodegreePerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MicroradianPerSecond) => new RotationalSpeed((_value) / 1e-6d, RotationalSpeedUnit.MicroradianPerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MillidegreePerSecond) => new RotationalSpeed(((180 / Math.PI) * _value) / 1e-3d, RotationalSpeedUnit.MillidegreePerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MilliradianPerSecond) => new RotationalSpeed((_value) / 1e-3d, RotationalSpeedUnit.MilliradianPerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.NanodegreePerSecond) => new RotationalSpeed(((180 / Math.PI) * _value) / 1e-9d, RotationalSpeedUnit.NanodegreePerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.NanoradianPerSecond) => new RotationalSpeed((_value) / 1e-9d, RotationalSpeedUnit.NanoradianPerSecond), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerMinute) => new RotationalSpeed((_value / 6.2831853072) * 60, RotationalSpeedUnit.RevolutionPerMinute), - (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerSecond) => new RotationalSpeed(_value / 6.2831853072, RotationalSpeedUnit.RevolutionPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.CentiradianPerSecond) => new RotationalSpeed(_value * 100, RotationalSpeedUnit.CentiradianPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DeciradianPerSecond) => new RotationalSpeed(_value * 10, RotationalSpeedUnit.DeciradianPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DegreePerMinute) => new RotationalSpeed(_value * new QuantityValue(1080000000000000000, 314159265358979, false), RotationalSpeedUnit.DegreePerMinute), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.DegreePerSecond) => new RotationalSpeed(_value * new QuantityValue(18000000000000000, 314159265358979, false), RotationalSpeedUnit.DegreePerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MicrodegreePerSecond) => new RotationalSpeed(_value * new QuantityValue(1800, 314159265358979, false) * BigInteger.Pow(10, 19), RotationalSpeedUnit.MicrodegreePerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MicroradianPerSecond) => new RotationalSpeed(_value * 1000000, RotationalSpeedUnit.MicroradianPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MillidegreePerSecond) => new RotationalSpeed(_value * new QuantityValue(9, 1570796326794895, false) * BigInteger.Pow(10, 19), RotationalSpeedUnit.MillidegreePerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.MilliradianPerSecond) => new RotationalSpeed(_value * 1000, RotationalSpeedUnit.MilliradianPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.NanodegreePerSecond) => new RotationalSpeed(_value * new QuantityValue(1800000, 314159265358979, false) * BigInteger.Pow(10, 19), RotationalSpeedUnit.NanodegreePerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.NanoradianPerSecond) => new RotationalSpeed(_value * 1000000000, RotationalSpeedUnit.NanoradianPerSecond), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerMinute) => new RotationalSpeed(_value * new QuantityValue(12500000000, 1308996939, false), RotationalSpeedUnit.RevolutionPerMinute), + (RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerSecond) => new RotationalSpeed(_value * new QuantityValue(625000000, 3926990817, false), RotationalSpeedUnit.RevolutionPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 345fdc1b76..9112abd0cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -56,7 +54,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -118,7 +116,7 @@ static RotationalStiffness() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RotationalStiffness(double value, RotationalStiffnessUnit unit) + public RotationalStiffness(QuantityValue value, RotationalStiffnessUnit unit) { _value = value; _unit = unit; @@ -132,7 +130,7 @@ public RotationalStiffness(double value, RotationalStiffnessUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffness(double value, UnitSystem unitSystem) + public RotationalStiffness(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -183,10 +181,10 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -211,167 +209,167 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); + public QuantityValue CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + public QuantityValue CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + public QuantityValue CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); + public QuantityValue DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + public QuantityValue DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + public QuantityValue DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); + public QuantityValue DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + public QuantityValue DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + public QuantityValue DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); + public QuantityValue KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); + public QuantityValue KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + public QuantityValue KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + public QuantityValue KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + public QuantityValue KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); + public QuantityValue MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); + public QuantityValue MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + public QuantityValue MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + public QuantityValue MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); + public QuantityValue MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + public QuantityValue MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + public QuantityValue MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); + public QuantityValue MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + public QuantityValue MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + public QuantityValue MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); + public QuantityValue NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + public QuantityValue NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + public QuantityValue NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); + public QuantityValue NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); + public QuantityValue NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); + public QuantityValue NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); /// /// Gets a value of this quantity converted into /// - public double NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); + public QuantityValue NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); /// /// Gets a value of this quantity converted into /// - public double PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); + public QuantityValue PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); /// /// Gets a value of this quantity converted into /// - public double PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); + public QuantityValue PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); #endregion @@ -483,7 +481,7 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvid /// /// Creates a from . /// - public static RotationalStiffness FromCentinewtonMetersPerDegree(double value) + public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMeterPerDegree); } @@ -491,7 +489,7 @@ public static RotationalStiffness FromCentinewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromCentinewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); } @@ -499,7 +497,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerDegree(double val /// /// Creates a from . /// - public static RotationalStiffness FromCentinewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); } @@ -507,7 +505,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerRadian(double val /// /// Creates a from . /// - public static RotationalStiffness FromDecanewtonMetersPerDegree(double value) + public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMeterPerDegree); } @@ -515,7 +513,7 @@ public static RotationalStiffness FromDecanewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromDecanewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); } @@ -523,7 +521,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerDegree(double valu /// /// Creates a from . /// - public static RotationalStiffness FromDecanewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); } @@ -531,7 +529,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerRadian(double valu /// /// Creates a from . /// - public static RotationalStiffness FromDecinewtonMetersPerDegree(double value) + public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMeterPerDegree); } @@ -539,7 +537,7 @@ public static RotationalStiffness FromDecinewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromDecinewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); } @@ -547,7 +545,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerDegree(double valu /// /// Creates a from . /// - public static RotationalStiffness FromDecinewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); } @@ -555,7 +553,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerRadian(double valu /// /// Creates a from . /// - public static RotationalStiffness FromKilonewtonMetersPerDegree(double value) + public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerDegree); } @@ -563,7 +561,7 @@ public static RotationalStiffness FromKilonewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromKilonewtonMetersPerRadian(double value) + public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian); } @@ -571,7 +569,7 @@ public static RotationalStiffness FromKilonewtonMetersPerRadian(double value) /// /// Creates a from . /// - public static RotationalStiffness FromKilonewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); } @@ -579,7 +577,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerDegree(double valu /// /// Creates a from . /// - public static RotationalStiffness FromKilonewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); } @@ -587,7 +585,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerRadian(double valu /// /// Creates a from . /// - public static RotationalStiffness FromKilopoundForceFeetPerDegrees(double value) + public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); } @@ -595,7 +593,7 @@ public static RotationalStiffness FromKilopoundForceFeetPerDegrees(double value) /// /// Creates a from . /// - public static RotationalStiffness FromMeganewtonMetersPerDegree(double value) + public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerDegree); } @@ -603,7 +601,7 @@ public static RotationalStiffness FromMeganewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromMeganewtonMetersPerRadian(double value) + public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian); } @@ -611,7 +609,7 @@ public static RotationalStiffness FromMeganewtonMetersPerRadian(double value) /// /// Creates a from . /// - public static RotationalStiffness FromMeganewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); } @@ -619,7 +617,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerDegree(double valu /// /// Creates a from . /// - public static RotationalStiffness FromMeganewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); } @@ -627,7 +625,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerRadian(double valu /// /// Creates a from . /// - public static RotationalStiffness FromMicronewtonMetersPerDegree(double value) + public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMeterPerDegree); } @@ -635,7 +633,7 @@ public static RotationalStiffness FromMicronewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromMicronewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); } @@ -643,7 +641,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerDegree(double val /// /// Creates a from . /// - public static RotationalStiffness FromMicronewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); } @@ -651,7 +649,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerRadian(double val /// /// Creates a from . /// - public static RotationalStiffness FromMillinewtonMetersPerDegree(double value) + public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMeterPerDegree); } @@ -659,7 +657,7 @@ public static RotationalStiffness FromMillinewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromMillinewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); } @@ -667,7 +665,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerDegree(double val /// /// Creates a from . /// - public static RotationalStiffness FromMillinewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); } @@ -675,7 +673,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerRadian(double val /// /// Creates a from . /// - public static RotationalStiffness FromNanonewtonMetersPerDegree(double value) + public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMeterPerDegree); } @@ -683,7 +681,7 @@ public static RotationalStiffness FromNanonewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromNanonewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); } @@ -691,7 +689,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerDegree(double valu /// /// Creates a from . /// - public static RotationalStiffness FromNanonewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); } @@ -699,7 +697,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerRadian(double valu /// /// Creates a from . /// - public static RotationalStiffness FromNewtonMetersPerDegree(double value) + public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerDegree); } @@ -707,7 +705,7 @@ public static RotationalStiffness FromNewtonMetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromNewtonMetersPerRadian(double value) + public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian); } @@ -715,7 +713,7 @@ public static RotationalStiffness FromNewtonMetersPerRadian(double value) /// /// Creates a from . /// - public static RotationalStiffness FromNewtonMillimetersPerDegree(double value) + public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerDegree); } @@ -723,7 +721,7 @@ public static RotationalStiffness FromNewtonMillimetersPerDegree(double value) /// /// Creates a from . /// - public static RotationalStiffness FromNewtonMillimetersPerRadian(double value) + public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerRadian); } @@ -731,7 +729,7 @@ public static RotationalStiffness FromNewtonMillimetersPerRadian(double value) /// /// Creates a from . /// - public static RotationalStiffness FromPoundForceFeetPerRadian(double value) + public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFeetPerRadian); } @@ -739,7 +737,7 @@ public static RotationalStiffness FromPoundForceFeetPerRadian(double value) /// /// Creates a from . /// - public static RotationalStiffness FromPoundForceFeetPerDegrees(double value) + public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue value) { return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFootPerDegrees); } @@ -750,7 +748,7 @@ public static RotationalStiffness FromPoundForceFeetPerDegrees(double value) /// Value to convert from. /// Unit to convert from. /// RotationalStiffness unit value. - public static RotationalStiffness From(double value, RotationalStiffnessUnit fromUnit) + public static RotationalStiffness From(QuantityValue value, RotationalStiffnessUnit fromUnit) { return new RotationalStiffness(value, fromUnit); } @@ -922,25 +920,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffness operator *(double left, RotationalStiffness right) + public static RotationalStiffness operator *(QuantityValue left, RotationalStiffness right) { return new RotationalStiffness(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffness operator *(RotationalStiffness left, double right) + public static RotationalStiffness operator *(RotationalStiffness left, QuantityValue right) { return new RotationalStiffness(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffness operator /(RotationalStiffness left, double right) + public static RotationalStiffness operator /(RotationalStiffness left, QuantityValue right) { return new RotationalStiffness(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalStiffness left, RotationalStiffness right) + public static QuantityValue operator /(RotationalStiffness left, RotationalStiffness right) { return left.NewtonMetersPerRadian / right.NewtonMetersPerRadian; } @@ -995,27 +993,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RotationalStiffness left, RotationalStiffness right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffness other, RotationalStiffness tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RotationalStiffness left, RotationalStiffness right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalStiffness otherQuantity)) @@ -1025,15 +1016,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RotationalStiffness other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1116,10 +1104,10 @@ public bool Equals(RotationalStiffness other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1136,7 +1124,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalStiffness other, RotationalStiffness tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1149,7 +1137,12 @@ public bool Equals(RotationalStiffness other, RotationalStiffness tolerance) /// A hash code for the current RotationalStiffness. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1160,7 +1153,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessUnit unit) + public QuantityValue As(RotationalStiffnessUnit unit) { if (Unit == unit) return Value; @@ -1169,7 +1162,7 @@ public double As(RotationalStiffnessUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1184,7 +1177,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); @@ -1250,72 +1243,72 @@ private bool TryToUnit(RotationalStiffnessUnit unit, [NotNullWhen(true)] out Rot RotationalStiffness? convertedOrNull = (Unit, unit) switch { // RotationalStiffnessUnit -> BaseUnit - (RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e-2d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e-2d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e-2d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e-1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e-1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e-1d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value) * 1e3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 77682.6, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value) * 1e6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e-6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e-6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e-6d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e-3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e-3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e-3d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * (180 / Math.PI)) * 1e-9d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 180 / Math.PI * 0.001) * 1e-9d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness((_value * 0.001) * 1e-9d, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * (180 / Math.PI), RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 180 / Math.PI * 0.001, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 0.001, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 1.3558179483314, RotationalStiffnessUnit.NewtonMeterPerRadian), - (RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 77.6826, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(180000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(180000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 100000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(180000000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(180000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 100, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(1800000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(1800000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 10000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(9, 1570796326794895, false) * BigInteger.Pow(10, 19), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 1000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(388413, 5, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(1800, 314159265358979, false) * BigInteger.Pow(10, 19), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 1000000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(9, 1570796326794895, false) * BigInteger.Pow(10, 19), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * 1000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 1000000000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 1000000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 1000000000000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(18000000000000, 314159265358979, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value / 1000, RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(6779089741657, 5000000000000, false), RotationalStiffnessUnit.NewtonMeterPerRadian), + (RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffnessUnit.NewtonMeterPerRadian) => new RotationalStiffness(_value * new QuantityValue(388413, 5000, false), RotationalStiffnessUnit.NewtonMeterPerRadian), // BaseUnit -> RotationalStiffnessUnit - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e-2d, RotationalStiffnessUnit.CentinewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e-2d, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e-2d, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e1d, RotationalStiffnessUnit.DecanewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e1d, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e1d, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e-1d, RotationalStiffnessUnit.DecinewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e-1d, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e-1d, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e3d, RotationalStiffnessUnit.KilonewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMeterPerRadian) => new RotationalStiffness((_value) / 1e3d, RotationalStiffnessUnit.KilonewtonMeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e3d, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e3d, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilopoundForceFootPerDegrees) => new RotationalStiffness(_value / 77682.6, RotationalStiffnessUnit.KilopoundForceFootPerDegrees), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e6d, RotationalStiffnessUnit.MeganewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMeterPerRadian) => new RotationalStiffness((_value) / 1e6d, RotationalStiffnessUnit.MeganewtonMeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e6d, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e6d, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e-6d, RotationalStiffnessUnit.MicronewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e-6d, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e-6d, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e-3d, RotationalStiffnessUnit.MillinewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e-3d, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e-3d, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMeterPerDegree) => new RotationalStiffness((_value / (180 / Math.PI)) / 1e-9d, RotationalStiffnessUnit.NanonewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree) => new RotationalStiffness((_value / 180 * Math.PI * 1000) / 1e-9d, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian) => new RotationalStiffness((_value * 1000) / 1e-9d, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerDegree) => new RotationalStiffness(_value / (180 / Math.PI), RotationalStiffnessUnit.NewtonMeterPerDegree), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMillimeterPerDegree) => new RotationalStiffness(_value / 180 * Math.PI * 1000, RotationalStiffnessUnit.NewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 180000000000000, false), RotationalStiffnessUnit.CentinewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 180000000000, false), RotationalStiffnessUnit.CentinewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian) => new RotationalStiffness(_value * 100000, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 180000000000000000, false), RotationalStiffnessUnit.DecanewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 180000000000000, false), RotationalStiffnessUnit.DecanewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian) => new RotationalStiffness(_value * 100, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 1800000000000000, false), RotationalStiffnessUnit.DecinewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 1800000000000, false), RotationalStiffnessUnit.DecinewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian) => new RotationalStiffness(_value * 10000, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(1570796326794895, 9, false) / BigInteger.Pow(10, 19), RotationalStiffnessUnit.KilonewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMeterPerRadian) => new RotationalStiffness(_value / 1000, RotationalStiffnessUnit.KilonewtonMeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000000000, false), RotationalStiffnessUnit.KilonewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian) => new RotationalStiffness(_value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.KilopoundForceFootPerDegrees) => new RotationalStiffness(_value * new QuantityValue(5, 388413, false), RotationalStiffnessUnit.KilopoundForceFootPerDegrees), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 1800, false) / BigInteger.Pow(10, 19), RotationalStiffnessUnit.MeganewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMeterPerRadian) => new RotationalStiffness(_value / 1000000, RotationalStiffnessUnit.MeganewtonMeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(1570796326794895, 9, false) / BigInteger.Pow(10, 19), RotationalStiffnessUnit.MeganewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian) => new RotationalStiffness(_value / 1000, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000, false), RotationalStiffnessUnit.MicronewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000, false), RotationalStiffnessUnit.MicronewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian) => new RotationalStiffness(_value * 1000000000, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000000, false), RotationalStiffnessUnit.MillinewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000, false), RotationalStiffnessUnit.MillinewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian) => new RotationalStiffness(_value * 1000000, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000, false), RotationalStiffnessUnit.NanonewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000, false), RotationalStiffnessUnit.NanonewtonMillimeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian) => new RotationalStiffness(_value * 1000000000000, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000000000, false), RotationalStiffnessUnit.NewtonMeterPerDegree), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMillimeterPerDegree) => new RotationalStiffness(_value * new QuantityValue(314159265358979, 18000000000000, false), RotationalStiffnessUnit.NewtonMillimeterPerDegree), (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMillimeterPerRadian) => new RotationalStiffness(_value * 1000, RotationalStiffnessUnit.NewtonMillimeterPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFeetPerRadian) => new RotationalStiffness(_value / 1.3558179483314, RotationalStiffnessUnit.PoundForceFeetPerRadian), - (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFootPerDegrees) => new RotationalStiffness(_value / 77.6826, RotationalStiffnessUnit.PoundForceFootPerDegrees), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFeetPerRadian) => new RotationalStiffness(_value * new QuantityValue(5000000000000, 6779089741657, false), RotationalStiffnessUnit.PoundForceFeetPerRadian), + (RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFootPerDegrees) => new RotationalStiffness(_value * new QuantityValue(5000, 388413, false), RotationalStiffnessUnit.PoundForceFootPerDegrees), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 480b65d543..f648291bad 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -88,7 +86,7 @@ static RotationalStiffnessPerLength() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) + public RotationalStiffnessPerLength(QuantityValue value, RotationalStiffnessPerLengthUnit unit) { _value = value; _unit = unit; @@ -102,7 +100,7 @@ public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) + public RotationalStiffnessPerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -153,10 +151,10 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -181,27 +179,27 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + public QuantityValue KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + public QuantityValue KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + public QuantityValue MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + public QuantityValue NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); /// /// Gets a value of this quantity converted into /// - public double PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + public QuantityValue PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); #endregion @@ -257,7 +255,7 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFor /// /// Creates a from . /// - public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(double value) + public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(QuantityValue value) { return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); } @@ -265,7 +263,7 @@ public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter /// /// Creates a from . /// - public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(double value) + public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(QuantityValue value) { return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); } @@ -273,7 +271,7 @@ public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFe /// /// Creates a from . /// - public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(double value) + public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(QuantityValue value) { return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); } @@ -281,7 +279,7 @@ public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter /// /// Creates a from . /// - public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(double value) + public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(QuantityValue value) { return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); } @@ -289,7 +287,7 @@ public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(dou /// /// Creates a from . /// - public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(double value) + public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(QuantityValue value) { return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); } @@ -300,7 +298,7 @@ public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(d /// Value to convert from. /// Unit to convert from. /// RotationalStiffnessPerLength unit value. - public static RotationalStiffnessPerLength From(double value, RotationalStiffnessPerLengthUnit fromUnit) + public static RotationalStiffnessPerLength From(QuantityValue value, RotationalStiffnessPerLengthUnit fromUnit) { return new RotationalStiffnessPerLength(value, fromUnit); } @@ -472,25 +470,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(double left, RotationalStiffnessPerLength right) + public static RotationalStiffnessPerLength operator *(QuantityValue left, RotationalStiffnessPerLength right) { return new RotationalStiffnessPerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, double right) + public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, QuantityValue right) { return new RotationalStiffnessPerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, double right) + public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, QuantityValue right) { return new RotationalStiffnessPerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static QuantityValue operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.NewtonMetersPerRadianPerMeter / right.NewtonMetersPerRadianPerMeter; } @@ -533,27 +531,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is RotationalStiffnessPerLength otherQuantity)) @@ -563,15 +554,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(RotationalStiffnessPerLength other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -654,10 +642,10 @@ public bool Equals(RotationalStiffnessPerLength other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -674,7 +662,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLength tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -687,7 +675,12 @@ public bool Equals(RotationalStiffnessPerLength other, RotationalStiffnessPerLen /// A hash code for the current RotationalStiffnessPerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -698,7 +691,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessPerLengthUnit unit) + public QuantityValue As(RotationalStiffnessPerLengthUnit unit) { if (Unit == unit) return Value; @@ -707,7 +700,7 @@ public double As(RotationalStiffnessPerLengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -722,7 +715,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); @@ -788,16 +781,16 @@ private bool TryToUnit(RotationalStiffnessPerLengthUnit unit, [NotNullWhen(true) RotationalStiffnessPerLength? convertedOrNull = (Unit, unit) switch { // RotationalStiffnessPerLengthUnit -> BaseUnit - (RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength((_value) * 1e3d, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), - (RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * 254864.324570, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), - (RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength((_value) * 1e6d, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), - (RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * 254.864324570, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * 1000, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * new QuantityValue(25486432457, 100000, false), RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * 1000000, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value * new QuantityValue(25486432457, 100000000, false), RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), // BaseUnit -> RotationalStiffnessPerLengthUnit - (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength((_value) / 1e3d, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter), - (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot) => new RotationalStiffnessPerLength(_value / 254864.324570, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot), - (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength((_value) / 1e6d, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter), - (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot) => new RotationalStiffnessPerLength(_value / 254.864324570, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot), + (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value / 1000, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot) => new RotationalStiffnessPerLength(_value * new QuantityValue(100000, 25486432457, false), RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot), + (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter) => new RotationalStiffnessPerLength(_value / 1000000, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter), + (RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot) => new RotationalStiffnessPerLength(_value * new QuantityValue(100000000, 25486432457, false), RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 1b34c9d74d..f80780af48 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,7 +79,7 @@ static Scalar() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Scalar(double value, ScalarUnit unit) + public Scalar(QuantityValue value, ScalarUnit unit) { _value = value; _unit = unit; @@ -92,7 +93,7 @@ public Scalar(double value, ScalarUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Scalar(double value, UnitSystem unitSystem) + public Scalar(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -143,10 +144,10 @@ public Scalar(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,7 +172,7 @@ public Scalar(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Amount => As(ScalarUnit.Amount); + public QuantityValue Amount => As(ScalarUnit.Amount); #endregion @@ -219,7 +220,7 @@ public static string GetAbbreviation(ScalarUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Scalar FromAmount(double value) + public static Scalar FromAmount(QuantityValue value) { return new Scalar(value, ScalarUnit.Amount); } @@ -230,7 +231,7 @@ public static Scalar FromAmount(double value) /// Value to convert from. /// Unit to convert from. /// Scalar unit value. - public static Scalar From(double value, ScalarUnit fromUnit) + public static Scalar From(QuantityValue value, ScalarUnit fromUnit) { return new Scalar(value, fromUnit); } @@ -402,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala } /// Get from multiplying value and . - public static Scalar operator *(double left, Scalar right) + public static Scalar operator *(QuantityValue left, Scalar right) { return new Scalar(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Scalar operator *(Scalar left, double right) + public static Scalar operator *(Scalar left, QuantityValue right) { return new Scalar(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Scalar operator /(Scalar left, double right) + public static Scalar operator /(Scalar left, QuantityValue right) { return new Scalar(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Scalar left, Scalar right) + public static QuantityValue operator /(Scalar left, Scalar right) { return left.Amount / right.Amount; } @@ -453,27 +454,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Scalar left, Scalar right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Scalar other, Scalar tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Scalar left, Scalar right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Scalar otherQuantity)) @@ -483,15 +477,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Scalar other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +565,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -594,7 +585,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Scalar other, Scalar tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -607,7 +598,12 @@ public bool Equals(Scalar other, Scalar tolerance) /// A hash code for the current Scalar. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -618,7 +614,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ScalarUnit unit) + public QuantityValue As(ScalarUnit unit) { if (Unit == unit) return Value; @@ -627,7 +623,7 @@ public double As(ScalarUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -642,7 +638,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index faf67fb063..a79cd13d1d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static SolidAngle() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SolidAngle(double value, SolidAngleUnit unit) + public SolidAngle(QuantityValue value, SolidAngleUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public SolidAngle(double value, SolidAngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SolidAngle(double value, UnitSystem unitSystem) + public SolidAngle(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double Steradians => As(SolidAngleUnit.Steradian); + public QuantityValue Steradians => As(SolidAngleUnit.Steradian); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provi /// /// Creates a from . /// - public static SolidAngle FromSteradians(double value) + public static SolidAngle FromSteradians(QuantityValue value) { return new SolidAngle(value, SolidAngleUnit.Steradian); } @@ -233,7 +234,7 @@ public static SolidAngle FromSteradians(double value) /// Value to convert from. /// Unit to convert from. /// SolidAngle unit value. - public static SolidAngle From(double value, SolidAngleUnit fromUnit) + public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit) { return new SolidAngle(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid } /// Get from multiplying value and . - public static SolidAngle operator *(double left, SolidAngle right) + public static SolidAngle operator *(QuantityValue left, SolidAngle right) { return new SolidAngle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SolidAngle operator *(SolidAngle left, double right) + public static SolidAngle operator *(SolidAngle left, QuantityValue right) { return new SolidAngle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SolidAngle operator /(SolidAngle left, double right) + public static SolidAngle operator /(SolidAngle left, QuantityValue right) { return new SolidAngle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SolidAngle left, SolidAngle right) + public static QuantityValue operator /(SolidAngle left, SolidAngle right) { return left.Steradians / right.Steradians; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SolidAngle left, SolidAngle right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SolidAngle other, SolidAngle tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SolidAngle left, SolidAngle right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SolidAngle otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SolidAngle other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(SolidAngle other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SolidAngle other, SolidAngle tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(SolidAngle other, SolidAngle tolerance) /// A hash code for the current SolidAngle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SolidAngleUnit unit) + public QuantityValue As(SolidAngleUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(SolidAngleUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 90133848e1..fca3586dd0 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -50,7 +48,7 @@ namespace UnitsNet IDivisionOperators, IDivisionOperators, IDivisionOperators, - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -62,7 +60,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -121,7 +119,7 @@ static SpecificEnergy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SpecificEnergy(double value, SpecificEnergyUnit unit) + public SpecificEnergy(QuantityValue value, SpecificEnergyUnit unit) { _value = value; _unit = unit; @@ -135,7 +133,7 @@ public SpecificEnergy(double value, SpecificEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEnergy(double value, UnitSystem unitSystem) + public SpecificEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -186,10 +184,10 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -214,152 +212,152 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); + public QuantityValue BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); /// /// Gets a value of this quantity converted into /// - public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); + public QuantityValue CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); /// /// Gets a value of this quantity converted into /// - public double GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); + public QuantityValue GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); /// /// Gets a value of this quantity converted into /// - public double GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); + public QuantityValue GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); /// /// Gets a value of this quantity converted into /// - public double GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); + public QuantityValue GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); /// /// Gets a value of this quantity converted into /// - public double GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); + public QuantityValue GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); /// /// Gets a value of this quantity converted into /// - public double GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); + public QuantityValue GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); /// /// Gets a value of this quantity converted into /// - public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); + public QuantityValue JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); + public QuantityValue KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); + public QuantityValue KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); /// /// Gets a value of this quantity converted into /// - public double KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); + public QuantityValue KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); /// /// Gets a value of this quantity converted into /// - public double KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); + public QuantityValue KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); /// /// Gets a value of this quantity converted into /// - public double KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); + public QuantityValue KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); /// /// Gets a value of this quantity converted into /// - public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); + public QuantityValue KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); /// /// Gets a value of this quantity converted into /// - public double KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); + public QuantityValue KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); + public QuantityValue MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); /// /// Gets a value of this quantity converted into /// - public double MegaJoulesPerTonne => As(SpecificEnergyUnit.MegaJoulePerTonne); + public QuantityValue MegaJoulesPerTonne => As(SpecificEnergyUnit.MegaJoulePerTonne); /// /// Gets a value of this quantity converted into /// - public double MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); + public QuantityValue MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); + public QuantityValue MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); /// /// Gets a value of this quantity converted into /// - public double MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); + public QuantityValue MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); /// /// Gets a value of this quantity converted into /// - public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); + public QuantityValue MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); + public QuantityValue MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); /// /// Gets a value of this quantity converted into /// - public double TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); + public QuantityValue TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); /// /// Gets a value of this quantity converted into /// - public double TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); + public QuantityValue TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); /// /// Gets a value of this quantity converted into /// - public double TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); + public QuantityValue TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); /// /// Gets a value of this quantity converted into /// - public double WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); + public QuantityValue WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); /// /// Gets a value of this quantity converted into /// - public double WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); + public QuantityValue WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); /// /// Gets a value of this quantity converted into /// - public double WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); + public QuantityValue WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); /// /// Gets a value of this quantity converted into /// - public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); + public QuantityValue WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); /// /// Gets a value of this quantity converted into /// - public double WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); + public QuantityValue WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); #endregion @@ -465,7 +463,7 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static SpecificEnergy FromBtuPerPound(double value) + public static SpecificEnergy FromBtuPerPound(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound); } @@ -473,7 +471,7 @@ public static SpecificEnergy FromBtuPerPound(double value) /// /// Creates a from . /// - public static SpecificEnergy FromCaloriesPerGram(double value) + public static SpecificEnergy FromCaloriesPerGram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram); } @@ -481,7 +479,7 @@ public static SpecificEnergy FromCaloriesPerGram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromGigawattDaysPerKilogram(double value) + public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerKilogram); } @@ -489,7 +487,7 @@ public static SpecificEnergy FromGigawattDaysPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromGigawattDaysPerShortTon(double value) + public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerShortTon); } @@ -497,7 +495,7 @@ public static SpecificEnergy FromGigawattDaysPerShortTon(double value) /// /// Creates a from . /// - public static SpecificEnergy FromGigawattDaysPerTonne(double value) + public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerTonne); } @@ -505,7 +503,7 @@ public static SpecificEnergy FromGigawattDaysPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromGigawattHoursPerKilogram(double value) + public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerKilogram); } @@ -513,7 +511,7 @@ public static SpecificEnergy FromGigawattHoursPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromGigawattHoursPerPound(double value) + public static SpecificEnergy FromGigawattHoursPerPound(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerPound); } @@ -521,7 +519,7 @@ public static SpecificEnergy FromGigawattHoursPerPound(double value) /// /// Creates a from . /// - public static SpecificEnergy FromJoulesPerKilogram(double value) + public static SpecificEnergy FromJoulesPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram); } @@ -529,7 +527,7 @@ public static SpecificEnergy FromJoulesPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilocaloriesPerGram(double value) + public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram); } @@ -537,7 +535,7 @@ public static SpecificEnergy FromKilocaloriesPerGram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilojoulesPerKilogram(double value) + public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram); } @@ -545,7 +543,7 @@ public static SpecificEnergy FromKilojoulesPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilowattDaysPerKilogram(double value) + public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerKilogram); } @@ -553,7 +551,7 @@ public static SpecificEnergy FromKilowattDaysPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilowattDaysPerShortTon(double value) + public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerShortTon); } @@ -561,7 +559,7 @@ public static SpecificEnergy FromKilowattDaysPerShortTon(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilowattDaysPerTonne(double value) + public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerTonne); } @@ -569,7 +567,7 @@ public static SpecificEnergy FromKilowattDaysPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilowattHoursPerKilogram(double value) + public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram); } @@ -577,7 +575,7 @@ public static SpecificEnergy FromKilowattHoursPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromKilowattHoursPerPound(double value) + public static SpecificEnergy FromKilowattHoursPerPound(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerPound); } @@ -585,7 +583,7 @@ public static SpecificEnergy FromKilowattHoursPerPound(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegajoulesPerKilogram(double value) + public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram); } @@ -593,7 +591,7 @@ public static SpecificEnergy FromMegajoulesPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegaJoulesPerTonne(double value) + public static SpecificEnergy FromMegaJoulesPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegaJoulePerTonne); } @@ -601,7 +599,7 @@ public static SpecificEnergy FromMegaJoulesPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegawattDaysPerKilogram(double value) + public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerKilogram); } @@ -609,7 +607,7 @@ public static SpecificEnergy FromMegawattDaysPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegawattDaysPerShortTon(double value) + public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerShortTon); } @@ -617,7 +615,7 @@ public static SpecificEnergy FromMegawattDaysPerShortTon(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegawattDaysPerTonne(double value) + public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerTonne); } @@ -625,7 +623,7 @@ public static SpecificEnergy FromMegawattDaysPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegawattHoursPerKilogram(double value) + public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram); } @@ -633,7 +631,7 @@ public static SpecificEnergy FromMegawattHoursPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromMegawattHoursPerPound(double value) + public static SpecificEnergy FromMegawattHoursPerPound(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerPound); } @@ -641,7 +639,7 @@ public static SpecificEnergy FromMegawattHoursPerPound(double value) /// /// Creates a from . /// - public static SpecificEnergy FromTerawattDaysPerKilogram(double value) + public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerKilogram); } @@ -649,7 +647,7 @@ public static SpecificEnergy FromTerawattDaysPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromTerawattDaysPerShortTon(double value) + public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerShortTon); } @@ -657,7 +655,7 @@ public static SpecificEnergy FromTerawattDaysPerShortTon(double value) /// /// Creates a from . /// - public static SpecificEnergy FromTerawattDaysPerTonne(double value) + public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerTonne); } @@ -665,7 +663,7 @@ public static SpecificEnergy FromTerawattDaysPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromWattDaysPerKilogram(double value) + public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerKilogram); } @@ -673,7 +671,7 @@ public static SpecificEnergy FromWattDaysPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromWattDaysPerShortTon(double value) + public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerShortTon); } @@ -681,7 +679,7 @@ public static SpecificEnergy FromWattDaysPerShortTon(double value) /// /// Creates a from . /// - public static SpecificEnergy FromWattDaysPerTonne(double value) + public static SpecificEnergy FromWattDaysPerTonne(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerTonne); } @@ -689,7 +687,7 @@ public static SpecificEnergy FromWattDaysPerTonne(double value) /// /// Creates a from . /// - public static SpecificEnergy FromWattHoursPerKilogram(double value) + public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram); } @@ -697,7 +695,7 @@ public static SpecificEnergy FromWattHoursPerKilogram(double value) /// /// Creates a from . /// - public static SpecificEnergy FromWattHoursPerPound(double value) + public static SpecificEnergy FromWattHoursPerPound(QuantityValue value) { return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerPound); } @@ -708,7 +706,7 @@ public static SpecificEnergy FromWattHoursPerPound(double value) /// Value to convert from. /// Unit to convert from. /// SpecificEnergy unit value. - public static SpecificEnergy From(double value, SpecificEnergyUnit fromUnit) + public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUnit) { return new SpecificEnergy(value, fromUnit); } @@ -880,25 +878,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEnergy operator *(double left, SpecificEnergy right) + public static SpecificEnergy operator *(QuantityValue left, SpecificEnergy right) { return new SpecificEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEnergy operator *(SpecificEnergy left, double right) + public static SpecificEnergy operator *(SpecificEnergy left, QuantityValue right) { return new SpecificEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEnergy operator /(SpecificEnergy left, double right) + public static SpecificEnergy operator /(SpecificEnergy left, QuantityValue right) { return new SpecificEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificEnergy left, SpecificEnergy right) + public static QuantityValue operator /(SpecificEnergy left, SpecificEnergy right) { return left.JoulesPerKilogram / right.JoulesPerKilogram; } @@ -907,8 +905,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Relational Operators - /// Get from / . - public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy) + /// Get from / . + public static BrakeSpecificFuelConsumption operator /(QuantityValue value, SpecificEnergy specificEnergy) { return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); } @@ -943,8 +941,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return TemperatureDelta.FromKelvins(specificEnergy.JoulesPerKilogram / specificEntropy.JoulesPerKilogramKelvin); } - /// Get from * . - public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) + /// Get from * . + public static QuantityValue operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption) { return specificEnergy.JoulesPerKilogram * brakeSpecificFuelConsumption.KilogramsPerJoule; } @@ -977,27 +975,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SpecificEnergy left, SpecificEnergy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEnergy other, SpecificEnergy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SpecificEnergy left, SpecificEnergy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificEnergy otherQuantity)) @@ -1007,15 +998,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SpecificEnergy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1098,10 +1086,10 @@ public bool Equals(SpecificEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1118,7 +1106,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificEnergy other, SpecificEnergy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1131,7 +1119,12 @@ public bool Equals(SpecificEnergy other, SpecificEnergy tolerance) /// A hash code for the current SpecificEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1142,7 +1135,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEnergyUnit unit) + public QuantityValue As(SpecificEnergyUnit unit) { if (Unit == unit) return Value; @@ -1151,7 +1144,7 @@ public double As(SpecificEnergyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1166,7 +1159,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); @@ -1232,66 +1225,66 @@ private bool TryToUnit(SpecificEnergyUnit unit, [NotNullWhen(true)] out Specific SpecificEnergy? convertedOrNull = (Unit, unit) switch { // SpecificEnergyUnit -> BaseUnit - (SpecificEnergyUnit.BtuPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 2326.000075362, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.CaloriePerGram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 4.184e3, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * (24 * 3.6e3)) * 1e9d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 9.0718474e2)) * 1e9d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 1e3)) * 1e9d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 3.6e3) * 1e9d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.GigawattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 7.93664e3) * 1e9d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 4.184e3) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * (24 * 3.6e3)) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 9.0718474e2)) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 1e3)) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 3.6e3) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.KilowattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 7.93664e3) * 1e3d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegaJoulePerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 1e3, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * (24 * 3.6e3)) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 9.0718474e2)) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 1e3)) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 3.6e3) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.MegawattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * 7.93664e3) * 1e6d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * (24 * 3.6e3)) * 1e12d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 9.0718474e2)) * 1e12d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy((_value * ((24 * 3.6e3) / 1e3)) * 1e12d, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * (24 * 3.6e3), SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * ((24 * 3.6e3) / 9.0718474e2), SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.WattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * ((24 * 3.6e3) / 1e3), SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 3.6e3, SpecificEnergyUnit.JoulePerKilogram), - (SpecificEnergyUnit.WattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 7.93664e3, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.BtuPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(1163000037681, 500000000, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.CaloriePerGram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 4184, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(4320000000000000000, 45359237, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 3600000000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.GigawattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 7936640000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 4184000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 1000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(4320000000000, 45359237, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 3600000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.KilowattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 7936640, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 1000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegaJoulePerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 1000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(4320000000000000, 45359237, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 3600000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.MegawattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 7936640000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000000000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(432, 45359237, false) * BigInteger.Pow(10, 19), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400000000000, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 86400, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(4320000000, 45359237, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.WattDayPerTonne, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(432, 5, false), SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * 3600, SpecificEnergyUnit.JoulePerKilogram), + (SpecificEnergyUnit.WattHourPerPound, SpecificEnergyUnit.JoulePerKilogram) => new SpecificEnergy(_value * new QuantityValue(198416, 25, false), SpecificEnergyUnit.JoulePerKilogram), // BaseUnit -> SpecificEnergyUnit - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.BtuPerPound) => new SpecificEnergy(_value / 2326.000075362, SpecificEnergyUnit.BtuPerPound), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.CaloriePerGram) => new SpecificEnergy(_value / 4.184e3, SpecificEnergyUnit.CaloriePerGram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerKilogram) => new SpecificEnergy((_value / (24 * 3.6e3)) / 1e9d, SpecificEnergyUnit.GigawattDayPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerShortTon) => new SpecificEnergy((_value / ((24 * 3.6e3) / 9.0718474e2)) / 1e9d, SpecificEnergyUnit.GigawattDayPerShortTon), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerTonne) => new SpecificEnergy((_value / ((24 * 3.6e3) / 1e3)) / 1e9d, SpecificEnergyUnit.GigawattDayPerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattHourPerKilogram) => new SpecificEnergy((_value / 3.6e3) / 1e9d, SpecificEnergyUnit.GigawattHourPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattHourPerPound) => new SpecificEnergy((_value / 7.93664e3) / 1e9d, SpecificEnergyUnit.GigawattHourPerPound), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilocaloriePerGram) => new SpecificEnergy((_value / 4.184e3) / 1e3d, SpecificEnergyUnit.KilocaloriePerGram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilojoulePerKilogram) => new SpecificEnergy((_value) / 1e3d, SpecificEnergyUnit.KilojoulePerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerKilogram) => new SpecificEnergy((_value / (24 * 3.6e3)) / 1e3d, SpecificEnergyUnit.KilowattDayPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerShortTon) => new SpecificEnergy((_value / ((24 * 3.6e3) / 9.0718474e2)) / 1e3d, SpecificEnergyUnit.KilowattDayPerShortTon), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerTonne) => new SpecificEnergy((_value / ((24 * 3.6e3) / 1e3)) / 1e3d, SpecificEnergyUnit.KilowattDayPerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattHourPerKilogram) => new SpecificEnergy((_value / 3.6e3) / 1e3d, SpecificEnergyUnit.KilowattHourPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattHourPerPound) => new SpecificEnergy((_value / 7.93664e3) / 1e3d, SpecificEnergyUnit.KilowattHourPerPound), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegajoulePerKilogram) => new SpecificEnergy((_value) / 1e6d, SpecificEnergyUnit.MegajoulePerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegaJoulePerTonne) => new SpecificEnergy(_value / 1e3, SpecificEnergyUnit.MegaJoulePerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerKilogram) => new SpecificEnergy((_value / (24 * 3.6e3)) / 1e6d, SpecificEnergyUnit.MegawattDayPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerShortTon) => new SpecificEnergy((_value / ((24 * 3.6e3) / 9.0718474e2)) / 1e6d, SpecificEnergyUnit.MegawattDayPerShortTon), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerTonne) => new SpecificEnergy((_value / ((24 * 3.6e3) / 1e3)) / 1e6d, SpecificEnergyUnit.MegawattDayPerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattHourPerKilogram) => new SpecificEnergy((_value / 3.6e3) / 1e6d, SpecificEnergyUnit.MegawattHourPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattHourPerPound) => new SpecificEnergy((_value / 7.93664e3) / 1e6d, SpecificEnergyUnit.MegawattHourPerPound), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerKilogram) => new SpecificEnergy((_value / (24 * 3.6e3)) / 1e12d, SpecificEnergyUnit.TerawattDayPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerShortTon) => new SpecificEnergy((_value / ((24 * 3.6e3) / 9.0718474e2)) / 1e12d, SpecificEnergyUnit.TerawattDayPerShortTon), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerTonne) => new SpecificEnergy((_value / ((24 * 3.6e3) / 1e3)) / 1e12d, SpecificEnergyUnit.TerawattDayPerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerKilogram) => new SpecificEnergy(_value / (24 * 3.6e3), SpecificEnergyUnit.WattDayPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerShortTon) => new SpecificEnergy(_value / ((24 * 3.6e3) / 9.0718474e2), SpecificEnergyUnit.WattDayPerShortTon), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerTonne) => new SpecificEnergy(_value / ((24 * 3.6e3) / 1e3), SpecificEnergyUnit.WattDayPerTonne), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattHourPerKilogram) => new SpecificEnergy(_value / 3.6e3, SpecificEnergyUnit.WattHourPerKilogram), - (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattHourPerPound) => new SpecificEnergy(_value / 7.93664e3, SpecificEnergyUnit.WattHourPerPound), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.BtuPerPound) => new SpecificEnergy(_value * new QuantityValue(500000000, 1163000037681, false), SpecificEnergyUnit.BtuPerPound), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.CaloriePerGram) => new SpecificEnergy(_value / 4184, SpecificEnergyUnit.CaloriePerGram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerKilogram) => new SpecificEnergy(_value / 86400000000000, SpecificEnergyUnit.GigawattDayPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerShortTon) => new SpecificEnergy(_value * new QuantityValue(45359237, 4320000000000000000, false), SpecificEnergyUnit.GigawattDayPerShortTon), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattDayPerTonne) => new SpecificEnergy(_value / 86400000000, SpecificEnergyUnit.GigawattDayPerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattHourPerKilogram) => new SpecificEnergy(_value / 3600000000000, SpecificEnergyUnit.GigawattHourPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.GigawattHourPerPound) => new SpecificEnergy(_value / 7936640000000, SpecificEnergyUnit.GigawattHourPerPound), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilocaloriePerGram) => new SpecificEnergy(_value / 4184000, SpecificEnergyUnit.KilocaloriePerGram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilojoulePerKilogram) => new SpecificEnergy(_value / 1000, SpecificEnergyUnit.KilojoulePerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerKilogram) => new SpecificEnergy(_value / 86400000, SpecificEnergyUnit.KilowattDayPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerShortTon) => new SpecificEnergy(_value * new QuantityValue(45359237, 4320000000000, false), SpecificEnergyUnit.KilowattDayPerShortTon), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattDayPerTonne) => new SpecificEnergy(_value / 86400, SpecificEnergyUnit.KilowattDayPerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattHourPerKilogram) => new SpecificEnergy(_value / 3600000, SpecificEnergyUnit.KilowattHourPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.KilowattHourPerPound) => new SpecificEnergy(_value / 7936640, SpecificEnergyUnit.KilowattHourPerPound), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegajoulePerKilogram) => new SpecificEnergy(_value / 1000000, SpecificEnergyUnit.MegajoulePerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegaJoulePerTonne) => new SpecificEnergy(_value / 1000, SpecificEnergyUnit.MegaJoulePerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerKilogram) => new SpecificEnergy(_value / 86400000000, SpecificEnergyUnit.MegawattDayPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerShortTon) => new SpecificEnergy(_value * new QuantityValue(45359237, 4320000000000000, false), SpecificEnergyUnit.MegawattDayPerShortTon), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattDayPerTonne) => new SpecificEnergy(_value / 86400000, SpecificEnergyUnit.MegawattDayPerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattHourPerKilogram) => new SpecificEnergy(_value / 3600000000, SpecificEnergyUnit.MegawattHourPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.MegawattHourPerPound) => new SpecificEnergy(_value / 7936640000, SpecificEnergyUnit.MegawattHourPerPound), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerKilogram) => new SpecificEnergy(_value / 86400000000000000, SpecificEnergyUnit.TerawattDayPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerShortTon) => new SpecificEnergy(_value * new QuantityValue(45359237, 432, false) / BigInteger.Pow(10, 19), SpecificEnergyUnit.TerawattDayPerShortTon), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.TerawattDayPerTonne) => new SpecificEnergy(_value / 86400000000000, SpecificEnergyUnit.TerawattDayPerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerKilogram) => new SpecificEnergy(_value / 86400, SpecificEnergyUnit.WattDayPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerShortTon) => new SpecificEnergy(_value * new QuantityValue(45359237, 4320000000, false), SpecificEnergyUnit.WattDayPerShortTon), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerTonne) => new SpecificEnergy(_value * new QuantityValue(5, 432, false), SpecificEnergyUnit.WattDayPerTonne), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattHourPerKilogram) => new SpecificEnergy(_value / 3600, SpecificEnergyUnit.WattHourPerKilogram), + (SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattHourPerPound) => new SpecificEnergy(_value * new QuantityValue(25, 198416, false), SpecificEnergyUnit.WattHourPerPound), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index d3a1a0172a..a9740973b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -93,7 +91,7 @@ static SpecificEntropy() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SpecificEntropy(double value, SpecificEntropyUnit unit) + public SpecificEntropy(QuantityValue value, SpecificEntropyUnit unit) { _value = value; _unit = unit; @@ -107,7 +105,7 @@ public SpecificEntropy(double value, SpecificEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEntropy(double value, UnitSystem unitSystem) + public SpecificEntropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -158,10 +156,10 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -186,47 +184,47 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); + public QuantityValue BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); /// /// Gets a value of this quantity converted into /// - public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); + public QuantityValue CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); /// /// Gets a value of this quantity converted into /// - public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + public QuantityValue JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); + public QuantityValue JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); + public QuantityValue KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + public QuantityValue KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); + public QuantityValue KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + public QuantityValue MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); + public QuantityValue MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); #endregion @@ -290,7 +288,7 @@ public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? /// /// Creates a from . /// - public static SpecificEntropy FromBtusPerPoundFahrenheit(double value) + public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.BtuPerPoundFahrenheit); } @@ -298,7 +296,7 @@ public static SpecificEntropy FromBtusPerPoundFahrenheit(double value) /// /// Creates a from . /// - public static SpecificEntropy FromCaloriesPerGramKelvin(double value) + public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin); } @@ -306,7 +304,7 @@ public static SpecificEntropy FromCaloriesPerGramKelvin(double value) /// /// Creates a from . /// - public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(double value) + public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); } @@ -314,7 +312,7 @@ public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(double value) /// /// Creates a from . /// - public static SpecificEntropy FromJoulesPerKilogramKelvin(double value) + public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin); } @@ -322,7 +320,7 @@ public static SpecificEntropy FromJoulesPerKilogramKelvin(double value) /// /// Creates a from . /// - public static SpecificEntropy FromKilocaloriesPerGramKelvin(double value) + public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin); } @@ -330,7 +328,7 @@ public static SpecificEntropy FromKilocaloriesPerGramKelvin(double value) /// /// Creates a from . /// - public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(double value) + public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); } @@ -338,7 +336,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(double valu /// /// Creates a from . /// - public static SpecificEntropy FromKilojoulesPerKilogramKelvin(double value) + public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin); } @@ -346,7 +344,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramKelvin(double value) /// /// Creates a from . /// - public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(double value) + public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); } @@ -354,7 +352,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(double valu /// /// Creates a from . /// - public static SpecificEntropy FromMegajoulesPerKilogramKelvin(double value) + public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue value) { return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin); } @@ -365,7 +363,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramKelvin(double value) /// Value to convert from. /// Unit to convert from. /// SpecificEntropy unit value. - public static SpecificEntropy From(double value, SpecificEntropyUnit fromUnit) + public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit fromUnit) { return new SpecificEntropy(value, fromUnit); } @@ -537,25 +535,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEntropy operator *(double left, SpecificEntropy right) + public static SpecificEntropy operator *(QuantityValue left, SpecificEntropy right) { return new SpecificEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEntropy operator *(SpecificEntropy left, double right) + public static SpecificEntropy operator *(SpecificEntropy left, QuantityValue right) { return new SpecificEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEntropy operator /(SpecificEntropy left, double right) + public static SpecificEntropy operator /(SpecificEntropy left, QuantityValue right) { return new SpecificEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificEntropy left, SpecificEntropy right) + public static QuantityValue operator /(SpecificEntropy left, SpecificEntropy right) { return left.JoulesPerKilogramKelvin / right.JoulesPerKilogramKelvin; } @@ -604,27 +602,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SpecificEntropy left, SpecificEntropy right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificEntropy other, SpecificEntropy tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SpecificEntropy left, SpecificEntropy right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificEntropy otherQuantity)) @@ -634,15 +625,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SpecificEntropy other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -725,10 +713,10 @@ public bool Equals(SpecificEntropy other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -745,7 +733,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificEntropy other, SpecificEntropy tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -758,7 +746,12 @@ public bool Equals(SpecificEntropy other, SpecificEntropy tolerance) /// A hash code for the current SpecificEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -769,7 +762,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEntropyUnit unit) + public QuantityValue As(SpecificEntropyUnit unit) { if (Unit == unit) return Value; @@ -778,7 +771,7 @@ public double As(SpecificEntropyUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -793,7 +786,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); @@ -859,24 +852,24 @@ private bool TryToUnit(SpecificEntropyUnit unit, [NotNullWhen(true)] out Specifi SpecificEntropy? convertedOrNull = (Unit, unit) switch { // SpecificEntropyUnit -> BaseUnit - (SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 4.1868e3, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 4.184e3, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * new QuantityValue(20934, 5, false), SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 4184, SpecificEntropyUnit.JoulePerKilogramKelvin), (SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy((_value * 4.184e3) * 1e3d, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy((_value) * 1e3d, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy((_value) * 1e3d, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy((_value) * 1e6d, SpecificEntropyUnit.JoulePerKilogramKelvin), - (SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy((_value) * 1e6d, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 4184000, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 1000, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 1000, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 1000000, SpecificEntropyUnit.JoulePerKilogramKelvin), + (SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin) => new SpecificEntropy(_value * 1000000, SpecificEntropyUnit.JoulePerKilogramKelvin), // BaseUnit -> SpecificEntropyUnit - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.BtuPerPoundFahrenheit) => new SpecificEntropy(_value / 4.1868e3, SpecificEntropyUnit.BtuPerPoundFahrenheit), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.CaloriePerGramKelvin) => new SpecificEntropy(_value / 4.184e3, SpecificEntropyUnit.CaloriePerGramKelvin), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.BtuPerPoundFahrenheit) => new SpecificEntropy(_value * new QuantityValue(5, 20934, false), SpecificEntropyUnit.BtuPerPoundFahrenheit), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.CaloriePerGramKelvin) => new SpecificEntropy(_value / 4184, SpecificEntropyUnit.CaloriePerGramKelvin), (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius) => new SpecificEntropy(_value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilocaloriePerGramKelvin) => new SpecificEntropy((_value / 4.184e3) / 1e3d, SpecificEntropyUnit.KilocaloriePerGramKelvin), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius) => new SpecificEntropy((_value) / 1e3d, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilojoulePerKilogramKelvin) => new SpecificEntropy((_value) / 1e3d, SpecificEntropyUnit.KilojoulePerKilogramKelvin), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius) => new SpecificEntropy((_value) / 1e6d, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius), - (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramKelvin) => new SpecificEntropy((_value) / 1e6d, SpecificEntropyUnit.MegajoulePerKilogramKelvin), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilocaloriePerGramKelvin) => new SpecificEntropy(_value / 4184000, SpecificEntropyUnit.KilocaloriePerGramKelvin), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius) => new SpecificEntropy(_value / 1000, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilojoulePerKilogramKelvin) => new SpecificEntropy(_value / 1000, SpecificEntropyUnit.KilojoulePerKilogramKelvin), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius) => new SpecificEntropy(_value / 1000000, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius), + (SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramKelvin) => new SpecificEntropy(_value / 1000000, SpecificEntropyUnit.MegajoulePerKilogramKelvin), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 3ca7bc5f45..b2344ef379 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,7 +85,7 @@ static SpecificFuelConsumption() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) + public SpecificFuelConsumption(QuantityValue value, SpecificFuelConsumptionUnit unit) { _value = value; _unit = unit; @@ -98,7 +99,7 @@ public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificFuelConsumption(double value, UnitSystem unitSystem) + public SpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -149,10 +150,10 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,22 +178,22 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); + public QuantityValue GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); + public QuantityValue KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); /// /// Gets a value of this quantity converted into /// - public double KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); + public QuantityValue KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); /// /// Gets a value of this quantity converted into /// - public double PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); + public QuantityValue PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); #endregion @@ -246,7 +247,7 @@ public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, IFormatPr /// /// Creates a from . /// - public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(double value) + public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(QuantityValue value) { return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); } @@ -254,7 +255,7 @@ public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(double value) /// /// Creates a from . /// - public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(double value) + public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(QuantityValue value) { return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); } @@ -262,7 +263,7 @@ public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(double v /// /// Creates a from . /// - public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(double value) + public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(QuantityValue value) { return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); } @@ -270,7 +271,7 @@ public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(double va /// /// Creates a from . /// - public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(double value) + public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(QuantityValue value) { return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); } @@ -281,7 +282,7 @@ public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(double val /// Value to convert from. /// Unit to convert from. /// SpecificFuelConsumption unit value. - public static SpecificFuelConsumption From(double value, SpecificFuelConsumptionUnit fromUnit) + public static SpecificFuelConsumption From(QuantityValue value, SpecificFuelConsumptionUnit fromUnit) { return new SpecificFuelConsumption(value, fromUnit); } @@ -453,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(double left, SpecificFuelConsumption right) + public static SpecificFuelConsumption operator *(QuantityValue left, SpecificFuelConsumption right) { return new SpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, double right) + public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, QuantityValue right) { return new SpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, double right) + public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, QuantityValue right) { return new SpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) + public static QuantityValue operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) { return left.GramsPerKiloNewtonSecond / right.GramsPerKiloNewtonSecond; } @@ -504,27 +505,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificFuelConsumption otherQuantity)) @@ -534,15 +528,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SpecificFuelConsumption other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -625,10 +616,10 @@ public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -645,7 +636,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -658,7 +649,12 @@ public bool Equals(SpecificFuelConsumption other, SpecificFuelConsumption tolera /// A hash code for the current SpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -669,7 +665,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificFuelConsumptionUnit unit) + public QuantityValue As(SpecificFuelConsumptionUnit unit) { if (Unit == unit) return Value; @@ -678,7 +674,7 @@ public double As(SpecificFuelConsumptionUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -693,7 +689,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); @@ -759,14 +755,14 @@ private bool TryToUnit(SpecificFuelConsumptionUnit unit, [NotNullWhen(true)] out SpecificFuelConsumption? convertedOrNull = (Unit, unit) switch { // SpecificFuelConsumptionUnit -> BaseUnit - (SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value * 28.33, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), - (SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption((_value) * 1e3d, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), - (SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value * 28.33, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), + (SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value * new QuantityValue(2833, 100, false), SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), + (SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value * 1000, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), + (SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value * new QuantityValue(2833, 100, false), SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), // BaseUnit -> SpecificFuelConsumptionUnit - (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour) => new SpecificFuelConsumption(_value / 28.33, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour), - (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond) => new SpecificFuelConsumption((_value) / 1e3d, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond), - (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour) => new SpecificFuelConsumption(_value / 28.33, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour), + (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour) => new SpecificFuelConsumption(_value * new QuantityValue(100, 2833, false), SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour), + (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond) => new SpecificFuelConsumption(_value / 1000, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond), + (SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour) => new SpecificFuelConsumption(_value * new QuantityValue(100, 2833, false), SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index c65602c990..8fb737e7bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -43,7 +41,7 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -55,7 +53,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,7 +85,7 @@ static SpecificVolume() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SpecificVolume(double value, SpecificVolumeUnit unit) + public SpecificVolume(QuantityValue value, SpecificVolumeUnit unit) { _value = value; _unit = unit; @@ -101,7 +99,7 @@ public SpecificVolume(double value, SpecificVolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificVolume(double value, UnitSystem unitSystem) + public SpecificVolume(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -152,10 +150,10 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -180,17 +178,17 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); + public QuantityValue CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); + public QuantityValue CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); /// /// Gets a value of this quantity converted into /// - public double MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); + public QuantityValue MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); #endregion @@ -242,7 +240,7 @@ public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static SpecificVolume FromCubicFeetPerPound(double value) + public static SpecificVolume FromCubicFeetPerPound(QuantityValue value) { return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound); } @@ -250,7 +248,7 @@ public static SpecificVolume FromCubicFeetPerPound(double value) /// /// Creates a from . /// - public static SpecificVolume FromCubicMetersPerKilogram(double value) + public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue value) { return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram); } @@ -258,7 +256,7 @@ public static SpecificVolume FromCubicMetersPerKilogram(double value) /// /// Creates a from . /// - public static SpecificVolume FromMillicubicMetersPerKilogram(double value) + public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue value) { return new SpecificVolume(value, SpecificVolumeUnit.MillicubicMeterPerKilogram); } @@ -269,7 +267,7 @@ public static SpecificVolume FromMillicubicMetersPerKilogram(double value) /// Value to convert from. /// Unit to convert from. /// SpecificVolume unit value. - public static SpecificVolume From(double value, SpecificVolumeUnit fromUnit) + public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUnit) { return new SpecificVolume(value, fromUnit); } @@ -441,25 +439,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificVolume operator *(double left, SpecificVolume right) + public static SpecificVolume operator *(QuantityValue left, SpecificVolume right) { return new SpecificVolume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificVolume operator *(SpecificVolume left, double right) + public static SpecificVolume operator *(SpecificVolume left, QuantityValue right) { return new SpecificVolume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificVolume operator /(SpecificVolume left, double right) + public static SpecificVolume operator /(SpecificVolume left, QuantityValue right) { return new SpecificVolume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificVolume left, SpecificVolume right) + public static QuantityValue operator /(SpecificVolume left, SpecificVolume right) { return left.CubicMetersPerKilogram / right.CubicMetersPerKilogram; } @@ -468,8 +466,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Relational Operators - /// Get from / . - public static Density operator /(double value, SpecificVolume specificVolume) + /// Get from / . + public static Density operator /(QuantityValue value, SpecificVolume specificVolume) { return Density.FromKilogramsPerCubicMeter(value / specificVolume.CubicMetersPerKilogram); } @@ -480,8 +478,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return Volume.FromCubicMeters(specificVolume.CubicMetersPerKilogram * mass.Kilograms); } - /// Get from * . - public static double operator *(SpecificVolume specificVolume, Density density) + /// Get from * . + public static QuantityValue operator *(SpecificVolume specificVolume, Density density) { return specificVolume.CubicMetersPerKilogram * density.KilogramsPerCubicMeter; } @@ -514,27 +512,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SpecificVolume left, SpecificVolume right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificVolume other, SpecificVolume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SpecificVolume left, SpecificVolume right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificVolume otherQuantity)) @@ -544,15 +535,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SpecificVolume other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -635,10 +623,10 @@ public bool Equals(SpecificVolume other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -655,7 +643,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificVolume other, SpecificVolume tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -668,7 +656,12 @@ public bool Equals(SpecificVolume other, SpecificVolume tolerance) /// A hash code for the current SpecificVolume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -679,7 +672,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificVolumeUnit unit) + public QuantityValue As(SpecificVolumeUnit unit) { if (Unit == unit) return Value; @@ -688,7 +681,7 @@ public double As(SpecificVolumeUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -703,7 +696,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); @@ -769,12 +762,12 @@ private bool TryToUnit(SpecificVolumeUnit unit, [NotNullWhen(true)] out Specific SpecificVolume? convertedOrNull = (Unit, unit) switch { // SpecificVolumeUnit -> BaseUnit - (SpecificVolumeUnit.CubicFootPerPound, SpecificVolumeUnit.CubicMeterPerKilogram) => new SpecificVolume(_value / 16.01846353, SpecificVolumeUnit.CubicMeterPerKilogram), - (SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolumeUnit.CubicMeterPerKilogram) => new SpecificVolume((_value) * 1e-3d, SpecificVolumeUnit.CubicMeterPerKilogram), + (SpecificVolumeUnit.CubicFootPerPound, SpecificVolumeUnit.CubicMeterPerKilogram) => new SpecificVolume(_value * new QuantityValue(100000000, 1601846353, false), SpecificVolumeUnit.CubicMeterPerKilogram), + (SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolumeUnit.CubicMeterPerKilogram) => new SpecificVolume(_value / 1000, SpecificVolumeUnit.CubicMeterPerKilogram), // BaseUnit -> SpecificVolumeUnit - (SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.CubicFootPerPound) => new SpecificVolume(_value * 16.01846353, SpecificVolumeUnit.CubicFootPerPound), - (SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.MillicubicMeterPerKilogram) => new SpecificVolume((_value) / 1e-3d, SpecificVolumeUnit.MillicubicMeterPerKilogram), + (SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.CubicFootPerPound) => new SpecificVolume(_value * new QuantityValue(1601846353, 100000000, false), SpecificVolumeUnit.CubicFootPerPound), + (SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.MillicubicMeterPerKilogram) => new SpecificVolume(_value * 1000, SpecificVolumeUnit.MillicubicMeterPerKilogram), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 63f0330845..c47632a94e 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -60,7 +58,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -106,7 +104,7 @@ static SpecificWeight() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public SpecificWeight(double value, SpecificWeightUnit unit) + public SpecificWeight(QuantityValue value, SpecificWeightUnit unit) { _value = value; _unit = unit; @@ -120,7 +118,7 @@ public SpecificWeight(double value, SpecificWeightUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificWeight(double value, UnitSystem unitSystem) + public SpecificWeight(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -171,10 +169,10 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -199,87 +197,87 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); + public QuantityValue KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); + public QuantityValue KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); + public QuantityValue KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); + public QuantityValue KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); + public QuantityValue KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); + public QuantityValue KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); + public QuantityValue KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); + public QuantityValue KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); /// /// Gets a value of this quantity converted into /// - public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); + public QuantityValue MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); + public QuantityValue NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); + public QuantityValue NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); + public QuantityValue NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); + public QuantityValue PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); /// /// Gets a value of this quantity converted into /// - public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); + public QuantityValue PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); + public QuantityValue TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); + public QuantityValue TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); /// /// Gets a value of this quantity converted into /// - public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); + public QuantityValue TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); #endregion @@ -359,7 +357,7 @@ public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? p /// /// Creates a from . /// - public static SpecificWeight FromKilogramsForcePerCubicCentimeter(double value) + public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter); } @@ -367,7 +365,7 @@ public static SpecificWeight FromKilogramsForcePerCubicCentimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilogramsForcePerCubicMeter(double value) + public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter); } @@ -375,7 +373,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilogramsForcePerCubicMillimeter(double value) + public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter); } @@ -383,7 +381,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMillimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilonewtonsPerCubicCentimeter(double value) + public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter); } @@ -391,7 +389,7 @@ public static SpecificWeight FromKilonewtonsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilonewtonsPerCubicMeter(double value) + public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter); } @@ -399,7 +397,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilonewtonsPerCubicMillimeter(double value) + public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter); } @@ -407,7 +405,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilopoundsForcePerCubicFoot(double value) + public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot); } @@ -415,7 +413,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicFoot(double value) /// /// Creates a from . /// - public static SpecificWeight FromKilopoundsForcePerCubicInch(double value) + public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch); } @@ -423,7 +421,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicInch(double value) /// /// Creates a from . /// - public static SpecificWeight FromMeganewtonsPerCubicMeter(double value) + public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter); } @@ -431,7 +429,7 @@ public static SpecificWeight FromMeganewtonsPerCubicMeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromNewtonsPerCubicCentimeter(double value) + public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter); } @@ -439,7 +437,7 @@ public static SpecificWeight FromNewtonsPerCubicCentimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromNewtonsPerCubicMeter(double value) + public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter); } @@ -447,7 +445,7 @@ public static SpecificWeight FromNewtonsPerCubicMeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromNewtonsPerCubicMillimeter(double value) + public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter); } @@ -455,7 +453,7 @@ public static SpecificWeight FromNewtonsPerCubicMillimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromPoundsForcePerCubicFoot(double value) + public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot); } @@ -463,7 +461,7 @@ public static SpecificWeight FromPoundsForcePerCubicFoot(double value) /// /// Creates a from . /// - public static SpecificWeight FromPoundsForcePerCubicInch(double value) + public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch); } @@ -471,7 +469,7 @@ public static SpecificWeight FromPoundsForcePerCubicInch(double value) /// /// Creates a from . /// - public static SpecificWeight FromTonnesForcePerCubicCentimeter(double value) + public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter); } @@ -479,7 +477,7 @@ public static SpecificWeight FromTonnesForcePerCubicCentimeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromTonnesForcePerCubicMeter(double value) + public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter); } @@ -487,7 +485,7 @@ public static SpecificWeight FromTonnesForcePerCubicMeter(double value) /// /// Creates a from . /// - public static SpecificWeight FromTonnesForcePerCubicMillimeter(double value) + public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue value) { return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter); } @@ -498,7 +496,7 @@ public static SpecificWeight FromTonnesForcePerCubicMillimeter(double value) /// Value to convert from. /// Unit to convert from. /// SpecificWeight unit value. - public static SpecificWeight From(double value, SpecificWeightUnit fromUnit) + public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUnit) { return new SpecificWeight(value, fromUnit); } @@ -670,25 +668,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificWeight operator *(double left, SpecificWeight right) + public static SpecificWeight operator *(QuantityValue left, SpecificWeight right) { return new SpecificWeight(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificWeight operator *(SpecificWeight left, double right) + public static SpecificWeight operator *(SpecificWeight left, QuantityValue right) { return new SpecificWeight(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificWeight operator /(SpecificWeight left, double right) + public static SpecificWeight operator /(SpecificWeight left, QuantityValue right) { return new SpecificWeight(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificWeight left, SpecificWeight right) + public static QuantityValue operator /(SpecificWeight left, SpecificWeight right) { return left.NewtonsPerCubicMeter / right.NewtonsPerCubicMeter; } @@ -749,27 +747,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(SpecificWeight left, SpecificWeight right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(SpecificWeight other, SpecificWeight tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(SpecificWeight left, SpecificWeight right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is SpecificWeight otherQuantity)) @@ -779,15 +770,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(SpecificWeight other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +858,10 @@ public bool Equals(SpecificWeight other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -890,7 +878,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(SpecificWeight other, SpecificWeight tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -903,7 +891,12 @@ public bool Equals(SpecificWeight other, SpecificWeight tolerance) /// A hash code for the current SpecificWeight. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -914,7 +907,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificWeightUnit unit) + public QuantityValue As(SpecificWeightUnit unit) { if (Unit == unit) return Value; @@ -923,7 +916,7 @@ public double As(SpecificWeightUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -938,7 +931,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); @@ -1004,40 +997,40 @@ private bool TryToUnit(SpecificWeightUnit unit, [NotNullWhen(true)] out Specific SpecificWeight? convertedOrNull = (Unit, unit) switch { // SpecificWeightUnit -> BaseUnit - (SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665e6, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665e9, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value * 1000000) * 1e3d, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value) * 1e3d, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value * 1000000000) * 1e3d, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value * 1.570874638462462e2) * 1e3d, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value * 2.714471375263134e5) * 1e3d, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight((_value) * 1e6d, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9806650, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(196133, 20000, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9806650000, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000000000, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000000000000, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(785437319231231, 5000000000, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(1357235687631567, 5000000, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000000, SpecificWeightUnit.NewtonPerCubicMeter), (SpecificWeightUnit.NewtonPerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000000, SpecificWeightUnit.NewtonPerCubicMeter), (SpecificWeightUnit.NewtonPerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1000000000, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 1.570874638462462e2, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 2.714471375263134e5, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665e9, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665e3, SpecificWeightUnit.NewtonPerCubicMeter), - (SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9.80665e12, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(785437319231231, 5000000000000, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(1357235687631567, 5000000000, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9806650000, SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * new QuantityValue(196133, 20, false), SpecificWeightUnit.NewtonPerCubicMeter), + (SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeightUnit.NewtonPerCubicMeter) => new SpecificWeight(_value * 9806650000000, SpecificWeightUnit.NewtonPerCubicMeter), // BaseUnit -> SpecificWeightUnit - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicCentimeter) => new SpecificWeight(_value / 9.80665e6, SpecificWeightUnit.KilogramForcePerCubicCentimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicMeter) => new SpecificWeight(_value / 9.80665, SpecificWeightUnit.KilogramForcePerCubicMeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicMillimeter) => new SpecificWeight(_value / 9.80665e9, SpecificWeightUnit.KilogramForcePerCubicMillimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicCentimeter) => new SpecificWeight((_value * 0.000001) / 1e3d, SpecificWeightUnit.KilonewtonPerCubicCentimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicMeter) => new SpecificWeight((_value) / 1e3d, SpecificWeightUnit.KilonewtonPerCubicMeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicMillimeter) => new SpecificWeight((_value * 0.000000001) / 1e3d, SpecificWeightUnit.KilonewtonPerCubicMillimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilopoundForcePerCubicFoot) => new SpecificWeight((_value / 1.570874638462462e2) / 1e3d, SpecificWeightUnit.KilopoundForcePerCubicFoot), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilopoundForcePerCubicInch) => new SpecificWeight((_value / 2.714471375263134e5) / 1e3d, SpecificWeightUnit.KilopoundForcePerCubicInch), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.MeganewtonPerCubicMeter) => new SpecificWeight((_value) / 1e6d, SpecificWeightUnit.MeganewtonPerCubicMeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicCentimeter) => new SpecificWeight(_value * 0.000001, SpecificWeightUnit.NewtonPerCubicCentimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMillimeter) => new SpecificWeight(_value * 0.000000001, SpecificWeightUnit.NewtonPerCubicMillimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.PoundForcePerCubicFoot) => new SpecificWeight(_value / 1.570874638462462e2, SpecificWeightUnit.PoundForcePerCubicFoot), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.PoundForcePerCubicInch) => new SpecificWeight(_value / 2.714471375263134e5, SpecificWeightUnit.PoundForcePerCubicInch), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicCentimeter) => new SpecificWeight(_value / 9.80665e9, SpecificWeightUnit.TonneForcePerCubicCentimeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMeter) => new SpecificWeight(_value / 9.80665e3, SpecificWeightUnit.TonneForcePerCubicMeter), - (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMillimeter) => new SpecificWeight(_value / 9.80665e12, SpecificWeightUnit.TonneForcePerCubicMillimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicCentimeter) => new SpecificWeight(_value / 9806650, SpecificWeightUnit.KilogramForcePerCubicCentimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicMeter) => new SpecificWeight(_value * new QuantityValue(20000, 196133, false), SpecificWeightUnit.KilogramForcePerCubicMeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilogramForcePerCubicMillimeter) => new SpecificWeight(_value / 9806650000, SpecificWeightUnit.KilogramForcePerCubicMillimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicCentimeter) => new SpecificWeight(_value / 1000000000, SpecificWeightUnit.KilonewtonPerCubicCentimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicMeter) => new SpecificWeight(_value / 1000, SpecificWeightUnit.KilonewtonPerCubicMeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilonewtonPerCubicMillimeter) => new SpecificWeight(_value / 1000000000000, SpecificWeightUnit.KilonewtonPerCubicMillimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilopoundForcePerCubicFoot) => new SpecificWeight(_value * new QuantityValue(5000000000, 785437319231231, false), SpecificWeightUnit.KilopoundForcePerCubicFoot), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.KilopoundForcePerCubicInch) => new SpecificWeight(_value * new QuantityValue(5000000, 1357235687631567, false), SpecificWeightUnit.KilopoundForcePerCubicInch), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.MeganewtonPerCubicMeter) => new SpecificWeight(_value / 1000000, SpecificWeightUnit.MeganewtonPerCubicMeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicCentimeter) => new SpecificWeight(_value / 1000000, SpecificWeightUnit.NewtonPerCubicCentimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMillimeter) => new SpecificWeight(_value / 1000000000, SpecificWeightUnit.NewtonPerCubicMillimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.PoundForcePerCubicFoot) => new SpecificWeight(_value * new QuantityValue(5000000000000, 785437319231231, false), SpecificWeightUnit.PoundForcePerCubicFoot), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.PoundForcePerCubicInch) => new SpecificWeight(_value * new QuantityValue(5000000000, 1357235687631567, false), SpecificWeightUnit.PoundForcePerCubicInch), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicCentimeter) => new SpecificWeight(_value / 9806650000, SpecificWeightUnit.TonneForcePerCubicCentimeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMeter) => new SpecificWeight(_value * new QuantityValue(20, 196133, false), SpecificWeightUnit.TonneForcePerCubicMeter), + (SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMillimeter) => new SpecificWeight(_value / 9806650000000, SpecificWeightUnit.TonneForcePerCubicMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 9b5a9a80e6..fa67c74217 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -61,7 +59,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -123,7 +121,7 @@ static Speed() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Speed(double value, SpeedUnit unit) + public Speed(QuantityValue value, SpeedUnit unit) { _value = value; _unit = unit; @@ -137,7 +135,7 @@ public Speed(double value, SpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Speed(double value, UnitSystem unitSystem) + public Speed(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -188,10 +186,10 @@ public Speed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -216,167 +214,167 @@ public Speed(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); + public QuantityValue CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); /// /// Gets a value of this quantity converted into /// - public double CentimetersPerMinute => As(SpeedUnit.CentimeterPerMinute); + public QuantityValue CentimetersPerMinute => As(SpeedUnit.CentimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); + public QuantityValue CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecimetersPerMinute => As(SpeedUnit.DecimeterPerMinute); + public QuantityValue DecimetersPerMinute => As(SpeedUnit.DecimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); + public QuantityValue DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double FeetPerHour => As(SpeedUnit.FootPerHour); + public QuantityValue FeetPerHour => As(SpeedUnit.FootPerHour); /// /// Gets a value of this quantity converted into /// - public double FeetPerMinute => As(SpeedUnit.FootPerMinute); + public QuantityValue FeetPerMinute => As(SpeedUnit.FootPerMinute); /// /// Gets a value of this quantity converted into /// - public double FeetPerSecond => As(SpeedUnit.FootPerSecond); + public QuantityValue FeetPerSecond => As(SpeedUnit.FootPerSecond); /// /// Gets a value of this quantity converted into /// - public double InchesPerHour => As(SpeedUnit.InchPerHour); + public QuantityValue InchesPerHour => As(SpeedUnit.InchPerHour); /// /// Gets a value of this quantity converted into /// - public double InchesPerMinute => As(SpeedUnit.InchPerMinute); + public QuantityValue InchesPerMinute => As(SpeedUnit.InchPerMinute); /// /// Gets a value of this quantity converted into /// - public double InchesPerSecond => As(SpeedUnit.InchPerSecond); + public QuantityValue InchesPerSecond => As(SpeedUnit.InchPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilometersPerHour => As(SpeedUnit.KilometerPerHour); + public QuantityValue KilometersPerHour => As(SpeedUnit.KilometerPerHour); /// /// Gets a value of this quantity converted into /// - public double KilometersPerMinute => As(SpeedUnit.KilometerPerMinute); + public QuantityValue KilometersPerMinute => As(SpeedUnit.KilometerPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); + public QuantityValue KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); /// /// Gets a value of this quantity converted into /// - public double Knots => As(SpeedUnit.Knot); + public QuantityValue Knots => As(SpeedUnit.Knot); /// /// Gets a value of this quantity converted into /// - public double Mach => As(SpeedUnit.Mach); + public QuantityValue Mach => As(SpeedUnit.Mach); /// /// Gets a value of this quantity converted into /// - public double MetersPerHour => As(SpeedUnit.MeterPerHour); + public QuantityValue MetersPerHour => As(SpeedUnit.MeterPerHour); /// /// Gets a value of this quantity converted into /// - public double MetersPerMinute => As(SpeedUnit.MeterPerMinute); + public QuantityValue MetersPerMinute => As(SpeedUnit.MeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double MetersPerSecond => As(SpeedUnit.MeterPerSecond); + public QuantityValue MetersPerSecond => As(SpeedUnit.MeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double MicrometersPerMinute => As(SpeedUnit.MicrometerPerMinute); + public QuantityValue MicrometersPerMinute => As(SpeedUnit.MicrometerPerMinute); /// /// Gets a value of this quantity converted into /// - public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); + public QuantityValue MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); /// /// Gets a value of this quantity converted into /// - public double MilesPerHour => As(SpeedUnit.MilePerHour); + public QuantityValue MilesPerHour => As(SpeedUnit.MilePerHour); /// /// Gets a value of this quantity converted into /// - public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); + public QuantityValue MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); /// /// Gets a value of this quantity converted into /// - public double MillimetersPerMinute => As(SpeedUnit.MillimeterPerMinute); + public QuantityValue MillimetersPerMinute => As(SpeedUnit.MillimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); + public QuantityValue MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanometersPerMinute => As(SpeedUnit.NanometerPerMinute); + public QuantityValue NanometersPerMinute => As(SpeedUnit.NanometerPerMinute); /// /// Gets a value of this quantity converted into /// - public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); + public QuantityValue NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); /// /// Gets a value of this quantity converted into /// - public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); + public QuantityValue UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); /// /// Gets a value of this quantity converted into /// - public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); + public QuantityValue UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); /// /// Gets a value of this quantity converted into /// - public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); + public QuantityValue UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double YardsPerHour => As(SpeedUnit.YardPerHour); + public QuantityValue YardsPerHour => As(SpeedUnit.YardPerHour); /// /// Gets a value of this quantity converted into /// - public double YardsPerMinute => As(SpeedUnit.YardPerMinute); + public QuantityValue YardsPerMinute => As(SpeedUnit.YardPerMinute); /// /// Gets a value of this quantity converted into /// - public double YardsPerSecond => As(SpeedUnit.YardPerSecond); + public QuantityValue YardsPerSecond => As(SpeedUnit.YardPerSecond); #endregion @@ -488,7 +486,7 @@ public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Speed FromCentimetersPerHour(double value) + public static Speed FromCentimetersPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.CentimeterPerHour); } @@ -496,7 +494,7 @@ public static Speed FromCentimetersPerHour(double value) /// /// Creates a from . /// - public static Speed FromCentimetersPerMinute(double value) + public static Speed FromCentimetersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.CentimeterPerMinute); } @@ -504,7 +502,7 @@ public static Speed FromCentimetersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromCentimetersPerSecond(double value) + public static Speed FromCentimetersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.CentimeterPerSecond); } @@ -512,7 +510,7 @@ public static Speed FromCentimetersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromDecimetersPerMinute(double value) + public static Speed FromDecimetersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.DecimeterPerMinute); } @@ -520,7 +518,7 @@ public static Speed FromDecimetersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromDecimetersPerSecond(double value) + public static Speed FromDecimetersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.DecimeterPerSecond); } @@ -528,7 +526,7 @@ public static Speed FromDecimetersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromFeetPerHour(double value) + public static Speed FromFeetPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.FootPerHour); } @@ -536,7 +534,7 @@ public static Speed FromFeetPerHour(double value) /// /// Creates a from . /// - public static Speed FromFeetPerMinute(double value) + public static Speed FromFeetPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.FootPerMinute); } @@ -544,7 +542,7 @@ public static Speed FromFeetPerMinute(double value) /// /// Creates a from . /// - public static Speed FromFeetPerSecond(double value) + public static Speed FromFeetPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.FootPerSecond); } @@ -552,7 +550,7 @@ public static Speed FromFeetPerSecond(double value) /// /// Creates a from . /// - public static Speed FromInchesPerHour(double value) + public static Speed FromInchesPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.InchPerHour); } @@ -560,7 +558,7 @@ public static Speed FromInchesPerHour(double value) /// /// Creates a from . /// - public static Speed FromInchesPerMinute(double value) + public static Speed FromInchesPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.InchPerMinute); } @@ -568,7 +566,7 @@ public static Speed FromInchesPerMinute(double value) /// /// Creates a from . /// - public static Speed FromInchesPerSecond(double value) + public static Speed FromInchesPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.InchPerSecond); } @@ -576,7 +574,7 @@ public static Speed FromInchesPerSecond(double value) /// /// Creates a from . /// - public static Speed FromKilometersPerHour(double value) + public static Speed FromKilometersPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.KilometerPerHour); } @@ -584,7 +582,7 @@ public static Speed FromKilometersPerHour(double value) /// /// Creates a from . /// - public static Speed FromKilometersPerMinute(double value) + public static Speed FromKilometersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.KilometerPerMinute); } @@ -592,7 +590,7 @@ public static Speed FromKilometersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromKilometersPerSecond(double value) + public static Speed FromKilometersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.KilometerPerSecond); } @@ -600,7 +598,7 @@ public static Speed FromKilometersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromKnots(double value) + public static Speed FromKnots(QuantityValue value) { return new Speed(value, SpeedUnit.Knot); } @@ -608,7 +606,7 @@ public static Speed FromKnots(double value) /// /// Creates a from . /// - public static Speed FromMach(double value) + public static Speed FromMach(QuantityValue value) { return new Speed(value, SpeedUnit.Mach); } @@ -616,7 +614,7 @@ public static Speed FromMach(double value) /// /// Creates a from . /// - public static Speed FromMetersPerHour(double value) + public static Speed FromMetersPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.MeterPerHour); } @@ -624,7 +622,7 @@ public static Speed FromMetersPerHour(double value) /// /// Creates a from . /// - public static Speed FromMetersPerMinute(double value) + public static Speed FromMetersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.MeterPerMinute); } @@ -632,7 +630,7 @@ public static Speed FromMetersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromMetersPerSecond(double value) + public static Speed FromMetersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.MeterPerSecond); } @@ -640,7 +638,7 @@ public static Speed FromMetersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromMicrometersPerMinute(double value) + public static Speed FromMicrometersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.MicrometerPerMinute); } @@ -648,7 +646,7 @@ public static Speed FromMicrometersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromMicrometersPerSecond(double value) + public static Speed FromMicrometersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.MicrometerPerSecond); } @@ -656,7 +654,7 @@ public static Speed FromMicrometersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromMilesPerHour(double value) + public static Speed FromMilesPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.MilePerHour); } @@ -664,7 +662,7 @@ public static Speed FromMilesPerHour(double value) /// /// Creates a from . /// - public static Speed FromMillimetersPerHour(double value) + public static Speed FromMillimetersPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.MillimeterPerHour); } @@ -672,7 +670,7 @@ public static Speed FromMillimetersPerHour(double value) /// /// Creates a from . /// - public static Speed FromMillimetersPerMinute(double value) + public static Speed FromMillimetersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.MillimeterPerMinute); } @@ -680,7 +678,7 @@ public static Speed FromMillimetersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromMillimetersPerSecond(double value) + public static Speed FromMillimetersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.MillimeterPerSecond); } @@ -688,7 +686,7 @@ public static Speed FromMillimetersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromNanometersPerMinute(double value) + public static Speed FromNanometersPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.NanometerPerMinute); } @@ -696,7 +694,7 @@ public static Speed FromNanometersPerMinute(double value) /// /// Creates a from . /// - public static Speed FromNanometersPerSecond(double value) + public static Speed FromNanometersPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.NanometerPerSecond); } @@ -704,7 +702,7 @@ public static Speed FromNanometersPerSecond(double value) /// /// Creates a from . /// - public static Speed FromUsSurveyFeetPerHour(double value) + public static Speed FromUsSurveyFeetPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.UsSurveyFootPerHour); } @@ -712,7 +710,7 @@ public static Speed FromUsSurveyFeetPerHour(double value) /// /// Creates a from . /// - public static Speed FromUsSurveyFeetPerMinute(double value) + public static Speed FromUsSurveyFeetPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.UsSurveyFootPerMinute); } @@ -720,7 +718,7 @@ public static Speed FromUsSurveyFeetPerMinute(double value) /// /// Creates a from . /// - public static Speed FromUsSurveyFeetPerSecond(double value) + public static Speed FromUsSurveyFeetPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.UsSurveyFootPerSecond); } @@ -728,7 +726,7 @@ public static Speed FromUsSurveyFeetPerSecond(double value) /// /// Creates a from . /// - public static Speed FromYardsPerHour(double value) + public static Speed FromYardsPerHour(QuantityValue value) { return new Speed(value, SpeedUnit.YardPerHour); } @@ -736,7 +734,7 @@ public static Speed FromYardsPerHour(double value) /// /// Creates a from . /// - public static Speed FromYardsPerMinute(double value) + public static Speed FromYardsPerMinute(QuantityValue value) { return new Speed(value, SpeedUnit.YardPerMinute); } @@ -744,7 +742,7 @@ public static Speed FromYardsPerMinute(double value) /// /// Creates a from . /// - public static Speed FromYardsPerSecond(double value) + public static Speed FromYardsPerSecond(QuantityValue value) { return new Speed(value, SpeedUnit.YardPerSecond); } @@ -755,7 +753,7 @@ public static Speed FromYardsPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// Speed unit value. - public static Speed From(double value, SpeedUnit fromUnit) + public static Speed From(QuantityValue value, SpeedUnit fromUnit) { return new Speed(value, fromUnit); } @@ -927,25 +925,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed } /// Get from multiplying value and . - public static Speed operator *(double left, Speed right) + public static Speed operator *(QuantityValue left, Speed right) { return new Speed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Speed operator *(Speed left, double right) + public static Speed operator *(Speed left, QuantityValue right) { return new Speed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Speed operator /(Speed left, double right) + public static Speed operator /(Speed left, QuantityValue right) { return new Speed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Speed left, Speed right) + public static QuantityValue operator /(Speed left, Speed right) { return left.MetersPerSecond / right.MetersPerSecond; } @@ -1030,27 +1028,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Speed left, Speed right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Speed other, Speed tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Speed left, Speed right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Speed otherQuantity)) @@ -1060,15 +1051,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Speed other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1151,10 +1139,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1171,7 +1159,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Speed other, Speed tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1184,7 +1172,12 @@ public bool Equals(Speed other, Speed tolerance) /// A hash code for the current Speed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1195,7 +1188,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpeedUnit unit) + public QuantityValue As(SpeedUnit unit) { if (Unit == unit) return Value; @@ -1204,7 +1197,7 @@ public double As(SpeedUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1219,7 +1212,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); @@ -1285,72 +1278,72 @@ private bool TryToUnit(SpeedUnit unit, [NotNullWhen(true)] out Speed? converted) Speed? convertedOrNull = (Unit, unit) switch { // SpeedUnit -> BaseUnit - (SpeedUnit.CentimeterPerHour, SpeedUnit.MeterPerSecond) => new Speed((_value / 3600) * 1e-2d, SpeedUnit.MeterPerSecond), - (SpeedUnit.CentimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e-2d, SpeedUnit.MeterPerSecond), - (SpeedUnit.CentimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e-2d, SpeedUnit.MeterPerSecond), - (SpeedUnit.DecimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e-1d, SpeedUnit.MeterPerSecond), - (SpeedUnit.DecimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e-1d, SpeedUnit.MeterPerSecond), - (SpeedUnit.FootPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.3048 / 3600, SpeedUnit.MeterPerSecond), - (SpeedUnit.FootPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.3048 / 60, SpeedUnit.MeterPerSecond), - (SpeedUnit.FootPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.3048, SpeedUnit.MeterPerSecond), - (SpeedUnit.InchPerHour, SpeedUnit.MeterPerSecond) => new Speed((_value / 3600) * 2.54e-2, SpeedUnit.MeterPerSecond), - (SpeedUnit.InchPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 2.54e-2, SpeedUnit.MeterPerSecond), - (SpeedUnit.InchPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * 2.54e-2, SpeedUnit.MeterPerSecond), - (SpeedUnit.KilometerPerHour, SpeedUnit.MeterPerSecond) => new Speed((_value / 3600) * 1e3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.KilometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.KilometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.Knot, SpeedUnit.MeterPerSecond) => new Speed(_value * (1852.0 / 3600.0), SpeedUnit.MeterPerSecond), - (SpeedUnit.Mach, SpeedUnit.MeterPerSecond) => new Speed(_value * 340.29, SpeedUnit.MeterPerSecond), + (SpeedUnit.CentimeterPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value / 360000, SpeedUnit.MeterPerSecond), + (SpeedUnit.CentimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 6000, SpeedUnit.MeterPerSecond), + (SpeedUnit.CentimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value / 100, SpeedUnit.MeterPerSecond), + (SpeedUnit.DecimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 600, SpeedUnit.MeterPerSecond), + (SpeedUnit.DecimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value / 10, SpeedUnit.MeterPerSecond), + (SpeedUnit.FootPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 1500000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.FootPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 25000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.FootPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(381, 1250, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.InchPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 18000000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.InchPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 300000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.InchPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 5000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.KilometerPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(5, 18, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.KilometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(50, 3, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.KilometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * 1000, SpeedUnit.MeterPerSecond), + (SpeedUnit.Knot, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(463, 900, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.Mach, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(34029, 100, false), SpeedUnit.MeterPerSecond), (SpeedUnit.MeterPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value / 3600, SpeedUnit.MeterPerSecond), (SpeedUnit.MeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 60, SpeedUnit.MeterPerSecond), - (SpeedUnit.MicrometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e-6d, SpeedUnit.MeterPerSecond), - (SpeedUnit.MicrometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e-6d, SpeedUnit.MeterPerSecond), - (SpeedUnit.MilePerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.44704, SpeedUnit.MeterPerSecond), - (SpeedUnit.MillimeterPerHour, SpeedUnit.MeterPerSecond) => new Speed((_value / 3600) * 1e-3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.MillimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e-3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.MillimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e-3d, SpeedUnit.MeterPerSecond), - (SpeedUnit.NanometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value / 60) * 1e-9d, SpeedUnit.MeterPerSecond), - (SpeedUnit.NanometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed((_value) * 1e-9d, SpeedUnit.MeterPerSecond), - (SpeedUnit.UsSurveyFootPerHour, SpeedUnit.MeterPerSecond) => new Speed((_value * 1200 / 3937) / 3600, SpeedUnit.MeterPerSecond), - (SpeedUnit.UsSurveyFootPerMinute, SpeedUnit.MeterPerSecond) => new Speed((_value * 1200 / 3937) / 60, SpeedUnit.MeterPerSecond), - (SpeedUnit.UsSurveyFootPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * 1200 / 3937, SpeedUnit.MeterPerSecond), - (SpeedUnit.YardPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.9144 / 3600, SpeedUnit.MeterPerSecond), - (SpeedUnit.YardPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.9144 / 60, SpeedUnit.MeterPerSecond), - (SpeedUnit.YardPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * 0.9144, SpeedUnit.MeterPerSecond), + (SpeedUnit.MicrometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 60000000, SpeedUnit.MeterPerSecond), + (SpeedUnit.MicrometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value / 1000000, SpeedUnit.MeterPerSecond), + (SpeedUnit.MilePerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(1397, 3125, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.MillimeterPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value / 3600000, SpeedUnit.MeterPerSecond), + (SpeedUnit.MillimeterPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 60000, SpeedUnit.MeterPerSecond), + (SpeedUnit.MillimeterPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value / 1000, SpeedUnit.MeterPerSecond), + (SpeedUnit.NanometerPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value / 60000000000, SpeedUnit.MeterPerSecond), + (SpeedUnit.NanometerPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value / 1000000000, SpeedUnit.MeterPerSecond), + (SpeedUnit.UsSurveyFootPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value / 11811, SpeedUnit.MeterPerSecond), + (SpeedUnit.UsSurveyFootPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(20, 3937, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.UsSurveyFootPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(1200, 3937, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.YardPerHour, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(127, 500000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.YardPerMinute, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(381, 25000, false), SpeedUnit.MeterPerSecond), + (SpeedUnit.YardPerSecond, SpeedUnit.MeterPerSecond) => new Speed(_value * new QuantityValue(1143, 1250, false), SpeedUnit.MeterPerSecond), // BaseUnit -> SpeedUnit - (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerHour) => new Speed((_value * 3600) / 1e-2d, SpeedUnit.CentimeterPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerMinute) => new Speed((_value * 60) / 1e-2d, SpeedUnit.CentimeterPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerSecond) => new Speed((_value) / 1e-2d, SpeedUnit.CentimeterPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.DecimeterPerMinute) => new Speed((_value * 60) / 1e-1d, SpeedUnit.DecimeterPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.DecimeterPerSecond) => new Speed((_value) / 1e-1d, SpeedUnit.DecimeterPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerHour) => new Speed(_value / 0.3048 * 3600, SpeedUnit.FootPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerMinute) => new Speed(_value / 0.3048 * 60, SpeedUnit.FootPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerSecond) => new Speed(_value / 0.3048, SpeedUnit.FootPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerHour) => new Speed((_value / 2.54e-2) * 3600, SpeedUnit.InchPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerMinute) => new Speed((_value / 2.54e-2) * 60, SpeedUnit.InchPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerSecond) => new Speed(_value / 2.54e-2, SpeedUnit.InchPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerHour) => new Speed((_value * 3600) / 1e3d, SpeedUnit.KilometerPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerMinute) => new Speed((_value * 60) / 1e3d, SpeedUnit.KilometerPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerSecond) => new Speed((_value) / 1e3d, SpeedUnit.KilometerPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.Knot) => new Speed(_value / (1852.0 / 3600.0), SpeedUnit.Knot), - (SpeedUnit.MeterPerSecond, SpeedUnit.Mach) => new Speed(_value / 340.29, SpeedUnit.Mach), + (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerHour) => new Speed(_value * 360000, SpeedUnit.CentimeterPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerMinute) => new Speed(_value * 6000, SpeedUnit.CentimeterPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.CentimeterPerSecond) => new Speed(_value * 100, SpeedUnit.CentimeterPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.DecimeterPerMinute) => new Speed(_value * 600, SpeedUnit.DecimeterPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.DecimeterPerSecond) => new Speed(_value * 10, SpeedUnit.DecimeterPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerHour) => new Speed(_value * new QuantityValue(1500000, 127, false), SpeedUnit.FootPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerMinute) => new Speed(_value * new QuantityValue(25000, 127, false), SpeedUnit.FootPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.FootPerSecond) => new Speed(_value * new QuantityValue(1250, 381, false), SpeedUnit.FootPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerHour) => new Speed(_value * new QuantityValue(18000000, 127, false), SpeedUnit.InchPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerMinute) => new Speed(_value * new QuantityValue(300000, 127, false), SpeedUnit.InchPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.InchPerSecond) => new Speed(_value * new QuantityValue(5000, 127, false), SpeedUnit.InchPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerHour) => new Speed(_value * new QuantityValue(18, 5, false), SpeedUnit.KilometerPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerMinute) => new Speed(_value * new QuantityValue(3, 50, false), SpeedUnit.KilometerPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.KilometerPerSecond) => new Speed(_value / 1000, SpeedUnit.KilometerPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.Knot) => new Speed(_value * new QuantityValue(900, 463, false), SpeedUnit.Knot), + (SpeedUnit.MeterPerSecond, SpeedUnit.Mach) => new Speed(_value * new QuantityValue(100, 34029, false), SpeedUnit.Mach), (SpeedUnit.MeterPerSecond, SpeedUnit.MeterPerHour) => new Speed(_value * 3600, SpeedUnit.MeterPerHour), (SpeedUnit.MeterPerSecond, SpeedUnit.MeterPerMinute) => new Speed(_value * 60, SpeedUnit.MeterPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.MicrometerPerMinute) => new Speed((_value * 60) / 1e-6d, SpeedUnit.MicrometerPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.MicrometerPerSecond) => new Speed((_value) / 1e-6d, SpeedUnit.MicrometerPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.MilePerHour) => new Speed(_value / 0.44704, SpeedUnit.MilePerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerHour) => new Speed((_value * 3600) / 1e-3d, SpeedUnit.MillimeterPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerMinute) => new Speed((_value * 60) / 1e-3d, SpeedUnit.MillimeterPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerSecond) => new Speed((_value) / 1e-3d, SpeedUnit.MillimeterPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.NanometerPerMinute) => new Speed((_value * 60) / 1e-9d, SpeedUnit.NanometerPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.NanometerPerSecond) => new Speed((_value) / 1e-9d, SpeedUnit.NanometerPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerHour) => new Speed((_value * 3937 / 1200) * 3600, SpeedUnit.UsSurveyFootPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerMinute) => new Speed((_value * 3937 / 1200) * 60, SpeedUnit.UsSurveyFootPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerSecond) => new Speed(_value * 3937 / 1200, SpeedUnit.UsSurveyFootPerSecond), - (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerHour) => new Speed(_value / 0.9144 * 3600, SpeedUnit.YardPerHour), - (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerMinute) => new Speed(_value / 0.9144 * 60, SpeedUnit.YardPerMinute), - (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerSecond) => new Speed(_value / 0.9144, SpeedUnit.YardPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.MicrometerPerMinute) => new Speed(_value * 60000000, SpeedUnit.MicrometerPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.MicrometerPerSecond) => new Speed(_value * 1000000, SpeedUnit.MicrometerPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.MilePerHour) => new Speed(_value * new QuantityValue(3125, 1397, false), SpeedUnit.MilePerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerHour) => new Speed(_value * 3600000, SpeedUnit.MillimeterPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerMinute) => new Speed(_value * 60000, SpeedUnit.MillimeterPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.MillimeterPerSecond) => new Speed(_value * 1000, SpeedUnit.MillimeterPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.NanometerPerMinute) => new Speed(_value * 60000000000, SpeedUnit.NanometerPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.NanometerPerSecond) => new Speed(_value * 1000000000, SpeedUnit.NanometerPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerHour) => new Speed(_value * 11811, SpeedUnit.UsSurveyFootPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerMinute) => new Speed(_value * new QuantityValue(3937, 20, false), SpeedUnit.UsSurveyFootPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.UsSurveyFootPerSecond) => new Speed(_value * new QuantityValue(3937, 1200, false), SpeedUnit.UsSurveyFootPerSecond), + (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerHour) => new Speed(_value * new QuantityValue(500000, 127, false), SpeedUnit.YardPerHour), + (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerMinute) => new Speed(_value * new QuantityValue(25000, 381, false), SpeedUnit.YardPerMinute), + (SpeedUnit.MeterPerSecond, SpeedUnit.YardPerSecond) => new Speed(_value * new QuantityValue(1250, 1143, false), SpeedUnit.YardPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 5398cbcef5..0e8931f6d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,7 +87,7 @@ static StandardVolumeFlow() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) + public StandardVolumeFlow(QuantityValue value, StandardVolumeFlowUnit unit) { _value = value; _unit = unit; @@ -100,7 +101,7 @@ public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public StandardVolumeFlow(double value, UnitSystem unitSystem) + public StandardVolumeFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -151,10 +152,10 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,47 +180,47 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); + public QuantityValue StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); + public QuantityValue StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); /// /// Gets a value of this quantity converted into /// - public double StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); + public QuantityValue StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); /// /// Gets a value of this quantity converted into /// - public double StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); + public QuantityValue StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); + public QuantityValue StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); /// /// Gets a value of this quantity converted into /// - public double StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); + public QuantityValue StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); /// /// Gets a value of this quantity converted into /// - public double StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); + public QuantityValue StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); + public QuantityValue StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); + public QuantityValue StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); #endregion @@ -283,7 +284,7 @@ public static string GetAbbreviation(StandardVolumeFlowUnit unit, IFormatProvide /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(double value) + public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); } @@ -291,7 +292,7 @@ public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(double va /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicFeetPerHour(double value) + public static StandardVolumeFlow FromStandardCubicFeetPerHour(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerHour); } @@ -299,7 +300,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerHour(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicFeetPerMinute(double value) + public static StandardVolumeFlow FromStandardCubicFeetPerMinute(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerMinute); } @@ -307,7 +308,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerMinute(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicFeetPerSecond(double value) + public static StandardVolumeFlow FromStandardCubicFeetPerSecond(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerSecond); } @@ -315,7 +316,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerSecond(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicMetersPerDay(double value) + public static StandardVolumeFlow FromStandardCubicMetersPerDay(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerDay); } @@ -323,7 +324,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerDay(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicMetersPerHour(double value) + public static StandardVolumeFlow FromStandardCubicMetersPerHour(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerHour); } @@ -331,7 +332,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerHour(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicMetersPerMinute(double value) + public static StandardVolumeFlow FromStandardCubicMetersPerMinute(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerMinute); } @@ -339,7 +340,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerMinute(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardCubicMetersPerSecond(double value) + public static StandardVolumeFlow FromStandardCubicMetersPerSecond(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerSecond); } @@ -347,7 +348,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerSecond(double value) /// /// Creates a from . /// - public static StandardVolumeFlow FromStandardLitersPerMinute(double value) + public static StandardVolumeFlow FromStandardLitersPerMinute(QuantityValue value) { return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardLiterPerMinute); } @@ -358,7 +359,7 @@ public static StandardVolumeFlow FromStandardLitersPerMinute(double value) /// Value to convert from. /// Unit to convert from. /// StandardVolumeFlow unit value. - public static StandardVolumeFlow From(double value, StandardVolumeFlowUnit fromUnit) + public static StandardVolumeFlow From(QuantityValue value, StandardVolumeFlowUnit fromUnit) { return new StandardVolumeFlow(value, fromUnit); } @@ -530,25 +531,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(double left, StandardVolumeFlow right) + public static StandardVolumeFlow operator *(QuantityValue left, StandardVolumeFlow right) { return new StandardVolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(StandardVolumeFlow left, double right) + public static StandardVolumeFlow operator *(StandardVolumeFlow left, QuantityValue right) { return new StandardVolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static StandardVolumeFlow operator /(StandardVolumeFlow left, double right) + public static StandardVolumeFlow operator /(StandardVolumeFlow left, QuantityValue right) { return new StandardVolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(StandardVolumeFlow left, StandardVolumeFlow right) + public static QuantityValue operator /(StandardVolumeFlow left, StandardVolumeFlow right) { return left.StandardCubicMetersPerSecond / right.StandardCubicMetersPerSecond; } @@ -581,27 +582,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is StandardVolumeFlow otherQuantity)) @@ -611,15 +605,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(StandardVolumeFlow other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +693,10 @@ public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -722,7 +713,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -735,7 +726,12 @@ public bool Equals(StandardVolumeFlow other, StandardVolumeFlow tolerance) /// A hash code for the current StandardVolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -746,7 +742,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(StandardVolumeFlowUnit unit) + public QuantityValue As(StandardVolumeFlowUnit unit) { if (Unit == unit) return Value; @@ -755,7 +751,7 @@ public double As(StandardVolumeFlowUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -770,7 +766,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); @@ -836,20 +832,20 @@ private bool TryToUnit(StandardVolumeFlowUnit unit, [NotNullWhen(true)] out Stan StandardVolumeFlow? convertedOrNull = (Unit, unit) switch { // StandardVolumeFlowUnit -> BaseUnit - (StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 6e7, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), - (StandardVolumeFlowUnit.StandardCubicFootPerHour, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value * 7.8657907199999087346816086183876e-6, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), - (StandardVolumeFlowUnit.StandardCubicFootPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 2118.88000326, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), - (StandardVolumeFlowUnit.StandardCubicFootPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 35.314666721, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), + (StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 60000000, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), + (StandardVolumeFlowUnit.StandardCubicFootPerHour, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value * new QuantityValue(6145149, 781250000000, false), StandardVolumeFlowUnit.StandardCubicMeterPerSecond), + (StandardVolumeFlowUnit.StandardCubicFootPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value * new QuantityValue(18435447, 39062500000, false), StandardVolumeFlowUnit.StandardCubicMeterPerSecond), + (StandardVolumeFlowUnit.StandardCubicFootPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value * new QuantityValue(55306341, 1953125000, false), StandardVolumeFlowUnit.StandardCubicMeterPerSecond), (StandardVolumeFlowUnit.StandardCubicMeterPerDay, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 86400, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), (StandardVolumeFlowUnit.StandardCubicMeterPerHour, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 3600, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), (StandardVolumeFlowUnit.StandardCubicMeterPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 60, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), (StandardVolumeFlowUnit.StandardLiterPerMinute, StandardVolumeFlowUnit.StandardCubicMeterPerSecond) => new StandardVolumeFlow(_value / 60000, StandardVolumeFlowUnit.StandardCubicMeterPerSecond), // BaseUnit -> StandardVolumeFlowUnit - (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute) => new StandardVolumeFlow(_value * 6e7, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute), - (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerHour) => new StandardVolumeFlow(_value / 7.8657907199999087346816086183876e-6, StandardVolumeFlowUnit.StandardCubicFootPerHour), - (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerMinute) => new StandardVolumeFlow(_value * 2118.88000326, StandardVolumeFlowUnit.StandardCubicFootPerMinute), - (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerSecond) => new StandardVolumeFlow(_value * 35.314666721, StandardVolumeFlowUnit.StandardCubicFootPerSecond), + (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute) => new StandardVolumeFlow(_value * 60000000, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute), + (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerHour) => new StandardVolumeFlow(_value * new QuantityValue(781250000000, 6145149, false), StandardVolumeFlowUnit.StandardCubicFootPerHour), + (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerMinute) => new StandardVolumeFlow(_value * new QuantityValue(39062500000, 18435447, false), StandardVolumeFlowUnit.StandardCubicFootPerMinute), + (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicFootPerSecond) => new StandardVolumeFlow(_value * new QuantityValue(1953125000, 55306341, false), StandardVolumeFlowUnit.StandardCubicFootPerSecond), (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerDay) => new StandardVolumeFlow(_value * 86400, StandardVolumeFlowUnit.StandardCubicMeterPerDay), (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerHour) => new StandardVolumeFlow(_value * 3600, StandardVolumeFlowUnit.StandardCubicMeterPerHour), (StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerMinute) => new StandardVolumeFlow(_value * 60, StandardVolumeFlowUnit.StandardCubicMeterPerMinute), diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 605a89f181..f083bbdaaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,7 +88,7 @@ static Temperature() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Temperature(double value, TemperatureUnit unit) + public Temperature(QuantityValue value, TemperatureUnit unit) { _value = value; _unit = unit; @@ -101,7 +102,7 @@ public Temperature(double value, TemperatureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Temperature(double value, UnitSystem unitSystem) + public Temperature(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -149,10 +150,10 @@ public Temperature(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,52 +178,52 @@ public Temperature(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius); + public QuantityValue DegreesCelsius => As(TemperatureUnit.DegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle); + public QuantityValue DegreesDelisle => As(TemperatureUnit.DegreeDelisle); /// /// Gets a value of this quantity converted into /// - public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); + public QuantityValue DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double DegreesNewton => As(TemperatureUnit.DegreeNewton); + public QuantityValue DegreesNewton => As(TemperatureUnit.DegreeNewton); /// /// Gets a value of this quantity converted into /// - public double DegreesRankine => As(TemperatureUnit.DegreeRankine); + public QuantityValue DegreesRankine => As(TemperatureUnit.DegreeRankine); /// /// Gets a value of this quantity converted into /// - public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur); + public QuantityValue DegreesReaumur => As(TemperatureUnit.DegreeReaumur); /// /// Gets a value of this quantity converted into /// - public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer); + public QuantityValue DegreesRoemer => As(TemperatureUnit.DegreeRoemer); /// /// Gets a value of this quantity converted into /// - public double Kelvins => As(TemperatureUnit.Kelvin); + public QuantityValue Kelvins => As(TemperatureUnit.Kelvin); /// /// Gets a value of this quantity converted into /// - public double MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); + public QuantityValue MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double SolarTemperatures => As(TemperatureUnit.SolarTemperature); + public QuantityValue SolarTemperatures => As(TemperatureUnit.SolarTemperature); #endregion @@ -288,7 +289,7 @@ public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? prov /// /// Creates a from . /// - public static Temperature FromDegreesCelsius(double value) + public static Temperature FromDegreesCelsius(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeCelsius); } @@ -296,7 +297,7 @@ public static Temperature FromDegreesCelsius(double value) /// /// Creates a from . /// - public static Temperature FromDegreesDelisle(double value) + public static Temperature FromDegreesDelisle(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeDelisle); } @@ -304,7 +305,7 @@ public static Temperature FromDegreesDelisle(double value) /// /// Creates a from . /// - public static Temperature FromDegreesFahrenheit(double value) + public static Temperature FromDegreesFahrenheit(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeFahrenheit); } @@ -312,7 +313,7 @@ public static Temperature FromDegreesFahrenheit(double value) /// /// Creates a from . /// - public static Temperature FromDegreesNewton(double value) + public static Temperature FromDegreesNewton(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeNewton); } @@ -320,7 +321,7 @@ public static Temperature FromDegreesNewton(double value) /// /// Creates a from . /// - public static Temperature FromDegreesRankine(double value) + public static Temperature FromDegreesRankine(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeRankine); } @@ -328,7 +329,7 @@ public static Temperature FromDegreesRankine(double value) /// /// Creates a from . /// - public static Temperature FromDegreesReaumur(double value) + public static Temperature FromDegreesReaumur(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeReaumur); } @@ -336,7 +337,7 @@ public static Temperature FromDegreesReaumur(double value) /// /// Creates a from . /// - public static Temperature FromDegreesRoemer(double value) + public static Temperature FromDegreesRoemer(QuantityValue value) { return new Temperature(value, TemperatureUnit.DegreeRoemer); } @@ -344,7 +345,7 @@ public static Temperature FromDegreesRoemer(double value) /// /// Creates a from . /// - public static Temperature FromKelvins(double value) + public static Temperature FromKelvins(QuantityValue value) { return new Temperature(value, TemperatureUnit.Kelvin); } @@ -352,7 +353,7 @@ public static Temperature FromKelvins(double value) /// /// Creates a from . /// - public static Temperature FromMillidegreesCelsius(double value) + public static Temperature FromMillidegreesCelsius(QuantityValue value) { return new Temperature(value, TemperatureUnit.MillidegreeCelsius); } @@ -360,7 +361,7 @@ public static Temperature FromMillidegreesCelsius(double value) /// /// Creates a from . /// - public static Temperature FromSolarTemperatures(double value) + public static Temperature FromSolarTemperatures(QuantityValue value) { return new Temperature(value, TemperatureUnit.SolarTemperature); } @@ -371,7 +372,7 @@ public static Temperature FromSolarTemperatures(double value) /// Value to convert from. /// Unit to convert from. /// Temperature unit value. - public static Temperature From(double value, TemperatureUnit fromUnit) + public static Temperature From(QuantityValue value, TemperatureUnit fromUnit) { return new Temperature(value, fromUnit); } @@ -548,27 +549,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Temperature left, Temperature right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Temperature other, Temperature tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Temperature left, Temperature right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Temperature otherQuantity)) @@ -578,15 +572,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Temperature other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -669,10 +660,10 @@ public bool Equals(Temperature other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -689,7 +680,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Temperature other, Temperature tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -702,7 +693,12 @@ public bool Equals(Temperature other, Temperature tolerance) /// A hash code for the current Temperature. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -713,7 +709,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureUnit unit) + public QuantityValue As(TemperatureUnit unit) { if (Unit == unit) return Value; @@ -722,7 +718,7 @@ public double As(TemperatureUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -737,7 +733,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); @@ -803,25 +799,25 @@ private bool TryToUnit(TemperatureUnit unit, [NotNullWhen(true)] out Temperature Temperature? convertedOrNull = (Unit, unit) switch { // TemperatureUnit -> BaseUnit - (TemperatureUnit.DegreeCelsius, TemperatureUnit.Kelvin) => new Temperature(_value + 273.15, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeDelisle, TemperatureUnit.Kelvin) => new Temperature(_value * -2 / 3 + 373.15, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeFahrenheit, TemperatureUnit.Kelvin) => new Temperature(_value * 5 / 9 + 459.67 * 5 / 9, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeNewton, TemperatureUnit.Kelvin) => new Temperature(_value * 100 / 33 + 273.15, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeRankine, TemperatureUnit.Kelvin) => new Temperature(_value * 5 / 9, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeReaumur, TemperatureUnit.Kelvin) => new Temperature(_value * 5 / 4 + 273.15, TemperatureUnit.Kelvin), - (TemperatureUnit.DegreeRoemer, TemperatureUnit.Kelvin) => new Temperature(_value * 40 / 21 + 273.15 - 7.5 * 40d / 21, TemperatureUnit.Kelvin), - (TemperatureUnit.MillidegreeCelsius, TemperatureUnit.Kelvin) => new Temperature(_value / 1000 + 273.15, TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeCelsius, TemperatureUnit.Kelvin) => new Temperature(_value + new QuantityValue(5463, 20, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeDelisle, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(-2, 3, false) + new QuantityValue(7463, 20, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeFahrenheit, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(5, 9, false) + new QuantityValue(45967, 180, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeNewton, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(100, 33, false) + new QuantityValue(5463, 20, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeRankine, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(5, 9, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeReaumur, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(5, 4, false) + new QuantityValue(5463, 20, false), TemperatureUnit.Kelvin), + (TemperatureUnit.DegreeRoemer, TemperatureUnit.Kelvin) => new Temperature(_value * new QuantityValue(40, 21, false) + new QuantityValue(36241, 140, false), TemperatureUnit.Kelvin), + (TemperatureUnit.MillidegreeCelsius, TemperatureUnit.Kelvin) => new Temperature(_value / 1000 + new QuantityValue(5463, 20, false), TemperatureUnit.Kelvin), (TemperatureUnit.SolarTemperature, TemperatureUnit.Kelvin) => new Temperature(_value * 5778, TemperatureUnit.Kelvin), // BaseUnit -> TemperatureUnit - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeCelsius) => new Temperature(_value - 273.15, TemperatureUnit.DegreeCelsius), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeDelisle) => new Temperature((_value - 373.15) * -3 / 2, TemperatureUnit.DegreeDelisle), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeFahrenheit) => new Temperature((_value - 459.67 * 5 / 9) * 9 / 5, TemperatureUnit.DegreeFahrenheit), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeNewton) => new Temperature((_value - 273.15) * 33 / 100, TemperatureUnit.DegreeNewton), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeRankine) => new Temperature(_value * 9 / 5, TemperatureUnit.DegreeRankine), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeReaumur) => new Temperature((_value - 273.15) * 4 / 5, TemperatureUnit.DegreeReaumur), - (TemperatureUnit.Kelvin, TemperatureUnit.DegreeRoemer) => new Temperature((_value - (273.15 - 7.5 * 40d / 21)) * 21 / 40, TemperatureUnit.DegreeRoemer), - (TemperatureUnit.Kelvin, TemperatureUnit.MillidegreeCelsius) => new Temperature((_value - 273.15) * 1000, TemperatureUnit.MillidegreeCelsius), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeCelsius) => new Temperature(_value + new QuantityValue(-5463, 20, false), TemperatureUnit.DegreeCelsius), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeDelisle) => new Temperature(_value * new QuantityValue(-3, 2, false) + new QuantityValue(22389, 40, false), TemperatureUnit.DegreeDelisle), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeFahrenheit) => new Temperature(_value * new QuantityValue(9, 5, false) + new QuantityValue(-45967, 100, false), TemperatureUnit.DegreeFahrenheit), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeNewton) => new Temperature(_value * new QuantityValue(33, 100, false) + new QuantityValue(-180279, 2000, false), TemperatureUnit.DegreeNewton), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeRankine) => new Temperature(_value * new QuantityValue(9, 5, false), TemperatureUnit.DegreeRankine), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeReaumur) => new Temperature(_value * new QuantityValue(4, 5, false) + new QuantityValue(-5463, 25, false), TemperatureUnit.DegreeReaumur), + (TemperatureUnit.Kelvin, TemperatureUnit.DegreeRoemer) => new Temperature(_value * new QuantityValue(21, 40, false) + new QuantityValue(-108723, 800, false), TemperatureUnit.DegreeRoemer), + (TemperatureUnit.Kelvin, TemperatureUnit.MillidegreeCelsius) => new Temperature(_value * 1000 + -273150, TemperatureUnit.MillidegreeCelsius), (TemperatureUnit.Kelvin, TemperatureUnit.SolarTemperature) => new Temperature(_value / 5778, TemperatureUnit.SolarTemperature), _ => null diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index b801bea101..d3b04e7869 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -93,7 +91,7 @@ static TemperatureChangeRate() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) + public TemperatureChangeRate(QuantityValue value, TemperatureChangeRateUnit unit) { _value = value; _unit = unit; @@ -107,7 +105,7 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureChangeRate(double value, UnitSystem unitSystem) + public TemperatureChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -158,10 +156,10 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -186,52 +184,52 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + public QuantityValue CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + public QuantityValue DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + public QuantityValue DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + public QuantityValue DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); /// /// Gets a value of this quantity converted into /// - public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + public QuantityValue DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + public QuantityValue HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + public QuantityValue KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + public QuantityValue MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + public QuantityValue MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); /// /// Gets a value of this quantity converted into /// - public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + public QuantityValue NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); #endregion @@ -297,7 +295,7 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProv /// /// Creates a from . /// - public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); } @@ -305,7 +303,7 @@ public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(double valu /// /// Creates a from . /// - public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); } @@ -313,7 +311,7 @@ public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(double value /// /// Creates a from . /// - public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); } @@ -321,7 +319,7 @@ public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(double value /// /// Creates a from . /// - public static TemperatureChangeRate FromDegreesCelsiusPerMinute(double value) + public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); } @@ -329,7 +327,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerMinute(double value) /// /// Creates a from . /// - public static TemperatureChangeRate FromDegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); } @@ -337,7 +335,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerSecond(double value) /// /// Creates a from . /// - public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); } @@ -345,7 +343,7 @@ public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(double valu /// /// Creates a from . /// - public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); } @@ -353,7 +351,7 @@ public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(double value /// /// Creates a from . /// - public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); } @@ -361,7 +359,7 @@ public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(double valu /// /// Creates a from . /// - public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); } @@ -369,7 +367,7 @@ public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(double valu /// /// Creates a from . /// - public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(double value) + public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValue value) { return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); } @@ -380,7 +378,7 @@ public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(double value /// Value to convert from. /// Unit to convert from. /// TemperatureChangeRate unit value. - public static TemperatureChangeRate From(double value, TemperatureChangeRateUnit fromUnit) + public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeRateUnit fromUnit) { return new TemperatureChangeRate(value, fromUnit); } @@ -552,25 +550,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(double left, TemperatureChangeRate right) + public static TemperatureChangeRate operator *(QuantityValue left, TemperatureChangeRate right) { return new TemperatureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(TemperatureChangeRate left, double right) + public static TemperatureChangeRate operator *(TemperatureChangeRate left, QuantityValue right) { return new TemperatureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureChangeRate operator /(TemperatureChangeRate left, double right) + public static TemperatureChangeRate operator /(TemperatureChangeRate left, QuantityValue right) { return new TemperatureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureChangeRate left, TemperatureChangeRate right) + public static QuantityValue operator /(TemperatureChangeRate left, TemperatureChangeRate right) { return left.DegreesCelsiusPerSecond / right.DegreesCelsiusPerSecond; } @@ -613,27 +611,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureChangeRate otherQuantity)) @@ -643,15 +634,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(TemperatureChangeRate other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -734,10 +722,10 @@ public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -754,7 +742,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -767,7 +755,12 @@ public bool Equals(TemperatureChangeRate other, TemperatureChangeRate tolerance) /// A hash code for the current TemperatureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -778,7 +771,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureChangeRateUnit unit) + public QuantityValue As(TemperatureChangeRateUnit unit) { if (Unit == unit) return Value; @@ -787,7 +780,7 @@ public double As(TemperatureChangeRateUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -802,7 +795,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); @@ -868,26 +861,26 @@ private bool TryToUnit(TemperatureChangeRateUnit unit, [NotNullWhen(true)] out T TemperatureChangeRate? convertedOrNull = (Unit, unit) switch { // TemperatureChangeRateUnit -> BaseUnit - (TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-2d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e1d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-1d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 100, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 10, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 10, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 60, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e2d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e3d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-6d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-3d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) * 1e-9d, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 100, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 1000, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 1000000, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 1000, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 1000000000, TemperatureChangeRateUnit.DegreeCelsiusPerSecond), // BaseUnit -> TemperatureChangeRateUnit - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-2d, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e1d, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-1d, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 100, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 10, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 10, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond), (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerMinute) => new TemperatureChangeRate(_value * 60, TemperatureChangeRateUnit.DegreeCelsiusPerMinute), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e2d, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e3d, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-6d, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-3d, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond), - (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond) => new TemperatureChangeRate((_value) / 1e-9d, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 100, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond) => new TemperatureChangeRate(_value / 1000, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 1000000, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 1000, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond), + (TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond) => new TemperatureChangeRate(_value * 1000000000, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index a3001d3e02..662875c122 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +46,7 @@ namespace UnitsNet IMultiplyOperators, IDivisionOperators, IDivisionOperators, - IMultiplyOperators, + IMultiplyOperators, #endif IComparable, IComparable, @@ -60,7 +58,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,7 +96,7 @@ static TemperatureDelta() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public TemperatureDelta(double value, TemperatureDeltaUnit unit) + public TemperatureDelta(QuantityValue value, TemperatureDeltaUnit unit) { _value = value; _unit = unit; @@ -112,7 +110,7 @@ public TemperatureDelta(double value, TemperatureDeltaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureDelta(double value, UnitSystem unitSystem) + public TemperatureDelta(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -163,10 +161,10 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,47 +189,47 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); + public QuantityValue DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); + public QuantityValue DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); /// /// Gets a value of this quantity converted into /// - public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); + public QuantityValue DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); + public QuantityValue DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); /// /// Gets a value of this quantity converted into /// - public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); + public QuantityValue DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); /// /// Gets a value of this quantity converted into /// - public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); + public QuantityValue DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); /// /// Gets a value of this quantity converted into /// - public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); + public QuantityValue DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); /// /// Gets a value of this quantity converted into /// - public double Kelvins => As(TemperatureDeltaUnit.Kelvin); + public QuantityValue Kelvins => As(TemperatureDeltaUnit.Kelvin); /// /// Gets a value of this quantity converted into /// - public double MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); + public QuantityValue MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); #endregion @@ -295,7 +293,7 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? /// /// Creates a from . /// - public static TemperatureDelta FromDegreesCelsius(double value) + public static TemperatureDelta FromDegreesCelsius(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius); } @@ -303,7 +301,7 @@ public static TemperatureDelta FromDegreesCelsius(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesDelisle(double value) + public static TemperatureDelta FromDegreesDelisle(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle); } @@ -311,7 +309,7 @@ public static TemperatureDelta FromDegreesDelisle(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesFahrenheit(double value) + public static TemperatureDelta FromDegreesFahrenheit(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit); } @@ -319,7 +317,7 @@ public static TemperatureDelta FromDegreesFahrenheit(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesNewton(double value) + public static TemperatureDelta FromDegreesNewton(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton); } @@ -327,7 +325,7 @@ public static TemperatureDelta FromDegreesNewton(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesRankine(double value) + public static TemperatureDelta FromDegreesRankine(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine); } @@ -335,7 +333,7 @@ public static TemperatureDelta FromDegreesRankine(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesReaumur(double value) + public static TemperatureDelta FromDegreesReaumur(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur); } @@ -343,7 +341,7 @@ public static TemperatureDelta FromDegreesReaumur(double value) /// /// Creates a from . /// - public static TemperatureDelta FromDegreesRoemer(double value) + public static TemperatureDelta FromDegreesRoemer(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer); } @@ -351,7 +349,7 @@ public static TemperatureDelta FromDegreesRoemer(double value) /// /// Creates a from . /// - public static TemperatureDelta FromKelvins(double value) + public static TemperatureDelta FromKelvins(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin); } @@ -359,7 +357,7 @@ public static TemperatureDelta FromKelvins(double value) /// /// Creates a from . /// - public static TemperatureDelta FromMillidegreesCelsius(double value) + public static TemperatureDelta FromMillidegreesCelsius(QuantityValue value) { return new TemperatureDelta(value, TemperatureDeltaUnit.MillidegreeCelsius); } @@ -370,7 +368,7 @@ public static TemperatureDelta FromMillidegreesCelsius(double value) /// Value to convert from. /// Unit to convert from. /// TemperatureDelta unit value. - public static TemperatureDelta From(double value, TemperatureDeltaUnit fromUnit) + public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fromUnit) { return new TemperatureDelta(value, fromUnit); } @@ -542,25 +540,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureDelta operator *(double left, TemperatureDelta right) + public static TemperatureDelta operator *(QuantityValue left, TemperatureDelta right) { return new TemperatureDelta(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureDelta operator *(TemperatureDelta left, double right) + public static TemperatureDelta operator *(TemperatureDelta left, QuantityValue right) { return new TemperatureDelta(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureDelta operator /(TemperatureDelta left, double right) + public static TemperatureDelta operator /(TemperatureDelta left, QuantityValue right) { return new TemperatureDelta(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureDelta left, TemperatureDelta right) + public static QuantityValue operator /(TemperatureDelta left, TemperatureDelta right) { return left.Kelvins / right.Kelvins; } @@ -569,8 +567,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Relational Operators - /// Get from / . - public static CoefficientOfThermalExpansion operator /(double value, TemperatureDelta temperatureDelta) + /// Get from / . + public static CoefficientOfThermalExpansion operator /(QuantityValue value, TemperatureDelta temperatureDelta) { return CoefficientOfThermalExpansion.FromPerKelvin(value / temperatureDelta.Kelvins); } @@ -611,8 +609,8 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return TemperatureGradient.FromDegreesCelsiusPerKilometer(temperatureDelta.DegreesCelsius / length.Kilometers); } - /// Get from * . - public static double operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) + /// Get from * . + public static QuantityValue operator *(TemperatureDelta temperatureDelta, CoefficientOfThermalExpansion coefficientOfThermalExpansion) { return temperatureDelta.Kelvins * coefficientOfThermalExpansion.PerKelvin; } @@ -645,27 +643,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(TemperatureDelta left, TemperatureDelta right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureDelta other, TemperatureDelta tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(TemperatureDelta left, TemperatureDelta right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureDelta otherQuantity)) @@ -675,15 +666,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(TemperatureDelta other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -766,10 +754,10 @@ public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -786,7 +774,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureDelta other, TemperatureDelta tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -799,7 +787,12 @@ public bool Equals(TemperatureDelta other, TemperatureDelta tolerance) /// A hash code for the current TemperatureDelta. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -810,7 +803,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureDeltaUnit unit) + public QuantityValue As(TemperatureDeltaUnit unit) { if (Unit == unit) return Value; @@ -819,7 +812,7 @@ public double As(TemperatureDeltaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -834,7 +827,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); @@ -901,23 +894,23 @@ private bool TryToUnit(TemperatureDeltaUnit unit, [NotNullWhen(true)] out Temper { // TemperatureDeltaUnit -> BaseUnit (TemperatureDeltaUnit.DegreeCelsius, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeDelisle, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * -2 / 3, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * 5 / 9, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeNewton, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * 100 / 33, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeRankine, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * 5 / 9, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeReaumur, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * 5 / 4, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.DegreeRoemer, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * 40 / 21, TemperatureDeltaUnit.Kelvin), - (TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta((_value) * 1e-3d, TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeDelisle, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(-2, 3, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(5, 9, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeNewton, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(100, 33, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeRankine, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(5, 9, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeReaumur, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(5, 4, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.DegreeRoemer, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value * new QuantityValue(40, 21, false), TemperatureDeltaUnit.Kelvin), + (TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDeltaUnit.Kelvin) => new TemperatureDelta(_value / 1000, TemperatureDeltaUnit.Kelvin), // BaseUnit -> TemperatureDeltaUnit (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeCelsius) => new TemperatureDelta(_value, TemperatureDeltaUnit.DegreeCelsius), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeDelisle) => new TemperatureDelta(_value * -3 / 2, TemperatureDeltaUnit.DegreeDelisle), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeFahrenheit) => new TemperatureDelta(_value * 9 / 5, TemperatureDeltaUnit.DegreeFahrenheit), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeNewton) => new TemperatureDelta(_value * 33 / 100, TemperatureDeltaUnit.DegreeNewton), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeRankine) => new TemperatureDelta(_value * 9 / 5, TemperatureDeltaUnit.DegreeRankine), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeReaumur) => new TemperatureDelta(_value * 4 / 5, TemperatureDeltaUnit.DegreeReaumur), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeRoemer) => new TemperatureDelta(_value * 21 / 40, TemperatureDeltaUnit.DegreeRoemer), - (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.MillidegreeCelsius) => new TemperatureDelta((_value) / 1e-3d, TemperatureDeltaUnit.MillidegreeCelsius), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeDelisle) => new TemperatureDelta(_value * new QuantityValue(-3, 2, false), TemperatureDeltaUnit.DegreeDelisle), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeFahrenheit) => new TemperatureDelta(_value * new QuantityValue(9, 5, false), TemperatureDeltaUnit.DegreeFahrenheit), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeNewton) => new TemperatureDelta(_value * new QuantityValue(33, 100, false), TemperatureDeltaUnit.DegreeNewton), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeRankine) => new TemperatureDelta(_value * new QuantityValue(9, 5, false), TemperatureDeltaUnit.DegreeRankine), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeReaumur) => new TemperatureDelta(_value * new QuantityValue(4, 5, false), TemperatureDeltaUnit.DegreeReaumur), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeRoemer) => new TemperatureDelta(_value * new QuantityValue(21, 40, false), TemperatureDeltaUnit.DegreeRoemer), + (TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.MillidegreeCelsius) => new TemperatureDelta(_value * 1000, TemperatureDeltaUnit.MillidegreeCelsius), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index babb3f6f2c..87494c85e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -54,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,7 +85,7 @@ static TemperatureGradient() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public TemperatureGradient(double value, TemperatureGradientUnit unit) + public TemperatureGradient(QuantityValue value, TemperatureGradientUnit unit) { _value = value; _unit = unit; @@ -101,7 +99,7 @@ public TemperatureGradient(double value, TemperatureGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureGradient(double value, UnitSystem unitSystem) + public TemperatureGradient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -152,10 +150,10 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -180,22 +178,22 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double DegreesCelsiusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); + public QuantityValue DegreesCelsiusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); /// /// Gets a value of this quantity converted into /// - public double DegreesCelsiusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); + public QuantityValue DegreesCelsiusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); /// /// Gets a value of this quantity converted into /// - public double DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); + public QuantityValue DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); /// /// Gets a value of this quantity converted into /// - public double KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); + public QuantityValue KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); #endregion @@ -249,7 +247,7 @@ public static string GetAbbreviation(TemperatureGradientUnit unit, IFormatProvid /// /// Creates a from . /// - public static TemperatureGradient FromDegreesCelsiusPerKilometer(double value) + public static TemperatureGradient FromDegreesCelsiusPerKilometer(QuantityValue value) { return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerKilometer); } @@ -257,7 +255,7 @@ public static TemperatureGradient FromDegreesCelsiusPerKilometer(double value) /// /// Creates a from . /// - public static TemperatureGradient FromDegreesCelsiusPerMeter(double value) + public static TemperatureGradient FromDegreesCelsiusPerMeter(QuantityValue value) { return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerMeter); } @@ -265,7 +263,7 @@ public static TemperatureGradient FromDegreesCelsiusPerMeter(double value) /// /// Creates a from . /// - public static TemperatureGradient FromDegreesFahrenheitPerFoot(double value) + public static TemperatureGradient FromDegreesFahrenheitPerFoot(QuantityValue value) { return new TemperatureGradient(value, TemperatureGradientUnit.DegreeFahrenheitPerFoot); } @@ -273,7 +271,7 @@ public static TemperatureGradient FromDegreesFahrenheitPerFoot(double value) /// /// Creates a from . /// - public static TemperatureGradient FromKelvinsPerMeter(double value) + public static TemperatureGradient FromKelvinsPerMeter(QuantityValue value) { return new TemperatureGradient(value, TemperatureGradientUnit.KelvinPerMeter); } @@ -284,7 +282,7 @@ public static TemperatureGradient FromKelvinsPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// TemperatureGradient unit value. - public static TemperatureGradient From(double value, TemperatureGradientUnit fromUnit) + public static TemperatureGradient From(QuantityValue value, TemperatureGradientUnit fromUnit) { return new TemperatureGradient(value, fromUnit); } @@ -456,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureGradient operator *(double left, TemperatureGradient right) + public static TemperatureGradient operator *(QuantityValue left, TemperatureGradient right) { return new TemperatureGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureGradient operator *(TemperatureGradient left, double right) + public static TemperatureGradient operator *(TemperatureGradient left, QuantityValue right) { return new TemperatureGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureGradient operator /(TemperatureGradient left, double right) + public static TemperatureGradient operator /(TemperatureGradient left, QuantityValue right) { return new TemperatureGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureGradient left, TemperatureGradient right) + public static QuantityValue operator /(TemperatureGradient left, TemperatureGradient right) { return left.KelvinsPerMeter / right.KelvinsPerMeter; } @@ -517,27 +515,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(TemperatureGradient left, TemperatureGradient right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TemperatureGradient other, TemperatureGradient tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(TemperatureGradient left, TemperatureGradient right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is TemperatureGradient otherQuantity)) @@ -547,15 +538,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(TemperatureGradient other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -638,10 +626,10 @@ public bool Equals(TemperatureGradient other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -658,7 +646,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TemperatureGradient other, TemperatureGradient tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -671,7 +659,12 @@ public bool Equals(TemperatureGradient other, TemperatureGradient tolerance) /// A hash code for the current TemperatureGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -682,7 +675,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureGradientUnit unit) + public QuantityValue As(TemperatureGradientUnit unit) { if (Unit == unit) return Value; @@ -691,7 +684,7 @@ public double As(TemperatureGradientUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -706,7 +699,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); @@ -772,14 +765,14 @@ private bool TryToUnit(TemperatureGradientUnit unit, [NotNullWhen(true)] out Tem TemperatureGradient? convertedOrNull = (Unit, unit) switch { // TemperatureGradientUnit -> BaseUnit - (TemperatureGradientUnit.DegreeCelsiusPerKilometer, TemperatureGradientUnit.KelvinPerMeter) => new TemperatureGradient(_value / 1e3, TemperatureGradientUnit.KelvinPerMeter), + (TemperatureGradientUnit.DegreeCelsiusPerKilometer, TemperatureGradientUnit.KelvinPerMeter) => new TemperatureGradient(_value / 1000, TemperatureGradientUnit.KelvinPerMeter), (TemperatureGradientUnit.DegreeCelsiusPerMeter, TemperatureGradientUnit.KelvinPerMeter) => new TemperatureGradient(_value, TemperatureGradientUnit.KelvinPerMeter), - (TemperatureGradientUnit.DegreeFahrenheitPerFoot, TemperatureGradientUnit.KelvinPerMeter) => new TemperatureGradient((_value / 0.3048) * 5 / 9, TemperatureGradientUnit.KelvinPerMeter), + (TemperatureGradientUnit.DegreeFahrenheitPerFoot, TemperatureGradientUnit.KelvinPerMeter) => new TemperatureGradient(_value * new QuantityValue(6250, 3429, false), TemperatureGradientUnit.KelvinPerMeter), // BaseUnit -> TemperatureGradientUnit - (TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeCelsiusPerKilometer) => new TemperatureGradient(_value * 1e3, TemperatureGradientUnit.DegreeCelsiusPerKilometer), + (TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeCelsiusPerKilometer) => new TemperatureGradient(_value * 1000, TemperatureGradientUnit.DegreeCelsiusPerKilometer), (TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeCelsiusPerMeter) => new TemperatureGradient(_value, TemperatureGradientUnit.DegreeCelsiusPerMeter), - (TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeFahrenheitPerFoot) => new TemperatureGradient((_value * 0.3048) * 9 / 5, TemperatureGradientUnit.DegreeFahrenheitPerFoot), + (TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeFahrenheitPerFoot) => new TemperatureGradient(_value * new QuantityValue(3429, 6250, false), TemperatureGradientUnit.DegreeFahrenheitPerFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 9c6b5fd17a..d3e3e67a35 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,7 +83,7 @@ static ThermalConductivity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ThermalConductivity(double value, ThermalConductivityUnit unit) + public ThermalConductivity(QuantityValue value, ThermalConductivityUnit unit) { _value = value; _unit = unit; @@ -96,7 +97,7 @@ public ThermalConductivity(double value, ThermalConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalConductivity(double value, UnitSystem unitSystem) + public ThermalConductivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -147,10 +148,10 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -175,12 +176,12 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); + public QuantityValue BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); /// /// Gets a value of this quantity converted into /// - public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); + public QuantityValue WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); #endregion @@ -230,7 +231,7 @@ public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvid /// /// Creates a from . /// - public static ThermalConductivity FromBtusPerHourFootFahrenheit(double value) + public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue value) { return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit); } @@ -238,7 +239,7 @@ public static ThermalConductivity FromBtusPerHourFootFahrenheit(double value) /// /// Creates a from . /// - public static ThermalConductivity FromWattsPerMeterKelvin(double value) + public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue value) { return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin); } @@ -249,7 +250,7 @@ public static ThermalConductivity FromWattsPerMeterKelvin(double value) /// Value to convert from. /// Unit to convert from. /// ThermalConductivity unit value. - public static ThermalConductivity From(double value, ThermalConductivityUnit fromUnit) + public static ThermalConductivity From(QuantityValue value, ThermalConductivityUnit fromUnit) { return new ThermalConductivity(value, fromUnit); } @@ -421,25 +422,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalConductivity operator *(double left, ThermalConductivity right) + public static ThermalConductivity operator *(QuantityValue left, ThermalConductivity right) { return new ThermalConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalConductivity operator *(ThermalConductivity left, double right) + public static ThermalConductivity operator *(ThermalConductivity left, QuantityValue right) { return new ThermalConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalConductivity operator /(ThermalConductivity left, double right) + public static ThermalConductivity operator /(ThermalConductivity left, QuantityValue right) { return new ThermalConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ThermalConductivity left, ThermalConductivity right) + public static QuantityValue operator /(ThermalConductivity left, ThermalConductivity right) { return left.WattsPerMeterKelvin / right.WattsPerMeterKelvin; } @@ -472,27 +473,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ThermalConductivity left, ThermalConductivity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalConductivity other, ThermalConductivity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ThermalConductivity left, ThermalConductivity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ThermalConductivity otherQuantity)) @@ -502,15 +496,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ThermalConductivity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -593,10 +584,10 @@ public bool Equals(ThermalConductivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -613,7 +604,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ThermalConductivity other, ThermalConductivity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -626,7 +617,12 @@ public bool Equals(ThermalConductivity other, ThermalConductivity tolerance) /// A hash code for the current ThermalConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -637,7 +633,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalConductivityUnit unit) + public QuantityValue As(ThermalConductivityUnit unit) { if (Unit == unit) return Value; @@ -646,7 +642,7 @@ public double As(ThermalConductivityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -661,7 +657,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); @@ -727,10 +723,10 @@ private bool TryToUnit(ThermalConductivityUnit unit, [NotNullWhen(true)] out The ThermalConductivity? convertedOrNull = (Unit, unit) switch { // ThermalConductivityUnit -> BaseUnit - (ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivityUnit.WattPerMeterKelvin) => new ThermalConductivity(_value * 1.73073467, ThermalConductivityUnit.WattPerMeterKelvin), + (ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivityUnit.WattPerMeterKelvin) => new ThermalConductivity(_value * new QuantityValue(173073467, 100000000, false), ThermalConductivityUnit.WattPerMeterKelvin), // BaseUnit -> ThermalConductivityUnit - (ThermalConductivityUnit.WattPerMeterKelvin, ThermalConductivityUnit.BtuPerHourFootFahrenheit) => new ThermalConductivity(_value / 1.73073467, ThermalConductivityUnit.BtuPerHourFootFahrenheit), + (ThermalConductivityUnit.WattPerMeterKelvin, ThermalConductivityUnit.BtuPerHourFootFahrenheit) => new ThermalConductivity(_value * new QuantityValue(100000000, 173073467, false), ThermalConductivityUnit.BtuPerHourFootFahrenheit), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index bc74c7f28b..13af340250 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static ThermalResistance() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public ThermalResistance(double value, ThermalResistanceUnit unit) + public ThermalResistance(QuantityValue value, ThermalResistanceUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public ThermalResistance(double value, ThermalResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalResistance(double value, UnitSystem unitSystem) + public ThermalResistance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,32 +177,32 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + public QuantityValue HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); /// /// Gets a value of this quantity converted into /// - public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + public QuantityValue SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); /// /// Gets a value of this quantity converted into /// - public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + public QuantityValue SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); /// /// Gets a value of this quantity converted into /// - public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + public QuantityValue SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); /// /// Gets a value of this quantity converted into /// - public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + public QuantityValue SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); /// /// Gets a value of this quantity converted into /// - public double SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); + public QuantityValue SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); #endregion @@ -259,7 +260,7 @@ public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider /// /// Creates a from . /// - public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(double value) + public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); } @@ -267,7 +268,7 @@ public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(double /// /// Creates a from . /// - public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(double value) + public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); } @@ -275,7 +276,7 @@ public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocal /// /// Creates a from . /// - public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(double value) + public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); } @@ -283,7 +284,7 @@ public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(double value) /// /// Creates a from . /// - public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(double value) + public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); } @@ -291,7 +292,7 @@ public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(double valu /// /// Creates a from . /// - public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(double value) + public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); } @@ -299,7 +300,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(double value) /// /// Creates a from . /// - public static ThermalResistance FromSquareMeterKelvinsPerWatt(double value) + public static ThermalResistance FromSquareMeterKelvinsPerWatt(QuantityValue value) { return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerWatt); } @@ -310,7 +311,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerWatt(double value) /// Value to convert from. /// Unit to convert from. /// ThermalResistance unit value. - public static ThermalResistance From(double value, ThermalResistanceUnit fromUnit) + public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit fromUnit) { return new ThermalResistance(value, fromUnit); } @@ -482,25 +483,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalResistance operator *(double left, ThermalResistance right) + public static ThermalResistance operator *(QuantityValue left, ThermalResistance right) { return new ThermalResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalResistance operator *(ThermalResistance left, double right) + public static ThermalResistance operator *(ThermalResistance left, QuantityValue right) { return new ThermalResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalResistance operator /(ThermalResistance left, double right) + public static ThermalResistance operator /(ThermalResistance left, QuantityValue right) { return new ThermalResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ThermalResistance left, ThermalResistance right) + public static QuantityValue operator /(ThermalResistance left, ThermalResistance right) { return left.SquareMeterKelvinsPerKilowatt / right.SquareMeterKelvinsPerKilowatt; } @@ -533,27 +534,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(ThermalResistance left, ThermalResistance right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(ThermalResistance other, ThermalResistance tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(ThermalResistance left, ThermalResistance right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is ThermalResistance otherQuantity)) @@ -563,15 +557,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(ThermalResistance other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -654,10 +645,10 @@ public bool Equals(ThermalResistance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -674,7 +665,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(ThermalResistance other, ThermalResistance tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -687,7 +678,12 @@ public bool Equals(ThermalResistance other, ThermalResistance tolerance) /// A hash code for the current ThermalResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -698,7 +694,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalResistanceUnit unit) + public QuantityValue As(ThermalResistanceUnit unit) { if (Unit == unit) return Value; @@ -707,7 +703,7 @@ public double As(ThermalResistanceUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -722,7 +718,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); @@ -788,17 +784,17 @@ private bool TryToUnit(ThermalResistanceUnit unit, [NotNullWhen(true)] out Therm ThermalResistance? convertedOrNull = (Unit, unit) switch { // ThermalResistanceUnit -> BaseUnit - (ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 176.1121482159839, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), - (ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 0.0859779507590433, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), - (ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 0.1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), - (ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 1000.0, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), + (ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * new QuantityValue(1761121482159839, 10000000000000, false), ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), + (ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * new QuantityValue(859779507590433, 10000000000000000, false), ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), + (ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value / 10, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), + (ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 1000, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), (ThermalResistanceUnit.SquareMeterKelvinPerWatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt) => new ThermalResistance(_value * 1000, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), // BaseUnit -> ThermalResistanceUnit - (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu) => new ThermalResistance(_value / 176.1121482159839, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu), - (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie) => new ThermalResistance(_value / 0.0859779507590433, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie), - (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt) => new ThermalResistance(_value / 0.1, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt), - (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt) => new ThermalResistance(_value / 1000.0, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt), + (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu) => new ThermalResistance(_value * new QuantityValue(10000000000000, 1761121482159839, false), ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu), + (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie) => new ThermalResistance(_value * new QuantityValue(10000000000000000, 859779507590433, false), ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie), + (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt) => new ThermalResistance(_value * 10, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt), + (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt) => new ThermalResistance(_value / 1000, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt), (ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterKelvinPerWatt) => new ThermalResistance(_value / 1000, ThermalResistanceUnit.SquareMeterKelvinPerWatt), _ => null diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 0f02672f0e..8fb3a35f23 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -60,7 +58,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -114,7 +112,7 @@ static Torque() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Torque(double value, TorqueUnit unit) + public Torque(QuantityValue value, TorqueUnit unit) { _value = value; _unit = unit; @@ -128,7 +126,7 @@ public Torque(double value, TorqueUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Torque(double value, UnitSystem unitSystem) + public Torque(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -179,10 +177,10 @@ public Torque(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -207,127 +205,127 @@ public Torque(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); + public QuantityValue GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); /// /// Gets a value of this quantity converted into /// - public double GramForceMeters => As(TorqueUnit.GramForceMeter); + public QuantityValue GramForceMeters => As(TorqueUnit.GramForceMeter); /// /// Gets a value of this quantity converted into /// - public double GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); + public QuantityValue GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); + public QuantityValue KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); + public QuantityValue KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); + public QuantityValue KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); + public QuantityValue KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); + public QuantityValue KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); + public QuantityValue KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); + public QuantityValue KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); + public QuantityValue KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); /// /// Gets a value of this quantity converted into /// - public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); + public QuantityValue MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); + public QuantityValue MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); + public QuantityValue MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); /// /// Gets a value of this quantity converted into /// - public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); + public QuantityValue MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); /// /// Gets a value of this quantity converted into /// - public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); + public QuantityValue MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); /// /// Gets a value of this quantity converted into /// - public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); + public QuantityValue NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); /// /// Gets a value of this quantity converted into /// - public double NewtonMeters => As(TorqueUnit.NewtonMeter); + public QuantityValue NewtonMeters => As(TorqueUnit.NewtonMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); + public QuantityValue NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); /// /// Gets a value of this quantity converted into /// - public double PoundalFeet => As(TorqueUnit.PoundalFoot); + public QuantityValue PoundalFeet => As(TorqueUnit.PoundalFoot); /// /// Gets a value of this quantity converted into /// - public double PoundForceFeet => As(TorqueUnit.PoundForceFoot); + public QuantityValue PoundForceFeet => As(TorqueUnit.PoundForceFoot); /// /// Gets a value of this quantity converted into /// - public double PoundForceInches => As(TorqueUnit.PoundForceInch); + public QuantityValue PoundForceInches => As(TorqueUnit.PoundForceInch); /// /// Gets a value of this quantity converted into /// - public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); + public QuantityValue TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); /// /// Gets a value of this quantity converted into /// - public double TonneForceMeters => As(TorqueUnit.TonneForceMeter); + public QuantityValue TonneForceMeters => As(TorqueUnit.TonneForceMeter); /// /// Gets a value of this quantity converted into /// - public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); + public QuantityValue TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); #endregion @@ -423,7 +421,7 @@ public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Torque FromGramForceCentimeters(double value) + public static Torque FromGramForceCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.GramForceCentimeter); } @@ -431,7 +429,7 @@ public static Torque FromGramForceCentimeters(double value) /// /// Creates a from . /// - public static Torque FromGramForceMeters(double value) + public static Torque FromGramForceMeters(QuantityValue value) { return new Torque(value, TorqueUnit.GramForceMeter); } @@ -439,7 +437,7 @@ public static Torque FromGramForceMeters(double value) /// /// Creates a from . /// - public static Torque FromGramForceMillimeters(double value) + public static Torque FromGramForceMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.GramForceMillimeter); } @@ -447,7 +445,7 @@ public static Torque FromGramForceMillimeters(double value) /// /// Creates a from . /// - public static Torque FromKilogramForceCentimeters(double value) + public static Torque FromKilogramForceCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilogramForceCentimeter); } @@ -455,7 +453,7 @@ public static Torque FromKilogramForceCentimeters(double value) /// /// Creates a from . /// - public static Torque FromKilogramForceMeters(double value) + public static Torque FromKilogramForceMeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilogramForceMeter); } @@ -463,7 +461,7 @@ public static Torque FromKilogramForceMeters(double value) /// /// Creates a from . /// - public static Torque FromKilogramForceMillimeters(double value) + public static Torque FromKilogramForceMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilogramForceMillimeter); } @@ -471,7 +469,7 @@ public static Torque FromKilogramForceMillimeters(double value) /// /// Creates a from . /// - public static Torque FromKilonewtonCentimeters(double value) + public static Torque FromKilonewtonCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilonewtonCentimeter); } @@ -479,7 +477,7 @@ public static Torque FromKilonewtonCentimeters(double value) /// /// Creates a from . /// - public static Torque FromKilonewtonMeters(double value) + public static Torque FromKilonewtonMeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilonewtonMeter); } @@ -487,7 +485,7 @@ public static Torque FromKilonewtonMeters(double value) /// /// Creates a from . /// - public static Torque FromKilonewtonMillimeters(double value) + public static Torque FromKilonewtonMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.KilonewtonMillimeter); } @@ -495,7 +493,7 @@ public static Torque FromKilonewtonMillimeters(double value) /// /// Creates a from . /// - public static Torque FromKilopoundForceFeet(double value) + public static Torque FromKilopoundForceFeet(QuantityValue value) { return new Torque(value, TorqueUnit.KilopoundForceFoot); } @@ -503,7 +501,7 @@ public static Torque FromKilopoundForceFeet(double value) /// /// Creates a from . /// - public static Torque FromKilopoundForceInches(double value) + public static Torque FromKilopoundForceInches(QuantityValue value) { return new Torque(value, TorqueUnit.KilopoundForceInch); } @@ -511,7 +509,7 @@ public static Torque FromKilopoundForceInches(double value) /// /// Creates a from . /// - public static Torque FromMeganewtonCentimeters(double value) + public static Torque FromMeganewtonCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.MeganewtonCentimeter); } @@ -519,7 +517,7 @@ public static Torque FromMeganewtonCentimeters(double value) /// /// Creates a from . /// - public static Torque FromMeganewtonMeters(double value) + public static Torque FromMeganewtonMeters(QuantityValue value) { return new Torque(value, TorqueUnit.MeganewtonMeter); } @@ -527,7 +525,7 @@ public static Torque FromMeganewtonMeters(double value) /// /// Creates a from . /// - public static Torque FromMeganewtonMillimeters(double value) + public static Torque FromMeganewtonMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.MeganewtonMillimeter); } @@ -535,7 +533,7 @@ public static Torque FromMeganewtonMillimeters(double value) /// /// Creates a from . /// - public static Torque FromMegapoundForceFeet(double value) + public static Torque FromMegapoundForceFeet(QuantityValue value) { return new Torque(value, TorqueUnit.MegapoundForceFoot); } @@ -543,7 +541,7 @@ public static Torque FromMegapoundForceFeet(double value) /// /// Creates a from . /// - public static Torque FromMegapoundForceInches(double value) + public static Torque FromMegapoundForceInches(QuantityValue value) { return new Torque(value, TorqueUnit.MegapoundForceInch); } @@ -551,7 +549,7 @@ public static Torque FromMegapoundForceInches(double value) /// /// Creates a from . /// - public static Torque FromNewtonCentimeters(double value) + public static Torque FromNewtonCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.NewtonCentimeter); } @@ -559,7 +557,7 @@ public static Torque FromNewtonCentimeters(double value) /// /// Creates a from . /// - public static Torque FromNewtonMeters(double value) + public static Torque FromNewtonMeters(QuantityValue value) { return new Torque(value, TorqueUnit.NewtonMeter); } @@ -567,7 +565,7 @@ public static Torque FromNewtonMeters(double value) /// /// Creates a from . /// - public static Torque FromNewtonMillimeters(double value) + public static Torque FromNewtonMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.NewtonMillimeter); } @@ -575,7 +573,7 @@ public static Torque FromNewtonMillimeters(double value) /// /// Creates a from . /// - public static Torque FromPoundalFeet(double value) + public static Torque FromPoundalFeet(QuantityValue value) { return new Torque(value, TorqueUnit.PoundalFoot); } @@ -583,7 +581,7 @@ public static Torque FromPoundalFeet(double value) /// /// Creates a from . /// - public static Torque FromPoundForceFeet(double value) + public static Torque FromPoundForceFeet(QuantityValue value) { return new Torque(value, TorqueUnit.PoundForceFoot); } @@ -591,7 +589,7 @@ public static Torque FromPoundForceFeet(double value) /// /// Creates a from . /// - public static Torque FromPoundForceInches(double value) + public static Torque FromPoundForceInches(QuantityValue value) { return new Torque(value, TorqueUnit.PoundForceInch); } @@ -599,7 +597,7 @@ public static Torque FromPoundForceInches(double value) /// /// Creates a from . /// - public static Torque FromTonneForceCentimeters(double value) + public static Torque FromTonneForceCentimeters(QuantityValue value) { return new Torque(value, TorqueUnit.TonneForceCentimeter); } @@ -607,7 +605,7 @@ public static Torque FromTonneForceCentimeters(double value) /// /// Creates a from . /// - public static Torque FromTonneForceMeters(double value) + public static Torque FromTonneForceMeters(QuantityValue value) { return new Torque(value, TorqueUnit.TonneForceMeter); } @@ -615,7 +613,7 @@ public static Torque FromTonneForceMeters(double value) /// /// Creates a from . /// - public static Torque FromTonneForceMillimeters(double value) + public static Torque FromTonneForceMillimeters(QuantityValue value) { return new Torque(value, TorqueUnit.TonneForceMillimeter); } @@ -626,7 +624,7 @@ public static Torque FromTonneForceMillimeters(double value) /// Value to convert from. /// Unit to convert from. /// Torque unit value. - public static Torque From(double value, TorqueUnit fromUnit) + public static Torque From(QuantityValue value, TorqueUnit fromUnit) { return new Torque(value, fromUnit); } @@ -798,25 +796,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static Torque operator *(double left, Torque right) + public static Torque operator *(QuantityValue left, Torque right) { return new Torque(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Torque operator *(Torque left, double right) + public static Torque operator *(Torque left, QuantityValue right) { return new Torque(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Torque operator /(Torque left, double right) + public static Torque operator /(Torque left, QuantityValue right) { return new Torque(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Torque left, Torque right) + public static QuantityValue operator /(Torque left, Torque right) { return left.NewtonMeters / right.NewtonMeters; } @@ -895,27 +893,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Torque left, Torque right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Torque other, Torque tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Torque left, Torque right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Torque otherQuantity)) @@ -925,15 +916,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Torque other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1016,10 +1004,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1036,7 +1024,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Torque other, Torque tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1049,7 +1037,12 @@ public bool Equals(Torque other, Torque tolerance) /// A hash code for the current Torque. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1060,7 +1053,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorqueUnit unit) + public QuantityValue As(TorqueUnit unit) { if (Unit == unit) return Value; @@ -1069,7 +1062,7 @@ public double As(TorqueUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1084,7 +1077,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); @@ -1150,56 +1143,56 @@ private bool TryToUnit(TorqueUnit unit, [NotNullWhen(true)] out Torque? converte Torque? convertedOrNull = (Unit, unit) switch { // TorqueUnit -> BaseUnit - (TorqueUnit.GramForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e-5, TorqueUnit.NewtonMeter), - (TorqueUnit.GramForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e-3, TorqueUnit.NewtonMeter), - (TorqueUnit.GramForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e-6, TorqueUnit.NewtonMeter), - (TorqueUnit.KilogramForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e-2, TorqueUnit.NewtonMeter), - (TorqueUnit.KilogramForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665, TorqueUnit.NewtonMeter), - (TorqueUnit.KilogramForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e-3, TorqueUnit.NewtonMeter), - (TorqueUnit.KilonewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque((_value * 0.01) * 1e3d, TorqueUnit.NewtonMeter), - (TorqueUnit.KilonewtonMeter, TorqueUnit.NewtonMeter) => new Torque((_value) * 1e3d, TorqueUnit.NewtonMeter), - (TorqueUnit.KilonewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque((_value * 0.001) * 1e3d, TorqueUnit.NewtonMeter), - (TorqueUnit.KilopoundForceFoot, TorqueUnit.NewtonMeter) => new Torque((_value * 1.3558179483314) * 1e3d, TorqueUnit.NewtonMeter), - (TorqueUnit.KilopoundForceInch, TorqueUnit.NewtonMeter) => new Torque((_value * 1.129848290276167e-1) * 1e3d, TorqueUnit.NewtonMeter), - (TorqueUnit.MeganewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque((_value * 0.01) * 1e6d, TorqueUnit.NewtonMeter), - (TorqueUnit.MeganewtonMeter, TorqueUnit.NewtonMeter) => new Torque((_value) * 1e6d, TorqueUnit.NewtonMeter), - (TorqueUnit.MeganewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque((_value * 0.001) * 1e6d, TorqueUnit.NewtonMeter), - (TorqueUnit.MegapoundForceFoot, TorqueUnit.NewtonMeter) => new Torque((_value * 1.3558179483314) * 1e6d, TorqueUnit.NewtonMeter), - (TorqueUnit.MegapoundForceInch, TorqueUnit.NewtonMeter) => new Torque((_value * 1.129848290276167e-1) * 1e6d, TorqueUnit.NewtonMeter), - (TorqueUnit.NewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 0.01, TorqueUnit.NewtonMeter), - (TorqueUnit.NewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 0.001, TorqueUnit.NewtonMeter), - (TorqueUnit.PoundalFoot, TorqueUnit.NewtonMeter) => new Torque(_value * 4.21401100938048e-2, TorqueUnit.NewtonMeter), - (TorqueUnit.PoundForceFoot, TorqueUnit.NewtonMeter) => new Torque(_value * 1.3558179483314, TorqueUnit.NewtonMeter), - (TorqueUnit.PoundForceInch, TorqueUnit.NewtonMeter) => new Torque(_value * 1.129848290276167e-1, TorqueUnit.NewtonMeter), - (TorqueUnit.TonneForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e1, TorqueUnit.NewtonMeter), - (TorqueUnit.TonneForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665e3, TorqueUnit.NewtonMeter), - (TorqueUnit.TonneForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 9.80665, TorqueUnit.NewtonMeter), + (TorqueUnit.GramForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 2000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.GramForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.GramForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.KilogramForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 2000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.KilogramForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.KilogramForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.KilonewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 10, TorqueUnit.NewtonMeter), + (TorqueUnit.KilonewtonMeter, TorqueUnit.NewtonMeter) => new Torque(_value * 1000, TorqueUnit.NewtonMeter), + (TorqueUnit.KilonewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value, TorqueUnit.NewtonMeter), + (TorqueUnit.KilopoundForceFoot, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(6779089741657, 5000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.KilopoundForceInch, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(1129848290276167, 10000000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.MeganewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 10000, TorqueUnit.NewtonMeter), + (TorqueUnit.MeganewtonMeter, TorqueUnit.NewtonMeter) => new Torque(_value * 1000000, TorqueUnit.NewtonMeter), + (TorqueUnit.MeganewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * 1000, TorqueUnit.NewtonMeter), + (TorqueUnit.MegapoundForceFoot, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(6779089741657, 5000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.MegapoundForceInch, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(1129848290276167, 10000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.NewtonCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value / 100, TorqueUnit.NewtonMeter), + (TorqueUnit.NewtonMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value / 1000, TorqueUnit.NewtonMeter), + (TorqueUnit.PoundalFoot, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(6584392202157, 156250000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.PoundForceFoot, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(6779089741657, 5000000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.PoundForceInch, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(1129848290276167, 10000000000000000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.TonneForceCentimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 2000, false), TorqueUnit.NewtonMeter), + (TorqueUnit.TonneForceMeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20, false), TorqueUnit.NewtonMeter), + (TorqueUnit.TonneForceMillimeter, TorqueUnit.NewtonMeter) => new Torque(_value * new QuantityValue(196133, 20000, false), TorqueUnit.NewtonMeter), // BaseUnit -> TorqueUnit - (TorqueUnit.NewtonMeter, TorqueUnit.GramForceCentimeter) => new Torque(_value / 9.80665e-5, TorqueUnit.GramForceCentimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.GramForceMeter) => new Torque(_value / 9.80665e-3, TorqueUnit.GramForceMeter), - (TorqueUnit.NewtonMeter, TorqueUnit.GramForceMillimeter) => new Torque(_value / 9.80665e-6, TorqueUnit.GramForceMillimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceCentimeter) => new Torque(_value / 9.80665e-2, TorqueUnit.KilogramForceCentimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceMeter) => new Torque(_value / 9.80665, TorqueUnit.KilogramForceMeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceMillimeter) => new Torque(_value / 9.80665e-3, TorqueUnit.KilogramForceMillimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonCentimeter) => new Torque((_value * 100) / 1e3d, TorqueUnit.KilonewtonCentimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonMeter) => new Torque((_value) / 1e3d, TorqueUnit.KilonewtonMeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonMillimeter) => new Torque((_value * 1000) / 1e3d, TorqueUnit.KilonewtonMillimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.KilopoundForceFoot) => new Torque((_value / 1.3558179483314) / 1e3d, TorqueUnit.KilopoundForceFoot), - (TorqueUnit.NewtonMeter, TorqueUnit.KilopoundForceInch) => new Torque((_value / 1.129848290276167e-1) / 1e3d, TorqueUnit.KilopoundForceInch), - (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonCentimeter) => new Torque((_value * 100) / 1e6d, TorqueUnit.MeganewtonCentimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonMeter) => new Torque((_value) / 1e6d, TorqueUnit.MeganewtonMeter), - (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonMillimeter) => new Torque((_value * 1000) / 1e6d, TorqueUnit.MeganewtonMillimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.MegapoundForceFoot) => new Torque((_value / 1.3558179483314) / 1e6d, TorqueUnit.MegapoundForceFoot), - (TorqueUnit.NewtonMeter, TorqueUnit.MegapoundForceInch) => new Torque((_value / 1.129848290276167e-1) / 1e6d, TorqueUnit.MegapoundForceInch), + (TorqueUnit.NewtonMeter, TorqueUnit.GramForceCentimeter) => new Torque(_value * new QuantityValue(2000000000, 196133, false), TorqueUnit.GramForceCentimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.GramForceMeter) => new Torque(_value * new QuantityValue(20000000, 196133, false), TorqueUnit.GramForceMeter), + (TorqueUnit.NewtonMeter, TorqueUnit.GramForceMillimeter) => new Torque(_value * new QuantityValue(20000000000, 196133, false), TorqueUnit.GramForceMillimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceCentimeter) => new Torque(_value * new QuantityValue(2000000, 196133, false), TorqueUnit.KilogramForceCentimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceMeter) => new Torque(_value * new QuantityValue(20000, 196133, false), TorqueUnit.KilogramForceMeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilogramForceMillimeter) => new Torque(_value * new QuantityValue(20000000, 196133, false), TorqueUnit.KilogramForceMillimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonCentimeter) => new Torque(_value / 10, TorqueUnit.KilonewtonCentimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonMeter) => new Torque(_value / 1000, TorqueUnit.KilonewtonMeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilonewtonMillimeter) => new Torque(_value, TorqueUnit.KilonewtonMillimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.KilopoundForceFoot) => new Torque(_value * new QuantityValue(5000000000, 6779089741657, false), TorqueUnit.KilopoundForceFoot), + (TorqueUnit.NewtonMeter, TorqueUnit.KilopoundForceInch) => new Torque(_value * new QuantityValue(10000000000000, 1129848290276167, false), TorqueUnit.KilopoundForceInch), + (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonCentimeter) => new Torque(_value / 10000, TorqueUnit.MeganewtonCentimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonMeter) => new Torque(_value / 1000000, TorqueUnit.MeganewtonMeter), + (TorqueUnit.NewtonMeter, TorqueUnit.MeganewtonMillimeter) => new Torque(_value / 1000, TorqueUnit.MeganewtonMillimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.MegapoundForceFoot) => new Torque(_value * new QuantityValue(5000000, 6779089741657, false), TorqueUnit.MegapoundForceFoot), + (TorqueUnit.NewtonMeter, TorqueUnit.MegapoundForceInch) => new Torque(_value * new QuantityValue(10000000000, 1129848290276167, false), TorqueUnit.MegapoundForceInch), (TorqueUnit.NewtonMeter, TorqueUnit.NewtonCentimeter) => new Torque(_value * 100, TorqueUnit.NewtonCentimeter), (TorqueUnit.NewtonMeter, TorqueUnit.NewtonMillimeter) => new Torque(_value * 1000, TorqueUnit.NewtonMillimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.PoundalFoot) => new Torque(_value / 4.21401100938048e-2, TorqueUnit.PoundalFoot), - (TorqueUnit.NewtonMeter, TorqueUnit.PoundForceFoot) => new Torque(_value / 1.3558179483314, TorqueUnit.PoundForceFoot), - (TorqueUnit.NewtonMeter, TorqueUnit.PoundForceInch) => new Torque(_value / 1.129848290276167e-1, TorqueUnit.PoundForceInch), - (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceCentimeter) => new Torque(_value / 9.80665e1, TorqueUnit.TonneForceCentimeter), - (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMeter) => new Torque(_value / 9.80665e3, TorqueUnit.TonneForceMeter), - (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMillimeter) => new Torque(_value / 9.80665, TorqueUnit.TonneForceMillimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.PoundalFoot) => new Torque(_value * new QuantityValue(156250000000000, 6584392202157, false), TorqueUnit.PoundalFoot), + (TorqueUnit.NewtonMeter, TorqueUnit.PoundForceFoot) => new Torque(_value * new QuantityValue(5000000000000, 6779089741657, false), TorqueUnit.PoundForceFoot), + (TorqueUnit.NewtonMeter, TorqueUnit.PoundForceInch) => new Torque(_value * new QuantityValue(10000000000000000, 1129848290276167, false), TorqueUnit.PoundForceInch), + (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceCentimeter) => new Torque(_value * new QuantityValue(2000, 196133, false), TorqueUnit.TonneForceCentimeter), + (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMeter) => new Torque(_value * new QuantityValue(20, 196133, false), TorqueUnit.TonneForceMeter), + (TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMillimeter) => new Torque(_value * new QuantityValue(20000, 196133, false), TorqueUnit.TonneForceMillimeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 42974f2c14..d455f40b57 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,7 +99,7 @@ static TorquePerLength() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public TorquePerLength(double value, TorquePerLengthUnit unit) + public TorquePerLength(QuantityValue value, TorquePerLengthUnit unit) { _value = value; _unit = unit; @@ -112,7 +113,7 @@ public TorquePerLength(double value, TorquePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TorquePerLength(double value, UnitSystem unitSystem) + public TorquePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -163,10 +164,10 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,107 +192,107 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + public QuantityValue KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); + public QuantityValue KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + public QuantityValue KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + public QuantityValue KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); + public QuantityValue KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + public QuantityValue KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); + public QuantityValue KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); /// /// Gets a value of this quantity converted into /// - public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); + public QuantityValue KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); /// /// Gets a value of this quantity converted into /// - public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + public QuantityValue MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); + public QuantityValue MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + public QuantityValue MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); + public QuantityValue MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); /// /// Gets a value of this quantity converted into /// - public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); + public QuantityValue MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); /// /// Gets a value of this quantity converted into /// - public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); + public QuantityValue NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); + public QuantityValue NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); + public QuantityValue NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); + public QuantityValue PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); /// /// Gets a value of this quantity converted into /// - public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); + public QuantityValue PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); /// /// Gets a value of this quantity converted into /// - public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); + public QuantityValue TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); + public QuantityValue TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); + public QuantityValue TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); #endregion @@ -379,7 +380,7 @@ public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? /// /// Creates a from . /// - public static TorquePerLength FromKilogramForceCentimetersPerMeter(double value) + public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); } @@ -387,7 +388,7 @@ public static TorquePerLength FromKilogramForceCentimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilogramForceMetersPerMeter(double value) + public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); } @@ -395,7 +396,7 @@ public static TorquePerLength FromKilogramForceMetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilogramForceMillimetersPerMeter(double value) + public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); } @@ -403,7 +404,7 @@ public static TorquePerLength FromKilogramForceMillimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilonewtonCentimetersPerMeter(double value) + public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); } @@ -411,7 +412,7 @@ public static TorquePerLength FromKilonewtonCentimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilonewtonMetersPerMeter(double value) + public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); } @@ -419,7 +420,7 @@ public static TorquePerLength FromKilonewtonMetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilonewtonMillimetersPerMeter(double value) + public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); } @@ -427,7 +428,7 @@ public static TorquePerLength FromKilonewtonMillimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilopoundForceFeetPerFoot(double value) + public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); } @@ -435,7 +436,7 @@ public static TorquePerLength FromKilopoundForceFeetPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromKilopoundForceInchesPerFoot(double value) + public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); } @@ -443,7 +444,7 @@ public static TorquePerLength FromKilopoundForceInchesPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromMeganewtonCentimetersPerMeter(double value) + public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); } @@ -451,7 +452,7 @@ public static TorquePerLength FromMeganewtonCentimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromMeganewtonMetersPerMeter(double value) + public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); } @@ -459,7 +460,7 @@ public static TorquePerLength FromMeganewtonMetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromMeganewtonMillimetersPerMeter(double value) + public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); } @@ -467,7 +468,7 @@ public static TorquePerLength FromMeganewtonMillimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromMegapoundForceFeetPerFoot(double value) + public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); } @@ -475,7 +476,7 @@ public static TorquePerLength FromMegapoundForceFeetPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromMegapoundForceInchesPerFoot(double value) + public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); } @@ -483,7 +484,7 @@ public static TorquePerLength FromMegapoundForceInchesPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromNewtonCentimetersPerMeter(double value) + public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); } @@ -491,7 +492,7 @@ public static TorquePerLength FromNewtonCentimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromNewtonMetersPerMeter(double value) + public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); } @@ -499,7 +500,7 @@ public static TorquePerLength FromNewtonMetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromNewtonMillimetersPerMeter(double value) + public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); } @@ -507,7 +508,7 @@ public static TorquePerLength FromNewtonMillimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromPoundForceFeetPerFoot(double value) + public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); } @@ -515,7 +516,7 @@ public static TorquePerLength FromPoundForceFeetPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromPoundForceInchesPerFoot(double value) + public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); } @@ -523,7 +524,7 @@ public static TorquePerLength FromPoundForceInchesPerFoot(double value) /// /// Creates a from . /// - public static TorquePerLength FromTonneForceCentimetersPerMeter(double value) + public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); } @@ -531,7 +532,7 @@ public static TorquePerLength FromTonneForceCentimetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromTonneForceMetersPerMeter(double value) + public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); } @@ -539,7 +540,7 @@ public static TorquePerLength FromTonneForceMetersPerMeter(double value) /// /// Creates a from . /// - public static TorquePerLength FromTonneForceMillimetersPerMeter(double value) + public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue value) { return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); } @@ -550,7 +551,7 @@ public static TorquePerLength FromTonneForceMillimetersPerMeter(double value) /// Value to convert from. /// Unit to convert from. /// TorquePerLength unit value. - public static TorquePerLength From(double value, TorquePerLengthUnit fromUnit) + public static TorquePerLength From(QuantityValue value, TorquePerLengthUnit fromUnit) { return new TorquePerLength(value, fromUnit); } @@ -722,25 +723,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static TorquePerLength operator *(double left, TorquePerLength right) + public static TorquePerLength operator *(QuantityValue left, TorquePerLength right) { return new TorquePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TorquePerLength operator *(TorquePerLength left, double right) + public static TorquePerLength operator *(TorquePerLength left, QuantityValue right) { return new TorquePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TorquePerLength operator /(TorquePerLength left, double right) + public static TorquePerLength operator /(TorquePerLength left, QuantityValue right) { return new TorquePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TorquePerLength left, TorquePerLength right) + public static QuantityValue operator /(TorquePerLength left, TorquePerLength right) { return left.NewtonMetersPerMeter / right.NewtonMetersPerMeter; } @@ -773,27 +774,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(TorquePerLength left, TorquePerLength right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(TorquePerLength left, TorquePerLength right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is TorquePerLength otherQuantity)) @@ -803,15 +797,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("Use Equals(TorquePerLength other, TorquePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public bool Equals(TorquePerLength other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -894,10 +885,10 @@ public bool Equals(TorquePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -914,7 +905,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(TorquePerLength other, TorquePerLength tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -927,7 +918,12 @@ public bool Equals(TorquePerLength other, TorquePerLength tolerance) /// A hash code for the current TorquePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -938,7 +934,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorquePerLengthUnit unit) + public QuantityValue As(TorquePerLengthUnit unit) { if (Unit == unit) return Value; @@ -947,7 +943,7 @@ public double As(TorquePerLengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -962,7 +958,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); @@ -1028,48 +1024,48 @@ private bool TryToUnit(TorquePerLengthUnit unit, [NotNullWhen(true)] out TorqueP TorquePerLength? convertedOrNull = (Unit, unit) switch { // TorquePerLengthUnit -> BaseUnit - (TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.0980665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9.80665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.00980665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.01) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.001) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 4.44822161526) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.370685147638) * 1e3d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.01) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.001) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 4.44822161526) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength((_value * 0.370685147638) * 1e6d, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.01, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.001, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 4.44822161526, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 0.370685147638, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 98.0665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9806.65019960653, TorquePerLengthUnit.NewtonMeterPerMeter), - (TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 9.80665019960652, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(245166254990163, 2500000000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(245166254990163, 25000000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(245166254990163, 25000000000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 10, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 1000, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(222411080763, 50000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(185342573819, 500000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 10000, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 1000000, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * 1000, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(222411080763, 50000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(185342573819, 500000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value / 100, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value / 1000, TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(222411080763, 50000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(185342573819, 500000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(245166254990163, 2500000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(980665019960653, 100000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), + (TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(245166254990163, 25000000000000, false), TorquePerLengthUnit.NewtonMeterPerMeter), // BaseUnit -> TorquePerLengthUnit - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceCentimeterPerMeter) => new TorquePerLength(_value * 10.1971619222242, TorquePerLengthUnit.KilogramForceCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMeterPerMeter) => new TorquePerLength(_value * 0.101971619222242, TorquePerLengthUnit.KilogramForceMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMillimeterPerMeter) => new TorquePerLength(_value * 101.971619222242, TorquePerLengthUnit.KilogramForceMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonCentimeterPerMeter) => new TorquePerLength((_value * 100) / 1e3d, TorquePerLengthUnit.KilonewtonCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMeterPerMeter) => new TorquePerLength((_value) / 1e3d, TorquePerLengthUnit.KilonewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMillimeterPerMeter) => new TorquePerLength((_value * 1000) / 1e3d, TorquePerLengthUnit.KilonewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceFootPerFoot) => new TorquePerLength((_value / 4.44822161526) / 1e3d, TorquePerLengthUnit.KilopoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceInchPerFoot) => new TorquePerLength((_value / 0.370685147638) / 1e3d, TorquePerLengthUnit.KilopoundForceInchPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonCentimeterPerMeter) => new TorquePerLength((_value * 100) / 1e6d, TorquePerLengthUnit.MeganewtonCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMeterPerMeter) => new TorquePerLength((_value) / 1e6d, TorquePerLengthUnit.MeganewtonMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMillimeterPerMeter) => new TorquePerLength((_value * 1000) / 1e6d, TorquePerLengthUnit.MeganewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceFootPerFoot) => new TorquePerLength((_value / 4.44822161526) / 1e6d, TorquePerLengthUnit.MegapoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceInchPerFoot) => new TorquePerLength((_value / 0.370685147638) / 1e6d, TorquePerLengthUnit.MegapoundForceInchPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceCentimeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 5000000000000, false), TorquePerLengthUnit.KilogramForceCentimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 500000000000000, false), TorquePerLengthUnit.KilogramForceMeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilogramForceMillimeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 500000000000, false), TorquePerLengthUnit.KilogramForceMillimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonCentimeterPerMeter) => new TorquePerLength(_value / 10, TorquePerLengthUnit.KilonewtonCentimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMeterPerMeter) => new TorquePerLength(_value / 1000, TorquePerLengthUnit.KilonewtonMeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilonewtonMillimeterPerMeter) => new TorquePerLength(_value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceFootPerFoot) => new TorquePerLength(_value * new QuantityValue(50000000, 222411080763, false), TorquePerLengthUnit.KilopoundForceFootPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.KilopoundForceInchPerFoot) => new TorquePerLength(_value * new QuantityValue(500000000, 185342573819, false), TorquePerLengthUnit.KilopoundForceInchPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonCentimeterPerMeter) => new TorquePerLength(_value / 10000, TorquePerLengthUnit.MeganewtonCentimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMeterPerMeter) => new TorquePerLength(_value / 1000000, TorquePerLengthUnit.MeganewtonMeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MeganewtonMillimeterPerMeter) => new TorquePerLength(_value / 1000, TorquePerLengthUnit.MeganewtonMillimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceFootPerFoot) => new TorquePerLength(_value * new QuantityValue(50000, 222411080763, false), TorquePerLengthUnit.MegapoundForceFootPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.MegapoundForceInchPerFoot) => new TorquePerLength(_value * new QuantityValue(500000, 185342573819, false), TorquePerLengthUnit.MegapoundForceInchPerFoot), (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonCentimeterPerMeter) => new TorquePerLength(_value * 100, TorquePerLengthUnit.NewtonCentimeterPerMeter), (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonMillimeterPerMeter) => new TorquePerLength(_value * 1000, TorquePerLengthUnit.NewtonMillimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceFootPerFoot) => new TorquePerLength(_value / 4.44822161526, TorquePerLengthUnit.PoundForceFootPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceInchPerFoot) => new TorquePerLength(_value / 0.370685147638, TorquePerLengthUnit.PoundForceInchPerFoot), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter) => new TorquePerLength(_value * 0.0101971619222242, TorquePerLengthUnit.TonneForceCentimeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMeterPerMeter) => new TorquePerLength(_value * 0.000101971619222242, TorquePerLengthUnit.TonneForceMeterPerMeter), - (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter) => new TorquePerLength(_value * 0.101971619222242, TorquePerLengthUnit.TonneForceMillimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceFootPerFoot) => new TorquePerLength(_value * new QuantityValue(50000000000, 222411080763, false), TorquePerLengthUnit.PoundForceFootPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.PoundForceInchPerFoot) => new TorquePerLength(_value * new QuantityValue(500000000000, 185342573819, false), TorquePerLengthUnit.PoundForceInchPerFoot), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 5000000000000000, false), TorquePerLengthUnit.TonneForceCentimeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 500000000000000000, false), TorquePerLengthUnit.TonneForceMeterPerMeter), + (TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter) => new TorquePerLength(_value * new QuantityValue(50985809611121, 500000000000000, false), TorquePerLengthUnit.TonneForceMillimeterPerMeter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index dd23cd051f..c36a53bc34 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,7 +82,7 @@ static Turbidity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Turbidity(double value, TurbidityUnit unit) + public Turbidity(QuantityValue value, TurbidityUnit unit) { _value = value; _unit = unit; @@ -95,7 +96,7 @@ public Turbidity(double value, TurbidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Turbidity(double value, UnitSystem unitSystem) + public Turbidity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -146,10 +147,10 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,7 +175,7 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double NTU => As(TurbidityUnit.NTU); + public QuantityValue NTU => As(TurbidityUnit.NTU); #endregion @@ -222,7 +223,7 @@ public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provid /// /// Creates a from . /// - public static Turbidity FromNTU(double value) + public static Turbidity FromNTU(QuantityValue value) { return new Turbidity(value, TurbidityUnit.NTU); } @@ -233,7 +234,7 @@ public static Turbidity FromNTU(double value) /// Value to convert from. /// Unit to convert from. /// Turbidity unit value. - public static Turbidity From(double value, TurbidityUnit fromUnit) + public static Turbidity From(QuantityValue value, TurbidityUnit fromUnit) { return new Turbidity(value, fromUnit); } @@ -405,25 +406,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi } /// Get from multiplying value and . - public static Turbidity operator *(double left, Turbidity right) + public static Turbidity operator *(QuantityValue left, Turbidity right) { return new Turbidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Turbidity operator *(Turbidity left, double right) + public static Turbidity operator *(Turbidity left, QuantityValue right) { return new Turbidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Turbidity operator /(Turbidity left, double right) + public static Turbidity operator /(Turbidity left, QuantityValue right) { return new Turbidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Turbidity left, Turbidity right) + public static QuantityValue operator /(Turbidity left, Turbidity right) { return left.NTU / right.NTU; } @@ -456,27 +457,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Turbidity left, Turbidity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Turbidity other, Turbidity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Turbidity left, Turbidity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Turbidity otherQuantity)) @@ -486,15 +480,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Turbidity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -577,10 +568,10 @@ public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -597,7 +588,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Turbidity other, Turbidity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -610,7 +601,12 @@ public bool Equals(Turbidity other, Turbidity tolerance) /// A hash code for the current Turbidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -621,7 +617,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TurbidityUnit unit) + public QuantityValue As(TurbidityUnit unit) { if (Unit == unit) return Value; @@ -630,7 +626,7 @@ public double As(TurbidityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -645,7 +641,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 448d5bbca7..5083b198e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,7 +79,7 @@ static VitaminA() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VitaminA(double value, VitaminAUnit unit) + public VitaminA(QuantityValue value, VitaminAUnit unit) { _value = value; _unit = unit; @@ -92,7 +93,7 @@ public VitaminA(double value, VitaminAUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VitaminA(double value, UnitSystem unitSystem) + public VitaminA(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -143,10 +144,10 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,7 +172,7 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double InternationalUnits => As(VitaminAUnit.InternationalUnit); + public QuantityValue InternationalUnits => As(VitaminAUnit.InternationalUnit); #endregion @@ -219,7 +220,7 @@ public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provide /// /// Creates a from . /// - public static VitaminA FromInternationalUnits(double value) + public static VitaminA FromInternationalUnits(QuantityValue value) { return new VitaminA(value, VitaminAUnit.InternationalUnit); } @@ -230,7 +231,7 @@ public static VitaminA FromInternationalUnits(double value) /// Value to convert from. /// Unit to convert from. /// VitaminA unit value. - public static VitaminA From(double value, VitaminAUnit fromUnit) + public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit) { return new VitaminA(value, fromUnit); } @@ -402,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam } /// Get from multiplying value and . - public static VitaminA operator *(double left, VitaminA right) + public static VitaminA operator *(QuantityValue left, VitaminA right) { return new VitaminA(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VitaminA operator *(VitaminA left, double right) + public static VitaminA operator *(VitaminA left, QuantityValue right) { return new VitaminA(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VitaminA operator /(VitaminA left, double right) + public static VitaminA operator /(VitaminA left, QuantityValue right) { return new VitaminA(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VitaminA left, VitaminA right) + public static QuantityValue operator /(VitaminA left, VitaminA right) { return left.InternationalUnits / right.InternationalUnits; } @@ -453,27 +454,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VitaminA left, VitaminA right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VitaminA other, VitaminA tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VitaminA left, VitaminA right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VitaminA otherQuantity)) @@ -483,15 +477,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VitaminA other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +565,10 @@ public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -594,7 +585,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VitaminA other, VitaminA tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -607,7 +598,12 @@ public bool Equals(VitaminA other, VitaminA tolerance) /// A hash code for the current VitaminA. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -618,7 +614,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VitaminAUnit unit) + public QuantityValue As(VitaminAUnit unit) { if (Unit == unit) return Value; @@ -627,7 +623,7 @@ public double As(VitaminAUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -642,7 +638,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 880acbe456..62796ead7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -43,10 +41,12 @@ namespace UnitsNet IArithmeticQuantity, #if NET7_0_OR_GREATER IMultiplyOperators, + IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IDivisionOperators, IMultiplyOperators, + IMultiplyOperators, IDivisionOperators, IMultiplyOperators, IMultiplyOperators, @@ -64,7 +64,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -147,7 +147,7 @@ static Volume() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public Volume(double value, VolumeUnit unit) + public Volume(QuantityValue value, VolumeUnit unit) { _value = value; _unit = unit; @@ -161,7 +161,7 @@ public Volume(double value, VolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Volume(double value, UnitSystem unitSystem) + public Volume(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -212,10 +212,10 @@ public Volume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -240,272 +240,272 @@ public Volume(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AcreFeet => As(VolumeUnit.AcreFoot); + public QuantityValue AcreFeet => As(VolumeUnit.AcreFoot); /// /// Gets a value of this quantity converted into /// - public double AuTablespoons => As(VolumeUnit.AuTablespoon); + public QuantityValue AuTablespoons => As(VolumeUnit.AuTablespoon); /// /// Gets a value of this quantity converted into /// - public double BoardFeet => As(VolumeUnit.BoardFoot); + public QuantityValue BoardFeet => As(VolumeUnit.BoardFoot); /// /// Gets a value of this quantity converted into /// - public double Centiliters => As(VolumeUnit.Centiliter); + public QuantityValue Centiliters => As(VolumeUnit.Centiliter); /// /// Gets a value of this quantity converted into /// - public double CubicCentimeters => As(VolumeUnit.CubicCentimeter); + public QuantityValue CubicCentimeters => As(VolumeUnit.CubicCentimeter); /// /// Gets a value of this quantity converted into /// - public double CubicDecimeters => As(VolumeUnit.CubicDecimeter); + public QuantityValue CubicDecimeters => As(VolumeUnit.CubicDecimeter); /// /// Gets a value of this quantity converted into /// - public double CubicFeet => As(VolumeUnit.CubicFoot); + public QuantityValue CubicFeet => As(VolumeUnit.CubicFoot); /// /// Gets a value of this quantity converted into /// - public double CubicHectometers => As(VolumeUnit.CubicHectometer); + public QuantityValue CubicHectometers => As(VolumeUnit.CubicHectometer); /// /// Gets a value of this quantity converted into /// - public double CubicInches => As(VolumeUnit.CubicInch); + public QuantityValue CubicInches => As(VolumeUnit.CubicInch); /// /// Gets a value of this quantity converted into /// - public double CubicKilometers => As(VolumeUnit.CubicKilometer); + public QuantityValue CubicKilometers => As(VolumeUnit.CubicKilometer); /// /// Gets a value of this quantity converted into /// - public double CubicMeters => As(VolumeUnit.CubicMeter); + public QuantityValue CubicMeters => As(VolumeUnit.CubicMeter); /// /// Gets a value of this quantity converted into /// - public double CubicMicrometers => As(VolumeUnit.CubicMicrometer); + public QuantityValue CubicMicrometers => As(VolumeUnit.CubicMicrometer); /// /// Gets a value of this quantity converted into /// - public double CubicMiles => As(VolumeUnit.CubicMile); + public QuantityValue CubicMiles => As(VolumeUnit.CubicMile); /// /// Gets a value of this quantity converted into /// - public double CubicMillimeters => As(VolumeUnit.CubicMillimeter); + public QuantityValue CubicMillimeters => As(VolumeUnit.CubicMillimeter); /// /// Gets a value of this quantity converted into /// - public double CubicYards => As(VolumeUnit.CubicYard); + public QuantityValue CubicYards => As(VolumeUnit.CubicYard); /// /// Gets a value of this quantity converted into /// - public double Decaliters => As(VolumeUnit.Decaliter); + public QuantityValue Decaliters => As(VolumeUnit.Decaliter); /// /// Gets a value of this quantity converted into /// - public double DecausGallons => As(VolumeUnit.DecausGallon); + public QuantityValue DecausGallons => As(VolumeUnit.DecausGallon); /// /// Gets a value of this quantity converted into /// - public double Deciliters => As(VolumeUnit.Deciliter); + public QuantityValue Deciliters => As(VolumeUnit.Deciliter); /// /// Gets a value of this quantity converted into /// - public double DeciusGallons => As(VolumeUnit.DeciusGallon); + public QuantityValue DeciusGallons => As(VolumeUnit.DeciusGallon); /// /// Gets a value of this quantity converted into /// - public double HectocubicFeet => As(VolumeUnit.HectocubicFoot); + public QuantityValue HectocubicFeet => As(VolumeUnit.HectocubicFoot); /// /// Gets a value of this quantity converted into /// - public double HectocubicMeters => As(VolumeUnit.HectocubicMeter); + public QuantityValue HectocubicMeters => As(VolumeUnit.HectocubicMeter); /// /// Gets a value of this quantity converted into /// - public double Hectoliters => As(VolumeUnit.Hectoliter); + public QuantityValue Hectoliters => As(VolumeUnit.Hectoliter); /// /// Gets a value of this quantity converted into /// - public double HectousGallons => As(VolumeUnit.HectousGallon); + public QuantityValue HectousGallons => As(VolumeUnit.HectousGallon); /// /// Gets a value of this quantity converted into /// - public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); + public QuantityValue ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); /// /// Gets a value of this quantity converted into /// - public double ImperialGallons => As(VolumeUnit.ImperialGallon); + public QuantityValue ImperialGallons => As(VolumeUnit.ImperialGallon); /// /// Gets a value of this quantity converted into /// - public double ImperialOunces => As(VolumeUnit.ImperialOunce); + public QuantityValue ImperialOunces => As(VolumeUnit.ImperialOunce); /// /// Gets a value of this quantity converted into /// - public double ImperialPints => As(VolumeUnit.ImperialPint); + public QuantityValue ImperialPints => As(VolumeUnit.ImperialPint); /// /// Gets a value of this quantity converted into /// - public double ImperialQuarts => As(VolumeUnit.ImperialQuart); + public QuantityValue ImperialQuarts => As(VolumeUnit.ImperialQuart); /// /// Gets a value of this quantity converted into /// - public double KilocubicFeet => As(VolumeUnit.KilocubicFoot); + public QuantityValue KilocubicFeet => As(VolumeUnit.KilocubicFoot); /// /// Gets a value of this quantity converted into /// - public double KilocubicMeters => As(VolumeUnit.KilocubicMeter); + public QuantityValue KilocubicMeters => As(VolumeUnit.KilocubicMeter); /// /// Gets a value of this quantity converted into /// - public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); + public QuantityValue KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); /// /// Gets a value of this quantity converted into /// - public double Kiloliters => As(VolumeUnit.Kiloliter); + public QuantityValue Kiloliters => As(VolumeUnit.Kiloliter); /// /// Gets a value of this quantity converted into /// - public double KilousGallons => As(VolumeUnit.KilousGallon); + public QuantityValue KilousGallons => As(VolumeUnit.KilousGallon); /// /// Gets a value of this quantity converted into /// - public double Liters => As(VolumeUnit.Liter); + public QuantityValue Liters => As(VolumeUnit.Liter); /// /// Gets a value of this quantity converted into /// - public double MegacubicFeet => As(VolumeUnit.MegacubicFoot); + public QuantityValue MegacubicFeet => As(VolumeUnit.MegacubicFoot); /// /// Gets a value of this quantity converted into /// - public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); + public QuantityValue MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); /// /// Gets a value of this quantity converted into /// - public double Megaliters => As(VolumeUnit.Megaliter); + public QuantityValue Megaliters => As(VolumeUnit.Megaliter); /// /// Gets a value of this quantity converted into /// - public double MegausGallons => As(VolumeUnit.MegausGallon); + public QuantityValue MegausGallons => As(VolumeUnit.MegausGallon); /// /// Gets a value of this quantity converted into /// - public double MetricCups => As(VolumeUnit.MetricCup); + public QuantityValue MetricCups => As(VolumeUnit.MetricCup); /// /// Gets a value of this quantity converted into /// - public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); + public QuantityValue MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); /// /// Gets a value of this quantity converted into /// - public double Microliters => As(VolumeUnit.Microliter); + public QuantityValue Microliters => As(VolumeUnit.Microliter); /// /// Gets a value of this quantity converted into /// - public double Milliliters => As(VolumeUnit.Milliliter); + public QuantityValue Milliliters => As(VolumeUnit.Milliliter); /// /// Gets a value of this quantity converted into /// - public double Nanoliters => As(VolumeUnit.Nanoliter); + public QuantityValue Nanoliters => As(VolumeUnit.Nanoliter); /// /// Gets a value of this quantity converted into /// - public double OilBarrels => As(VolumeUnit.OilBarrel); + public QuantityValue OilBarrels => As(VolumeUnit.OilBarrel); /// /// Gets a value of this quantity converted into /// - public double UkTablespoons => As(VolumeUnit.UkTablespoon); + public QuantityValue UkTablespoons => As(VolumeUnit.UkTablespoon); /// /// Gets a value of this quantity converted into /// - public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); + public QuantityValue UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); /// /// Gets a value of this quantity converted into /// - public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); + public QuantityValue UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); /// /// Gets a value of this quantity converted into /// - public double UsGallons => As(VolumeUnit.UsGallon); + public QuantityValue UsGallons => As(VolumeUnit.UsGallon); /// /// Gets a value of this quantity converted into /// - public double UsLegalCups => As(VolumeUnit.UsLegalCup); + public QuantityValue UsLegalCups => As(VolumeUnit.UsLegalCup); /// /// Gets a value of this quantity converted into /// - public double UsOunces => As(VolumeUnit.UsOunce); + public QuantityValue UsOunces => As(VolumeUnit.UsOunce); /// /// Gets a value of this quantity converted into /// - public double UsPints => As(VolumeUnit.UsPint); + public QuantityValue UsPints => As(VolumeUnit.UsPint); /// /// Gets a value of this quantity converted into /// - public double UsQuarts => As(VolumeUnit.UsQuart); + public QuantityValue UsQuarts => As(VolumeUnit.UsQuart); /// /// Gets a value of this quantity converted into /// - public double UsTablespoons => As(VolumeUnit.UsTablespoon); + public QuantityValue UsTablespoons => As(VolumeUnit.UsTablespoon); /// /// Gets a value of this quantity converted into /// - public double UsTeaspoons => As(VolumeUnit.UsTeaspoon); + public QuantityValue UsTeaspoons => As(VolumeUnit.UsTeaspoon); #endregion @@ -659,7 +659,7 @@ public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) /// /// Creates a from . /// - public static Volume FromAcreFeet(double value) + public static Volume FromAcreFeet(QuantityValue value) { return new Volume(value, VolumeUnit.AcreFoot); } @@ -667,7 +667,7 @@ public static Volume FromAcreFeet(double value) /// /// Creates a from . /// - public static Volume FromAuTablespoons(double value) + public static Volume FromAuTablespoons(QuantityValue value) { return new Volume(value, VolumeUnit.AuTablespoon); } @@ -675,7 +675,7 @@ public static Volume FromAuTablespoons(double value) /// /// Creates a from . /// - public static Volume FromBoardFeet(double value) + public static Volume FromBoardFeet(QuantityValue value) { return new Volume(value, VolumeUnit.BoardFoot); } @@ -683,7 +683,7 @@ public static Volume FromBoardFeet(double value) /// /// Creates a from . /// - public static Volume FromCentiliters(double value) + public static Volume FromCentiliters(QuantityValue value) { return new Volume(value, VolumeUnit.Centiliter); } @@ -691,7 +691,7 @@ public static Volume FromCentiliters(double value) /// /// Creates a from . /// - public static Volume FromCubicCentimeters(double value) + public static Volume FromCubicCentimeters(QuantityValue value) { return new Volume(value, VolumeUnit.CubicCentimeter); } @@ -699,7 +699,7 @@ public static Volume FromCubicCentimeters(double value) /// /// Creates a from . /// - public static Volume FromCubicDecimeters(double value) + public static Volume FromCubicDecimeters(QuantityValue value) { return new Volume(value, VolumeUnit.CubicDecimeter); } @@ -707,7 +707,7 @@ public static Volume FromCubicDecimeters(double value) /// /// Creates a from . /// - public static Volume FromCubicFeet(double value) + public static Volume FromCubicFeet(QuantityValue value) { return new Volume(value, VolumeUnit.CubicFoot); } @@ -715,7 +715,7 @@ public static Volume FromCubicFeet(double value) /// /// Creates a from . /// - public static Volume FromCubicHectometers(double value) + public static Volume FromCubicHectometers(QuantityValue value) { return new Volume(value, VolumeUnit.CubicHectometer); } @@ -723,7 +723,7 @@ public static Volume FromCubicHectometers(double value) /// /// Creates a from . /// - public static Volume FromCubicInches(double value) + public static Volume FromCubicInches(QuantityValue value) { return new Volume(value, VolumeUnit.CubicInch); } @@ -731,7 +731,7 @@ public static Volume FromCubicInches(double value) /// /// Creates a from . /// - public static Volume FromCubicKilometers(double value) + public static Volume FromCubicKilometers(QuantityValue value) { return new Volume(value, VolumeUnit.CubicKilometer); } @@ -739,7 +739,7 @@ public static Volume FromCubicKilometers(double value) /// /// Creates a from . /// - public static Volume FromCubicMeters(double value) + public static Volume FromCubicMeters(QuantityValue value) { return new Volume(value, VolumeUnit.CubicMeter); } @@ -747,7 +747,7 @@ public static Volume FromCubicMeters(double value) /// /// Creates a from . /// - public static Volume FromCubicMicrometers(double value) + public static Volume FromCubicMicrometers(QuantityValue value) { return new Volume(value, VolumeUnit.CubicMicrometer); } @@ -755,7 +755,7 @@ public static Volume FromCubicMicrometers(double value) /// /// Creates a from . /// - public static Volume FromCubicMiles(double value) + public static Volume FromCubicMiles(QuantityValue value) { return new Volume(value, VolumeUnit.CubicMile); } @@ -763,7 +763,7 @@ public static Volume FromCubicMiles(double value) /// /// Creates a from . /// - public static Volume FromCubicMillimeters(double value) + public static Volume FromCubicMillimeters(QuantityValue value) { return new Volume(value, VolumeUnit.CubicMillimeter); } @@ -771,7 +771,7 @@ public static Volume FromCubicMillimeters(double value) /// /// Creates a from . /// - public static Volume FromCubicYards(double value) + public static Volume FromCubicYards(QuantityValue value) { return new Volume(value, VolumeUnit.CubicYard); } @@ -779,7 +779,7 @@ public static Volume FromCubicYards(double value) /// /// Creates a from . /// - public static Volume FromDecaliters(double value) + public static Volume FromDecaliters(QuantityValue value) { return new Volume(value, VolumeUnit.Decaliter); } @@ -787,7 +787,7 @@ public static Volume FromDecaliters(double value) /// /// Creates a from . /// - public static Volume FromDecausGallons(double value) + public static Volume FromDecausGallons(QuantityValue value) { return new Volume(value, VolumeUnit.DecausGallon); } @@ -795,7 +795,7 @@ public static Volume FromDecausGallons(double value) /// /// Creates a from . /// - public static Volume FromDeciliters(double value) + public static Volume FromDeciliters(QuantityValue value) { return new Volume(value, VolumeUnit.Deciliter); } @@ -803,7 +803,7 @@ public static Volume FromDeciliters(double value) /// /// Creates a from . /// - public static Volume FromDeciusGallons(double value) + public static Volume FromDeciusGallons(QuantityValue value) { return new Volume(value, VolumeUnit.DeciusGallon); } @@ -811,7 +811,7 @@ public static Volume FromDeciusGallons(double value) /// /// Creates a from . /// - public static Volume FromHectocubicFeet(double value) + public static Volume FromHectocubicFeet(QuantityValue value) { return new Volume(value, VolumeUnit.HectocubicFoot); } @@ -819,7 +819,7 @@ public static Volume FromHectocubicFeet(double value) /// /// Creates a from . /// - public static Volume FromHectocubicMeters(double value) + public static Volume FromHectocubicMeters(QuantityValue value) { return new Volume(value, VolumeUnit.HectocubicMeter); } @@ -827,7 +827,7 @@ public static Volume FromHectocubicMeters(double value) /// /// Creates a from . /// - public static Volume FromHectoliters(double value) + public static Volume FromHectoliters(QuantityValue value) { return new Volume(value, VolumeUnit.Hectoliter); } @@ -835,7 +835,7 @@ public static Volume FromHectoliters(double value) /// /// Creates a from . /// - public static Volume FromHectousGallons(double value) + public static Volume FromHectousGallons(QuantityValue value) { return new Volume(value, VolumeUnit.HectousGallon); } @@ -843,7 +843,7 @@ public static Volume FromHectousGallons(double value) /// /// Creates a from . /// - public static Volume FromImperialBeerBarrels(double value) + public static Volume FromImperialBeerBarrels(QuantityValue value) { return new Volume(value, VolumeUnit.ImperialBeerBarrel); } @@ -851,7 +851,7 @@ public static Volume FromImperialBeerBarrels(double value) /// /// Creates a from . /// - public static Volume FromImperialGallons(double value) + public static Volume FromImperialGallons(QuantityValue value) { return new Volume(value, VolumeUnit.ImperialGallon); } @@ -859,7 +859,7 @@ public static Volume FromImperialGallons(double value) /// /// Creates a from . /// - public static Volume FromImperialOunces(double value) + public static Volume FromImperialOunces(QuantityValue value) { return new Volume(value, VolumeUnit.ImperialOunce); } @@ -867,7 +867,7 @@ public static Volume FromImperialOunces(double value) /// /// Creates a from . /// - public static Volume FromImperialPints(double value) + public static Volume FromImperialPints(QuantityValue value) { return new Volume(value, VolumeUnit.ImperialPint); } @@ -875,7 +875,7 @@ public static Volume FromImperialPints(double value) /// /// Creates a from . /// - public static Volume FromImperialQuarts(double value) + public static Volume FromImperialQuarts(QuantityValue value) { return new Volume(value, VolumeUnit.ImperialQuart); } @@ -883,7 +883,7 @@ public static Volume FromImperialQuarts(double value) /// /// Creates a from . /// - public static Volume FromKilocubicFeet(double value) + public static Volume FromKilocubicFeet(QuantityValue value) { return new Volume(value, VolumeUnit.KilocubicFoot); } @@ -891,7 +891,7 @@ public static Volume FromKilocubicFeet(double value) /// /// Creates a from . /// - public static Volume FromKilocubicMeters(double value) + public static Volume FromKilocubicMeters(QuantityValue value) { return new Volume(value, VolumeUnit.KilocubicMeter); } @@ -899,7 +899,7 @@ public static Volume FromKilocubicMeters(double value) /// /// Creates a from . /// - public static Volume FromKiloimperialGallons(double value) + public static Volume FromKiloimperialGallons(QuantityValue value) { return new Volume(value, VolumeUnit.KiloimperialGallon); } @@ -907,7 +907,7 @@ public static Volume FromKiloimperialGallons(double value) /// /// Creates a from . /// - public static Volume FromKiloliters(double value) + public static Volume FromKiloliters(QuantityValue value) { return new Volume(value, VolumeUnit.Kiloliter); } @@ -915,7 +915,7 @@ public static Volume FromKiloliters(double value) /// /// Creates a from . /// - public static Volume FromKilousGallons(double value) + public static Volume FromKilousGallons(QuantityValue value) { return new Volume(value, VolumeUnit.KilousGallon); } @@ -923,7 +923,7 @@ public static Volume FromKilousGallons(double value) /// /// Creates a from . /// - public static Volume FromLiters(double value) + public static Volume FromLiters(QuantityValue value) { return new Volume(value, VolumeUnit.Liter); } @@ -931,7 +931,7 @@ public static Volume FromLiters(double value) /// /// Creates a from . /// - public static Volume FromMegacubicFeet(double value) + public static Volume FromMegacubicFeet(QuantityValue value) { return new Volume(value, VolumeUnit.MegacubicFoot); } @@ -939,7 +939,7 @@ public static Volume FromMegacubicFeet(double value) /// /// Creates a from . /// - public static Volume FromMegaimperialGallons(double value) + public static Volume FromMegaimperialGallons(QuantityValue value) { return new Volume(value, VolumeUnit.MegaimperialGallon); } @@ -947,7 +947,7 @@ public static Volume FromMegaimperialGallons(double value) /// /// Creates a from . /// - public static Volume FromMegaliters(double value) + public static Volume FromMegaliters(QuantityValue value) { return new Volume(value, VolumeUnit.Megaliter); } @@ -955,7 +955,7 @@ public static Volume FromMegaliters(double value) /// /// Creates a from . /// - public static Volume FromMegausGallons(double value) + public static Volume FromMegausGallons(QuantityValue value) { return new Volume(value, VolumeUnit.MegausGallon); } @@ -963,7 +963,7 @@ public static Volume FromMegausGallons(double value) /// /// Creates a from . /// - public static Volume FromMetricCups(double value) + public static Volume FromMetricCups(QuantityValue value) { return new Volume(value, VolumeUnit.MetricCup); } @@ -971,7 +971,7 @@ public static Volume FromMetricCups(double value) /// /// Creates a from . /// - public static Volume FromMetricTeaspoons(double value) + public static Volume FromMetricTeaspoons(QuantityValue value) { return new Volume(value, VolumeUnit.MetricTeaspoon); } @@ -979,7 +979,7 @@ public static Volume FromMetricTeaspoons(double value) /// /// Creates a from . /// - public static Volume FromMicroliters(double value) + public static Volume FromMicroliters(QuantityValue value) { return new Volume(value, VolumeUnit.Microliter); } @@ -987,7 +987,7 @@ public static Volume FromMicroliters(double value) /// /// Creates a from . /// - public static Volume FromMilliliters(double value) + public static Volume FromMilliliters(QuantityValue value) { return new Volume(value, VolumeUnit.Milliliter); } @@ -995,7 +995,7 @@ public static Volume FromMilliliters(double value) /// /// Creates a from . /// - public static Volume FromNanoliters(double value) + public static Volume FromNanoliters(QuantityValue value) { return new Volume(value, VolumeUnit.Nanoliter); } @@ -1003,7 +1003,7 @@ public static Volume FromNanoliters(double value) /// /// Creates a from . /// - public static Volume FromOilBarrels(double value) + public static Volume FromOilBarrels(QuantityValue value) { return new Volume(value, VolumeUnit.OilBarrel); } @@ -1011,7 +1011,7 @@ public static Volume FromOilBarrels(double value) /// /// Creates a from . /// - public static Volume FromUkTablespoons(double value) + public static Volume FromUkTablespoons(QuantityValue value) { return new Volume(value, VolumeUnit.UkTablespoon); } @@ -1019,7 +1019,7 @@ public static Volume FromUkTablespoons(double value) /// /// Creates a from . /// - public static Volume FromUsBeerBarrels(double value) + public static Volume FromUsBeerBarrels(QuantityValue value) { return new Volume(value, VolumeUnit.UsBeerBarrel); } @@ -1027,7 +1027,7 @@ public static Volume FromUsBeerBarrels(double value) /// /// Creates a from . /// - public static Volume FromUsCustomaryCups(double value) + public static Volume FromUsCustomaryCups(QuantityValue value) { return new Volume(value, VolumeUnit.UsCustomaryCup); } @@ -1035,7 +1035,7 @@ public static Volume FromUsCustomaryCups(double value) /// /// Creates a from . /// - public static Volume FromUsGallons(double value) + public static Volume FromUsGallons(QuantityValue value) { return new Volume(value, VolumeUnit.UsGallon); } @@ -1043,7 +1043,7 @@ public static Volume FromUsGallons(double value) /// /// Creates a from . /// - public static Volume FromUsLegalCups(double value) + public static Volume FromUsLegalCups(QuantityValue value) { return new Volume(value, VolumeUnit.UsLegalCup); } @@ -1051,7 +1051,7 @@ public static Volume FromUsLegalCups(double value) /// /// Creates a from . /// - public static Volume FromUsOunces(double value) + public static Volume FromUsOunces(QuantityValue value) { return new Volume(value, VolumeUnit.UsOunce); } @@ -1059,7 +1059,7 @@ public static Volume FromUsOunces(double value) /// /// Creates a from . /// - public static Volume FromUsPints(double value) + public static Volume FromUsPints(QuantityValue value) { return new Volume(value, VolumeUnit.UsPint); } @@ -1067,7 +1067,7 @@ public static Volume FromUsPints(double value) /// /// Creates a from . /// - public static Volume FromUsQuarts(double value) + public static Volume FromUsQuarts(QuantityValue value) { return new Volume(value, VolumeUnit.UsQuart); } @@ -1075,7 +1075,7 @@ public static Volume FromUsQuarts(double value) /// /// Creates a from . /// - public static Volume FromUsTablespoons(double value) + public static Volume FromUsTablespoons(QuantityValue value) { return new Volume(value, VolumeUnit.UsTablespoon); } @@ -1083,7 +1083,7 @@ public static Volume FromUsTablespoons(double value) /// /// Creates a from . /// - public static Volume FromUsTeaspoons(double value) + public static Volume FromUsTeaspoons(QuantityValue value) { return new Volume(value, VolumeUnit.UsTeaspoon); } @@ -1094,7 +1094,7 @@ public static Volume FromUsTeaspoons(double value) /// Value to convert from. /// Unit to convert from. /// Volume unit value. - public static Volume From(double value, VolumeUnit fromUnit) + public static Volume From(QuantityValue value, VolumeUnit fromUnit) { return new Volume(value, fromUnit); } @@ -1266,25 +1266,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static Volume operator *(double left, Volume right) + public static Volume operator *(QuantityValue left, Volume right) { return new Volume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Volume operator *(Volume left, double right) + public static Volume operator *(Volume left, QuantityValue right) { return new Volume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Volume operator /(Volume left, double right) + public static Volume operator /(Volume left, QuantityValue right) { return new Volume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Volume left, Volume right) + public static QuantityValue operator /(Volume left, Volume right) { return left.CubicMeters / right.CubicMeters; } @@ -1299,6 +1299,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return AmountOfSubstance.FromMoles(volume.CubicMeters * molarity.MolesPerCubicMeter); } + /// Get from * . + public static Area operator *(Volume volume, ReciprocalLength reciprocalLength) + { + return Area.FromSquareMeters(volume.CubicMeters * reciprocalLength.InverseMeters); + } + /// Get from / . public static Area operator /(Volume volume, Length length) { @@ -1323,6 +1329,12 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return Energy.FromJoules(volume.CubicMeters * energyDensity.JoulesPerCubicMeter); } + /// Get from * . + public static Length operator *(Volume volume, ReciprocalArea reciprocalArea) + { + return Length.FromMeters(volume.CubicMeters * reciprocalArea.InverseSquareMeters); + } + /// Get from / . public static Length operator /(Volume volume, Area area) { @@ -1387,27 +1399,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(Volume other, Volume tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(Volume left, Volume right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is Volume otherQuantity)) @@ -1417,15 +1422,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(Volume other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1508,10 +1510,10 @@ 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( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1528,7 +1530,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(Volume other, Volume tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1541,7 +1543,12 @@ public bool Equals(Volume other, Volume tolerance) /// A hash code for the current Volume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1552,7 +1559,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeUnit unit) + public QuantityValue As(VolumeUnit unit) { if (Unit == unit) return Value; @@ -1561,7 +1568,7 @@ public double As(VolumeUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1576,7 +1583,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); @@ -1642,114 +1649,114 @@ private bool TryToUnit(VolumeUnit unit, [NotNullWhen(true)] out Volume? converte Volume? convertedOrNull = (Unit, unit) switch { // VolumeUnit -> BaseUnit - (VolumeUnit.AcreFoot, VolumeUnit.CubicMeter) => new Volume(_value / 0.000810714, VolumeUnit.CubicMeter), - (VolumeUnit.AuTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * 2e-5, VolumeUnit.CubicMeter), - (VolumeUnit.BoardFoot, VolumeUnit.CubicMeter) => new Volume(_value * 2.3597372158e-3, VolumeUnit.CubicMeter), - (VolumeUnit.Centiliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-2d, VolumeUnit.CubicMeter), - (VolumeUnit.CubicCentimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1e6, VolumeUnit.CubicMeter), - (VolumeUnit.CubicDecimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1e3, VolumeUnit.CubicMeter), - (VolumeUnit.CubicFoot, VolumeUnit.CubicMeter) => new Volume(_value * 2.8316846592e-2, VolumeUnit.CubicMeter), - (VolumeUnit.CubicHectometer, VolumeUnit.CubicMeter) => new Volume(_value * 1e6, VolumeUnit.CubicMeter), - (VolumeUnit.CubicInch, VolumeUnit.CubicMeter) => new Volume(_value * 1.6387 * 1e-5, VolumeUnit.CubicMeter), - (VolumeUnit.CubicKilometer, VolumeUnit.CubicMeter) => new Volume(_value * 1e9, VolumeUnit.CubicMeter), - (VolumeUnit.CubicMicrometer, VolumeUnit.CubicMeter) => new Volume(_value / 1e18, VolumeUnit.CubicMeter), - (VolumeUnit.CubicMile, VolumeUnit.CubicMeter) => new Volume(_value * 4.16818182544058e9, VolumeUnit.CubicMeter), - (VolumeUnit.CubicMillimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1e9, VolumeUnit.CubicMeter), - (VolumeUnit.CubicYard, VolumeUnit.CubicMeter) => new Volume(_value * 0.764554858, VolumeUnit.CubicMeter), - (VolumeUnit.Decaliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e1d, VolumeUnit.CubicMeter), - (VolumeUnit.DecausGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e1d, VolumeUnit.CubicMeter), - (VolumeUnit.Deciliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-1d, VolumeUnit.CubicMeter), - (VolumeUnit.DeciusGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e-1d, VolumeUnit.CubicMeter), - (VolumeUnit.HectocubicFoot, VolumeUnit.CubicMeter) => new Volume((_value * 2.8316846592e-2) * 1e2d, VolumeUnit.CubicMeter), - (VolumeUnit.HectocubicMeter, VolumeUnit.CubicMeter) => new Volume((_value) * 1e2d, VolumeUnit.CubicMeter), - (VolumeUnit.Hectoliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e2d, VolumeUnit.CubicMeter), - (VolumeUnit.HectousGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e2d, VolumeUnit.CubicMeter), - (VolumeUnit.ImperialBeerBarrel, VolumeUnit.CubicMeter) => new Volume(_value * 0.16365924, VolumeUnit.CubicMeter), - (VolumeUnit.ImperialGallon, VolumeUnit.CubicMeter) => new Volume(_value * 0.00454609, VolumeUnit.CubicMeter), - (VolumeUnit.ImperialOunce, VolumeUnit.CubicMeter) => new Volume(_value * 2.8413062499962901241875439064617e-5, VolumeUnit.CubicMeter), - (VolumeUnit.ImperialPint, VolumeUnit.CubicMeter) => new Volume(_value * 5.6826125e-4, VolumeUnit.CubicMeter), - (VolumeUnit.ImperialQuart, VolumeUnit.CubicMeter) => new Volume(_value * 1.1365225e-3, VolumeUnit.CubicMeter), - (VolumeUnit.KilocubicFoot, VolumeUnit.CubicMeter) => new Volume((_value * 2.8316846592e-2) * 1e3d, VolumeUnit.CubicMeter), - (VolumeUnit.KilocubicMeter, VolumeUnit.CubicMeter) => new Volume((_value) * 1e3d, VolumeUnit.CubicMeter), - (VolumeUnit.KiloimperialGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.00454609) * 1e3d, VolumeUnit.CubicMeter), - (VolumeUnit.Kiloliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e3d, VolumeUnit.CubicMeter), - (VolumeUnit.KilousGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e3d, VolumeUnit.CubicMeter), - (VolumeUnit.Liter, VolumeUnit.CubicMeter) => new Volume(_value / 1e3, VolumeUnit.CubicMeter), - (VolumeUnit.MegacubicFoot, VolumeUnit.CubicMeter) => new Volume((_value * 2.8316846592e-2) * 1e6d, VolumeUnit.CubicMeter), - (VolumeUnit.MegaimperialGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.00454609) * 1e6d, VolumeUnit.CubicMeter), - (VolumeUnit.Megaliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e6d, VolumeUnit.CubicMeter), - (VolumeUnit.MegausGallon, VolumeUnit.CubicMeter) => new Volume((_value * 0.003785411784) * 1e6d, VolumeUnit.CubicMeter), - (VolumeUnit.MetricCup, VolumeUnit.CubicMeter) => new Volume(_value * 0.00025, VolumeUnit.CubicMeter), - (VolumeUnit.MetricTeaspoon, VolumeUnit.CubicMeter) => new Volume(_value * 0.5e-5, VolumeUnit.CubicMeter), - (VolumeUnit.Microliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-6d, VolumeUnit.CubicMeter), - (VolumeUnit.Milliliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-3d, VolumeUnit.CubicMeter), - (VolumeUnit.Nanoliter, VolumeUnit.CubicMeter) => new Volume((_value / 1e3) * 1e-9d, VolumeUnit.CubicMeter), - (VolumeUnit.OilBarrel, VolumeUnit.CubicMeter) => new Volume(_value * 0.158987294928, VolumeUnit.CubicMeter), - (VolumeUnit.UkTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * 1.5e-5, VolumeUnit.CubicMeter), - (VolumeUnit.UsBeerBarrel, VolumeUnit.CubicMeter) => new Volume(_value * 0.1173477658, VolumeUnit.CubicMeter), - (VolumeUnit.UsCustomaryCup, VolumeUnit.CubicMeter) => new Volume(_value * 0.0002365882365, VolumeUnit.CubicMeter), - (VolumeUnit.UsGallon, VolumeUnit.CubicMeter) => new Volume(_value * 0.003785411784, VolumeUnit.CubicMeter), - (VolumeUnit.UsLegalCup, VolumeUnit.CubicMeter) => new Volume(_value * 0.00024, VolumeUnit.CubicMeter), - (VolumeUnit.UsOunce, VolumeUnit.CubicMeter) => new Volume(_value * 2.957352956253760505068307980135e-5, VolumeUnit.CubicMeter), - (VolumeUnit.UsPint, VolumeUnit.CubicMeter) => new Volume(_value * 4.73176473e-4, VolumeUnit.CubicMeter), - (VolumeUnit.UsQuart, VolumeUnit.CubicMeter) => new Volume(_value * 9.46352946e-4, VolumeUnit.CubicMeter), - (VolumeUnit.UsTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * 1.478676478125e-5, VolumeUnit.CubicMeter), - (VolumeUnit.UsTeaspoon, VolumeUnit.CubicMeter) => new Volume(_value * 4.92892159375e-6, VolumeUnit.CubicMeter), + (VolumeUnit.AcreFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(500000000, 405357, false), VolumeUnit.CubicMeter), + (VolumeUnit.AuTablespoon, VolumeUnit.CubicMeter) => new Volume(_value / 50000, VolumeUnit.CubicMeter), + (VolumeUnit.BoardFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(11798686079, 5000000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.Centiliter, VolumeUnit.CubicMeter) => new Volume(_value / 100000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicCentimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1000000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicDecimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(55306341, 1953125000, false), VolumeUnit.CubicMeter), + (VolumeUnit.CubicHectometer, VolumeUnit.CubicMeter) => new Volume(_value * 1000000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicInch, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(2048383, 125000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.CubicKilometer, VolumeUnit.CubicMeter) => new Volume(_value * 1000000000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicMicrometer, VolumeUnit.CubicMeter) => new Volume(_value / 1000000000000000000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicMile, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(208409091272029, 50000, false), VolumeUnit.CubicMeter), + (VolumeUnit.CubicMillimeter, VolumeUnit.CubicMeter) => new Volume(_value / 1000000000, VolumeUnit.CubicMeter), + (VolumeUnit.CubicYard, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(382277429, 500000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.Decaliter, VolumeUnit.CubicMeter) => new Volume(_value / 100, VolumeUnit.CubicMeter), + (VolumeUnit.DecausGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 12500000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.Deciliter, VolumeUnit.CubicMeter) => new Volume(_value / 10000, VolumeUnit.CubicMeter), + (VolumeUnit.DeciusGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 1250000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.HectocubicFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(55306341, 19531250, false), VolumeUnit.CubicMeter), + (VolumeUnit.HectocubicMeter, VolumeUnit.CubicMeter) => new Volume(_value * 100, VolumeUnit.CubicMeter), + (VolumeUnit.Hectoliter, VolumeUnit.CubicMeter) => new Volume(_value / 10, VolumeUnit.CubicMeter), + (VolumeUnit.HectousGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 1250000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.ImperialBeerBarrel, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(4091481, 25000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.ImperialGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 100000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.ImperialOunce, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 16000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.ImperialPint, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 800000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.ImperialQuart, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 400000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.KilocubicFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(55306341, 1953125, false), VolumeUnit.CubicMeter), + (VolumeUnit.KilocubicMeter, VolumeUnit.CubicMeter) => new Volume(_value * 1000, VolumeUnit.CubicMeter), + (VolumeUnit.KiloimperialGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 100000, false), VolumeUnit.CubicMeter), + (VolumeUnit.Kiloliter, VolumeUnit.CubicMeter) => new Volume(_value, VolumeUnit.CubicMeter), + (VolumeUnit.KilousGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 125000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.Liter, VolumeUnit.CubicMeter) => new Volume(_value / 1000, VolumeUnit.CubicMeter), + (VolumeUnit.MegacubicFoot, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(442450728, 15625, false), VolumeUnit.CubicMeter), + (VolumeUnit.MegaimperialGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(454609, 100, false), VolumeUnit.CubicMeter), + (VolumeUnit.Megaliter, VolumeUnit.CubicMeter) => new Volume(_value * 1000, VolumeUnit.CubicMeter), + (VolumeUnit.MegausGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 125000, false), VolumeUnit.CubicMeter), + (VolumeUnit.MetricCup, VolumeUnit.CubicMeter) => new Volume(_value / 4000, VolumeUnit.CubicMeter), + (VolumeUnit.MetricTeaspoon, VolumeUnit.CubicMeter) => new Volume(_value / 200000, VolumeUnit.CubicMeter), + (VolumeUnit.Microliter, VolumeUnit.CubicMeter) => new Volume(_value / 1000000000, VolumeUnit.CubicMeter), + (VolumeUnit.Milliliter, VolumeUnit.CubicMeter) => new Volume(_value / 1000000, VolumeUnit.CubicMeter), + (VolumeUnit.Nanoliter, VolumeUnit.CubicMeter) => new Volume(_value / 1000000000000, VolumeUnit.CubicMeter), + (VolumeUnit.OilBarrel, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(9936705933, 62500000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UkTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(3, 200000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsBeerBarrel, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(586738829, 5000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsCustomaryCup, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 2000000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsGallon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 125000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsLegalCup, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(3, 12500, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsOunce, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 16000000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsPint, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 1000000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsQuart, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 500000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsTablespoon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(473176473, 32000000000000, false), VolumeUnit.CubicMeter), + (VolumeUnit.UsTeaspoon, VolumeUnit.CubicMeter) => new Volume(_value * new QuantityValue(157725491, 32000000000000, false), VolumeUnit.CubicMeter), // BaseUnit -> VolumeUnit - (VolumeUnit.CubicMeter, VolumeUnit.AcreFoot) => new Volume(_value * 0.000810714, VolumeUnit.AcreFoot), - (VolumeUnit.CubicMeter, VolumeUnit.AuTablespoon) => new Volume(_value / 2e-5, VolumeUnit.AuTablespoon), - (VolumeUnit.CubicMeter, VolumeUnit.BoardFoot) => new Volume(_value / 2.3597372158e-3, VolumeUnit.BoardFoot), - (VolumeUnit.CubicMeter, VolumeUnit.Centiliter) => new Volume((_value * 1e3) / 1e-2d, VolumeUnit.Centiliter), - (VolumeUnit.CubicMeter, VolumeUnit.CubicCentimeter) => new Volume(_value * 1e6, VolumeUnit.CubicCentimeter), - (VolumeUnit.CubicMeter, VolumeUnit.CubicDecimeter) => new Volume(_value * 1e3, VolumeUnit.CubicDecimeter), - (VolumeUnit.CubicMeter, VolumeUnit.CubicFoot) => new Volume(_value / 2.8316846592e-2, VolumeUnit.CubicFoot), - (VolumeUnit.CubicMeter, VolumeUnit.CubicHectometer) => new Volume(_value / 1e6, VolumeUnit.CubicHectometer), - (VolumeUnit.CubicMeter, VolumeUnit.CubicInch) => new Volume(_value / (1.6387 * 1e-5), VolumeUnit.CubicInch), - (VolumeUnit.CubicMeter, VolumeUnit.CubicKilometer) => new Volume(_value / 1e9, VolumeUnit.CubicKilometer), - (VolumeUnit.CubicMeter, VolumeUnit.CubicMicrometer) => new Volume(_value * 1e18, VolumeUnit.CubicMicrometer), - (VolumeUnit.CubicMeter, VolumeUnit.CubicMile) => new Volume(_value / 4.16818182544058e9, VolumeUnit.CubicMile), - (VolumeUnit.CubicMeter, VolumeUnit.CubicMillimeter) => new Volume(_value * 1e9, VolumeUnit.CubicMillimeter), - (VolumeUnit.CubicMeter, VolumeUnit.CubicYard) => new Volume(_value / 0.764554858, VolumeUnit.CubicYard), - (VolumeUnit.CubicMeter, VolumeUnit.Decaliter) => new Volume((_value * 1e3) / 1e1d, VolumeUnit.Decaliter), - (VolumeUnit.CubicMeter, VolumeUnit.DecausGallon) => new Volume((_value / 0.003785411784) / 1e1d, VolumeUnit.DecausGallon), - (VolumeUnit.CubicMeter, VolumeUnit.Deciliter) => new Volume((_value * 1e3) / 1e-1d, VolumeUnit.Deciliter), - (VolumeUnit.CubicMeter, VolumeUnit.DeciusGallon) => new Volume((_value / 0.003785411784) / 1e-1d, VolumeUnit.DeciusGallon), - (VolumeUnit.CubicMeter, VolumeUnit.HectocubicFoot) => new Volume((_value / 2.8316846592e-2) / 1e2d, VolumeUnit.HectocubicFoot), - (VolumeUnit.CubicMeter, VolumeUnit.HectocubicMeter) => new Volume((_value) / 1e2d, VolumeUnit.HectocubicMeter), - (VolumeUnit.CubicMeter, VolumeUnit.Hectoliter) => new Volume((_value * 1e3) / 1e2d, VolumeUnit.Hectoliter), - (VolumeUnit.CubicMeter, VolumeUnit.HectousGallon) => new Volume((_value / 0.003785411784) / 1e2d, VolumeUnit.HectousGallon), - (VolumeUnit.CubicMeter, VolumeUnit.ImperialBeerBarrel) => new Volume(_value / 0.16365924, VolumeUnit.ImperialBeerBarrel), - (VolumeUnit.CubicMeter, VolumeUnit.ImperialGallon) => new Volume(_value / 0.00454609, VolumeUnit.ImperialGallon), - (VolumeUnit.CubicMeter, VolumeUnit.ImperialOunce) => new Volume(_value / 2.8413062499962901241875439064617e-5, VolumeUnit.ImperialOunce), - (VolumeUnit.CubicMeter, VolumeUnit.ImperialPint) => new Volume(_value / 5.6826125e-4, VolumeUnit.ImperialPint), - (VolumeUnit.CubicMeter, VolumeUnit.ImperialQuart) => new Volume(_value / 1.1365225e-3, VolumeUnit.ImperialQuart), - (VolumeUnit.CubicMeter, VolumeUnit.KilocubicFoot) => new Volume((_value / 2.8316846592e-2) / 1e3d, VolumeUnit.KilocubicFoot), - (VolumeUnit.CubicMeter, VolumeUnit.KilocubicMeter) => new Volume((_value) / 1e3d, VolumeUnit.KilocubicMeter), - (VolumeUnit.CubicMeter, VolumeUnit.KiloimperialGallon) => new Volume((_value / 0.00454609) / 1e3d, VolumeUnit.KiloimperialGallon), - (VolumeUnit.CubicMeter, VolumeUnit.Kiloliter) => new Volume((_value * 1e3) / 1e3d, VolumeUnit.Kiloliter), - (VolumeUnit.CubicMeter, VolumeUnit.KilousGallon) => new Volume((_value / 0.003785411784) / 1e3d, VolumeUnit.KilousGallon), - (VolumeUnit.CubicMeter, VolumeUnit.Liter) => new Volume(_value * 1e3, VolumeUnit.Liter), - (VolumeUnit.CubicMeter, VolumeUnit.MegacubicFoot) => new Volume((_value / 2.8316846592e-2) / 1e6d, VolumeUnit.MegacubicFoot), - (VolumeUnit.CubicMeter, VolumeUnit.MegaimperialGallon) => new Volume((_value / 0.00454609) / 1e6d, VolumeUnit.MegaimperialGallon), - (VolumeUnit.CubicMeter, VolumeUnit.Megaliter) => new Volume((_value * 1e3) / 1e6d, VolumeUnit.Megaliter), - (VolumeUnit.CubicMeter, VolumeUnit.MegausGallon) => new Volume((_value / 0.003785411784) / 1e6d, VolumeUnit.MegausGallon), - (VolumeUnit.CubicMeter, VolumeUnit.MetricCup) => new Volume(_value / 0.00025, VolumeUnit.MetricCup), - (VolumeUnit.CubicMeter, VolumeUnit.MetricTeaspoon) => new Volume(_value / 0.5e-5, VolumeUnit.MetricTeaspoon), - (VolumeUnit.CubicMeter, VolumeUnit.Microliter) => new Volume((_value * 1e3) / 1e-6d, VolumeUnit.Microliter), - (VolumeUnit.CubicMeter, VolumeUnit.Milliliter) => new Volume((_value * 1e3) / 1e-3d, VolumeUnit.Milliliter), - (VolumeUnit.CubicMeter, VolumeUnit.Nanoliter) => new Volume((_value * 1e3) / 1e-9d, VolumeUnit.Nanoliter), - (VolumeUnit.CubicMeter, VolumeUnit.OilBarrel) => new Volume(_value / 0.158987294928, VolumeUnit.OilBarrel), - (VolumeUnit.CubicMeter, VolumeUnit.UkTablespoon) => new Volume(_value / 1.5e-5, VolumeUnit.UkTablespoon), - (VolumeUnit.CubicMeter, VolumeUnit.UsBeerBarrel) => new Volume(_value / 0.1173477658, VolumeUnit.UsBeerBarrel), - (VolumeUnit.CubicMeter, VolumeUnit.UsCustomaryCup) => new Volume(_value / 0.0002365882365, VolumeUnit.UsCustomaryCup), - (VolumeUnit.CubicMeter, VolumeUnit.UsGallon) => new Volume(_value / 0.003785411784, VolumeUnit.UsGallon), - (VolumeUnit.CubicMeter, VolumeUnit.UsLegalCup) => new Volume(_value / 0.00024, VolumeUnit.UsLegalCup), - (VolumeUnit.CubicMeter, VolumeUnit.UsOunce) => new Volume(_value / 2.957352956253760505068307980135e-5, VolumeUnit.UsOunce), - (VolumeUnit.CubicMeter, VolumeUnit.UsPint) => new Volume(_value / 4.73176473e-4, VolumeUnit.UsPint), - (VolumeUnit.CubicMeter, VolumeUnit.UsQuart) => new Volume(_value / 9.46352946e-4, VolumeUnit.UsQuart), - (VolumeUnit.CubicMeter, VolumeUnit.UsTablespoon) => new Volume(_value / 1.478676478125e-5, VolumeUnit.UsTablespoon), - (VolumeUnit.CubicMeter, VolumeUnit.UsTeaspoon) => new Volume(_value / 4.92892159375e-6, VolumeUnit.UsTeaspoon), + (VolumeUnit.CubicMeter, VolumeUnit.AcreFoot) => new Volume(_value * new QuantityValue(405357, 500000000, false), VolumeUnit.AcreFoot), + (VolumeUnit.CubicMeter, VolumeUnit.AuTablespoon) => new Volume(_value * 50000, VolumeUnit.AuTablespoon), + (VolumeUnit.CubicMeter, VolumeUnit.BoardFoot) => new Volume(_value * new QuantityValue(5000000000000, 11798686079, false), VolumeUnit.BoardFoot), + (VolumeUnit.CubicMeter, VolumeUnit.Centiliter) => new Volume(_value * 100000, VolumeUnit.Centiliter), + (VolumeUnit.CubicMeter, VolumeUnit.CubicCentimeter) => new Volume(_value * 1000000, VolumeUnit.CubicCentimeter), + (VolumeUnit.CubicMeter, VolumeUnit.CubicDecimeter) => new Volume(_value * 1000, VolumeUnit.CubicDecimeter), + (VolumeUnit.CubicMeter, VolumeUnit.CubicFoot) => new Volume(_value * new QuantityValue(1953125000, 55306341, false), VolumeUnit.CubicFoot), + (VolumeUnit.CubicMeter, VolumeUnit.CubicHectometer) => new Volume(_value / 1000000, VolumeUnit.CubicHectometer), + (VolumeUnit.CubicMeter, VolumeUnit.CubicInch) => new Volume(_value * new QuantityValue(125000000000, 2048383, false), VolumeUnit.CubicInch), + (VolumeUnit.CubicMeter, VolumeUnit.CubicKilometer) => new Volume(_value / 1000000000, VolumeUnit.CubicKilometer), + (VolumeUnit.CubicMeter, VolumeUnit.CubicMicrometer) => new Volume(_value * 1000000000000000000, VolumeUnit.CubicMicrometer), + (VolumeUnit.CubicMeter, VolumeUnit.CubicMile) => new Volume(_value * new QuantityValue(50000, 208409091272029, false), VolumeUnit.CubicMile), + (VolumeUnit.CubicMeter, VolumeUnit.CubicMillimeter) => new Volume(_value * 1000000000, VolumeUnit.CubicMillimeter), + (VolumeUnit.CubicMeter, VolumeUnit.CubicYard) => new Volume(_value * new QuantityValue(500000000, 382277429, false), VolumeUnit.CubicYard), + (VolumeUnit.CubicMeter, VolumeUnit.Decaliter) => new Volume(_value * 100, VolumeUnit.Decaliter), + (VolumeUnit.CubicMeter, VolumeUnit.DecausGallon) => new Volume(_value * new QuantityValue(12500000000, 473176473, false), VolumeUnit.DecausGallon), + (VolumeUnit.CubicMeter, VolumeUnit.Deciliter) => new Volume(_value * 10000, VolumeUnit.Deciliter), + (VolumeUnit.CubicMeter, VolumeUnit.DeciusGallon) => new Volume(_value * new QuantityValue(1250000000000, 473176473, false), VolumeUnit.DeciusGallon), + (VolumeUnit.CubicMeter, VolumeUnit.HectocubicFoot) => new Volume(_value * new QuantityValue(19531250, 55306341, false), VolumeUnit.HectocubicFoot), + (VolumeUnit.CubicMeter, VolumeUnit.HectocubicMeter) => new Volume(_value / 100, VolumeUnit.HectocubicMeter), + (VolumeUnit.CubicMeter, VolumeUnit.Hectoliter) => new Volume(_value * 10, VolumeUnit.Hectoliter), + (VolumeUnit.CubicMeter, VolumeUnit.HectousGallon) => new Volume(_value * new QuantityValue(1250000000, 473176473, false), VolumeUnit.HectousGallon), + (VolumeUnit.CubicMeter, VolumeUnit.ImperialBeerBarrel) => new Volume(_value * new QuantityValue(25000000, 4091481, false), VolumeUnit.ImperialBeerBarrel), + (VolumeUnit.CubicMeter, VolumeUnit.ImperialGallon) => new Volume(_value * new QuantityValue(100000000, 454609, false), VolumeUnit.ImperialGallon), + (VolumeUnit.CubicMeter, VolumeUnit.ImperialOunce) => new Volume(_value * new QuantityValue(16000000000, 454609, false), VolumeUnit.ImperialOunce), + (VolumeUnit.CubicMeter, VolumeUnit.ImperialPint) => new Volume(_value * new QuantityValue(800000000, 454609, false), VolumeUnit.ImperialPint), + (VolumeUnit.CubicMeter, VolumeUnit.ImperialQuart) => new Volume(_value * new QuantityValue(400000000, 454609, false), VolumeUnit.ImperialQuart), + (VolumeUnit.CubicMeter, VolumeUnit.KilocubicFoot) => new Volume(_value * new QuantityValue(1953125, 55306341, false), VolumeUnit.KilocubicFoot), + (VolumeUnit.CubicMeter, VolumeUnit.KilocubicMeter) => new Volume(_value / 1000, VolumeUnit.KilocubicMeter), + (VolumeUnit.CubicMeter, VolumeUnit.KiloimperialGallon) => new Volume(_value * new QuantityValue(100000, 454609, false), VolumeUnit.KiloimperialGallon), + (VolumeUnit.CubicMeter, VolumeUnit.Kiloliter) => new Volume(_value, VolumeUnit.Kiloliter), + (VolumeUnit.CubicMeter, VolumeUnit.KilousGallon) => new Volume(_value * new QuantityValue(125000000, 473176473, false), VolumeUnit.KilousGallon), + (VolumeUnit.CubicMeter, VolumeUnit.Liter) => new Volume(_value * 1000, VolumeUnit.Liter), + (VolumeUnit.CubicMeter, VolumeUnit.MegacubicFoot) => new Volume(_value * new QuantityValue(15625, 442450728, false), VolumeUnit.MegacubicFoot), + (VolumeUnit.CubicMeter, VolumeUnit.MegaimperialGallon) => new Volume(_value * new QuantityValue(100, 454609, false), VolumeUnit.MegaimperialGallon), + (VolumeUnit.CubicMeter, VolumeUnit.Megaliter) => new Volume(_value / 1000, VolumeUnit.Megaliter), + (VolumeUnit.CubicMeter, VolumeUnit.MegausGallon) => new Volume(_value * new QuantityValue(125000, 473176473, false), VolumeUnit.MegausGallon), + (VolumeUnit.CubicMeter, VolumeUnit.MetricCup) => new Volume(_value * 4000, VolumeUnit.MetricCup), + (VolumeUnit.CubicMeter, VolumeUnit.MetricTeaspoon) => new Volume(_value * 200000, VolumeUnit.MetricTeaspoon), + (VolumeUnit.CubicMeter, VolumeUnit.Microliter) => new Volume(_value * 1000000000, VolumeUnit.Microliter), + (VolumeUnit.CubicMeter, VolumeUnit.Milliliter) => new Volume(_value * 1000000, VolumeUnit.Milliliter), + (VolumeUnit.CubicMeter, VolumeUnit.Nanoliter) => new Volume(_value * 1000000000000, VolumeUnit.Nanoliter), + (VolumeUnit.CubicMeter, VolumeUnit.OilBarrel) => new Volume(_value * new QuantityValue(62500000000, 9936705933, false), VolumeUnit.OilBarrel), + (VolumeUnit.CubicMeter, VolumeUnit.UkTablespoon) => new Volume(_value * new QuantityValue(200000, 3, false), VolumeUnit.UkTablespoon), + (VolumeUnit.CubicMeter, VolumeUnit.UsBeerBarrel) => new Volume(_value * new QuantityValue(5000000000, 586738829, false), VolumeUnit.UsBeerBarrel), + (VolumeUnit.CubicMeter, VolumeUnit.UsCustomaryCup) => new Volume(_value * new QuantityValue(2000000000000, 473176473, false), VolumeUnit.UsCustomaryCup), + (VolumeUnit.CubicMeter, VolumeUnit.UsGallon) => new Volume(_value * new QuantityValue(125000000000, 473176473, false), VolumeUnit.UsGallon), + (VolumeUnit.CubicMeter, VolumeUnit.UsLegalCup) => new Volume(_value * new QuantityValue(12500, 3, false), VolumeUnit.UsLegalCup), + (VolumeUnit.CubicMeter, VolumeUnit.UsOunce) => new Volume(_value * new QuantityValue(16000000000000, 473176473, false), VolumeUnit.UsOunce), + (VolumeUnit.CubicMeter, VolumeUnit.UsPint) => new Volume(_value * new QuantityValue(1000000000000, 473176473, false), VolumeUnit.UsPint), + (VolumeUnit.CubicMeter, VolumeUnit.UsQuart) => new Volume(_value * new QuantityValue(500000000000, 473176473, false), VolumeUnit.UsQuart), + (VolumeUnit.CubicMeter, VolumeUnit.UsTablespoon) => new Volume(_value * new QuantityValue(32000000000000, 473176473, false), VolumeUnit.UsTablespoon), + (VolumeUnit.CubicMeter, VolumeUnit.UsTeaspoon) => new Volume(_value * new QuantityValue(32000000000000, 157725491, false), VolumeUnit.UsTeaspoon), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index ef6fb19a9a..04a8f372f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -107,7 +105,7 @@ static VolumeConcentration() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VolumeConcentration(double value, VolumeConcentrationUnit unit) + public VolumeConcentration(QuantityValue value, VolumeConcentrationUnit unit) { _value = value; _unit = unit; @@ -121,7 +119,7 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeConcentration(double value, UnitSystem unitSystem) + public VolumeConcentration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -172,10 +170,10 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -200,102 +198,102 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); + public QuantityValue CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); + public QuantityValue CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); + public QuantityValue DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); + public QuantityValue DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); /// /// Gets a value of this quantity converted into /// - public double LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); + public QuantityValue LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); + public QuantityValue LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); + public QuantityValue MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); + public QuantityValue MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); + public QuantityValue MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); + public QuantityValue MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); + public QuantityValue NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); + public QuantityValue NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); /// /// Gets a value of this quantity converted into /// - public double PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); /// /// Gets a value of this quantity converted into /// - public double PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); /// /// Gets a value of this quantity converted into /// - public double PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); /// /// Gets a value of this quantity converted into /// - public double Percent => As(VolumeConcentrationUnit.Percent); + public QuantityValue Percent => As(VolumeConcentrationUnit.Percent); /// /// Gets a value of this quantity converted into /// - public double PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); + public QuantityValue PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); /// /// Gets a value of this quantity converted into /// - public double PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); + public QuantityValue PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); #endregion @@ -381,7 +379,7 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvid /// /// Creates a from . /// - public static VolumeConcentration FromCentilitersPerLiter(double value) + public static VolumeConcentration FromCentilitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerLiter); } @@ -389,7 +387,7 @@ public static VolumeConcentration FromCentilitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromCentilitersPerMililiter(double value) + public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerMililiter); } @@ -397,7 +395,7 @@ public static VolumeConcentration FromCentilitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromDecilitersPerLiter(double value) + public static VolumeConcentration FromDecilitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerLiter); } @@ -405,7 +403,7 @@ public static VolumeConcentration FromDecilitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromDecilitersPerMililiter(double value) + public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerMililiter); } @@ -413,7 +411,7 @@ public static VolumeConcentration FromDecilitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromDecimalFractions(double value) + public static VolumeConcentration FromDecimalFractions(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.DecimalFraction); } @@ -421,7 +419,7 @@ public static VolumeConcentration FromDecimalFractions(double value) /// /// Creates a from . /// - public static VolumeConcentration FromLitersPerLiter(double value) + public static VolumeConcentration FromLitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerLiter); } @@ -429,7 +427,7 @@ public static VolumeConcentration FromLitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromLitersPerMililiter(double value) + public static VolumeConcentration FromLitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerMililiter); } @@ -437,7 +435,7 @@ public static VolumeConcentration FromLitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromMicrolitersPerLiter(double value) + public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerLiter); } @@ -445,7 +443,7 @@ public static VolumeConcentration FromMicrolitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromMicrolitersPerMililiter(double value) + public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerMililiter); } @@ -453,7 +451,7 @@ public static VolumeConcentration FromMicrolitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromMillilitersPerLiter(double value) + public static VolumeConcentration FromMillilitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerLiter); } @@ -461,7 +459,7 @@ public static VolumeConcentration FromMillilitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromMillilitersPerMililiter(double value) + public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerMililiter); } @@ -469,7 +467,7 @@ public static VolumeConcentration FromMillilitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromNanolitersPerLiter(double value) + public static VolumeConcentration FromNanolitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerLiter); } @@ -477,7 +475,7 @@ public static VolumeConcentration FromNanolitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromNanolitersPerMililiter(double value) + public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerMililiter); } @@ -485,7 +483,7 @@ public static VolumeConcentration FromNanolitersPerMililiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPartsPerBillion(double value) + public static VolumeConcentration FromPartsPerBillion(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerBillion); } @@ -493,7 +491,7 @@ public static VolumeConcentration FromPartsPerBillion(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPartsPerMillion(double value) + public static VolumeConcentration FromPartsPerMillion(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerMillion); } @@ -501,7 +499,7 @@ public static VolumeConcentration FromPartsPerMillion(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPartsPerThousand(double value) + public static VolumeConcentration FromPartsPerThousand(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerThousand); } @@ -509,7 +507,7 @@ public static VolumeConcentration FromPartsPerThousand(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPartsPerTrillion(double value) + public static VolumeConcentration FromPartsPerTrillion(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerTrillion); } @@ -517,7 +515,7 @@ public static VolumeConcentration FromPartsPerTrillion(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPercent(double value) + public static VolumeConcentration FromPercent(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.Percent); } @@ -525,7 +523,7 @@ public static VolumeConcentration FromPercent(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPicolitersPerLiter(double value) + public static VolumeConcentration FromPicolitersPerLiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerLiter); } @@ -533,7 +531,7 @@ public static VolumeConcentration FromPicolitersPerLiter(double value) /// /// Creates a from . /// - public static VolumeConcentration FromPicolitersPerMililiter(double value) + public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue value) { return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerMililiter); } @@ -544,7 +542,7 @@ public static VolumeConcentration FromPicolitersPerMililiter(double value) /// Value to convert from. /// Unit to convert from. /// VolumeConcentration unit value. - public static VolumeConcentration From(double value, VolumeConcentrationUnit fromUnit) + public static VolumeConcentration From(QuantityValue value, VolumeConcentrationUnit fromUnit) { return new VolumeConcentration(value, fromUnit); } @@ -716,25 +714,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeConcentration operator *(double left, VolumeConcentration right) + public static VolumeConcentration operator *(QuantityValue left, VolumeConcentration right) { return new VolumeConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeConcentration operator *(VolumeConcentration left, double right) + public static VolumeConcentration operator *(VolumeConcentration left, QuantityValue right) { return new VolumeConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeConcentration operator /(VolumeConcentration left, double right) + public static VolumeConcentration operator /(VolumeConcentration left, QuantityValue right) { return new VolumeConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeConcentration left, VolumeConcentration right) + public static QuantityValue operator /(VolumeConcentration left, VolumeConcentration right) { return left.DecimalFractions / right.DecimalFractions; } @@ -783,27 +781,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VolumeConcentration left, VolumeConcentration right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeConcentration other, VolumeConcentration tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VolumeConcentration left, VolumeConcentration right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeConcentration otherQuantity)) @@ -813,15 +804,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VolumeConcentration other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -904,10 +892,10 @@ public bool Equals(VolumeConcentration other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -924,7 +912,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeConcentration other, VolumeConcentration tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -937,7 +925,12 @@ public bool Equals(VolumeConcentration other, VolumeConcentration tolerance) /// A hash code for the current VolumeConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -948,7 +941,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeConcentrationUnit unit) + public QuantityValue As(VolumeConcentrationUnit unit) { if (Unit == unit) return Value; @@ -957,7 +950,7 @@ public double As(VolumeConcentrationUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -972,7 +965,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); @@ -1038,46 +1031,46 @@ private bool TryToUnit(VolumeConcentrationUnit unit, [NotNullWhen(true)] out Vol VolumeConcentration? convertedOrNull = (Unit, unit) switch { // VolumeConcentrationUnit -> BaseUnit - (VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-2d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-2d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-1d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-1d, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 100, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value * 10, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 10, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value * 100, VolumeConcentrationUnit.DecimalFraction), (VolumeConcentrationUnit.LitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e-3, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-6d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-6d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-3d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-3d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-9d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-9d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PartPerBillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e9, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PartPerMillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e6, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PartPerThousand, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e3, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PartPerTrillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e12, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.Percent, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1e2, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value) * 1e-12d, VolumeConcentrationUnit.DecimalFraction), - (VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration((_value / 1e-3) * 1e-12d, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value * 1000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PartPerBillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PartPerMillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PartPerThousand, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PartPerTrillion, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.Percent, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 100, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000000000, VolumeConcentrationUnit.DecimalFraction), + (VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentrationUnit.DecimalFraction) => new VolumeConcentration(_value / 1000000000, VolumeConcentrationUnit.DecimalFraction), // BaseUnit -> VolumeConcentrationUnit - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.CentilitersPerLiter) => new VolumeConcentration((_value) / 1e-2d, VolumeConcentrationUnit.CentilitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.CentilitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-2d, VolumeConcentrationUnit.CentilitersPerMililiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.DecilitersPerLiter) => new VolumeConcentration((_value) / 1e-1d, VolumeConcentrationUnit.DecilitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.DecilitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-1d, VolumeConcentrationUnit.DecilitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.CentilitersPerLiter) => new VolumeConcentration(_value * 100, VolumeConcentrationUnit.CentilitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.CentilitersPerMililiter) => new VolumeConcentration(_value / 10, VolumeConcentrationUnit.CentilitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.DecilitersPerLiter) => new VolumeConcentration(_value * 10, VolumeConcentrationUnit.DecilitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.DecilitersPerMililiter) => new VolumeConcentration(_value / 100, VolumeConcentrationUnit.DecilitersPerMililiter), (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.LitersPerLiter) => new VolumeConcentration(_value, VolumeConcentrationUnit.LitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.LitersPerMililiter) => new VolumeConcentration(_value * 1e-3, VolumeConcentrationUnit.LitersPerMililiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MicrolitersPerLiter) => new VolumeConcentration((_value) / 1e-6d, VolumeConcentrationUnit.MicrolitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MicrolitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-6d, VolumeConcentrationUnit.MicrolitersPerMililiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MillilitersPerLiter) => new VolumeConcentration((_value) / 1e-3d, VolumeConcentrationUnit.MillilitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MillilitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-3d, VolumeConcentrationUnit.MillilitersPerMililiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.NanolitersPerLiter) => new VolumeConcentration((_value) / 1e-9d, VolumeConcentrationUnit.NanolitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.NanolitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-9d, VolumeConcentrationUnit.NanolitersPerMililiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerBillion) => new VolumeConcentration(_value * 1e9, VolumeConcentrationUnit.PartPerBillion), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerMillion) => new VolumeConcentration(_value * 1e6, VolumeConcentrationUnit.PartPerMillion), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerThousand) => new VolumeConcentration(_value * 1e3, VolumeConcentrationUnit.PartPerThousand), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerTrillion) => new VolumeConcentration(_value * 1e12, VolumeConcentrationUnit.PartPerTrillion), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.Percent) => new VolumeConcentration(_value * 1e2, VolumeConcentrationUnit.Percent), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerLiter) => new VolumeConcentration((_value) / 1e-12d, VolumeConcentrationUnit.PicolitersPerLiter), - (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerMililiter) => new VolumeConcentration((_value * 1e-3) / 1e-12d, VolumeConcentrationUnit.PicolitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.LitersPerMililiter) => new VolumeConcentration(_value / 1000, VolumeConcentrationUnit.LitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MicrolitersPerLiter) => new VolumeConcentration(_value * 1000000, VolumeConcentrationUnit.MicrolitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MicrolitersPerMililiter) => new VolumeConcentration(_value * 1000, VolumeConcentrationUnit.MicrolitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MillilitersPerLiter) => new VolumeConcentration(_value * 1000, VolumeConcentrationUnit.MillilitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.MillilitersPerMililiter) => new VolumeConcentration(_value, VolumeConcentrationUnit.MillilitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.NanolitersPerLiter) => new VolumeConcentration(_value * 1000000000, VolumeConcentrationUnit.NanolitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.NanolitersPerMililiter) => new VolumeConcentration(_value * 1000000, VolumeConcentrationUnit.NanolitersPerMililiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerBillion) => new VolumeConcentration(_value * 1000000000, VolumeConcentrationUnit.PartPerBillion), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerMillion) => new VolumeConcentration(_value * 1000000, VolumeConcentrationUnit.PartPerMillion), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerThousand) => new VolumeConcentration(_value * 1000, VolumeConcentrationUnit.PartPerThousand), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PartPerTrillion) => new VolumeConcentration(_value * 1000000000000, VolumeConcentrationUnit.PartPerTrillion), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.Percent) => new VolumeConcentration(_value * 100, VolumeConcentrationUnit.Percent), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerLiter) => new VolumeConcentration(_value * 1000000000000, VolumeConcentrationUnit.PicolitersPerLiter), + (VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerMililiter) => new VolumeConcentration(_value * 1000000000, VolumeConcentrationUnit.PicolitersPerMililiter), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 3c6413452c..4704b9d0de 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -21,12 +21,10 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if NET7_0_OR_GREATER -using System.Numerics; -#endif using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -58,7 +56,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,10 +95,18 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.CubicYardPerHour, "CubicYardsPerHour", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.CubicYardPerMinute, "CubicYardsPerMinute", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.CubicYardPerSecond, "CubicYardsPerSecond", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.DecaliterPerDay, "DecalitersPerDay", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.DecaliterPerHour, "DecalitersPerHour", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.DecaliterPerMinute, "DecalitersPerMinute", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.DecaliterPerSecond, "DecalitersPerSecond", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.DeciliterPerDay, "DecilitersPerDay", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.DeciliterPerHour, "DecilitersPerHour", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.DeciliterPerMinute, "DecilitersPerMinute", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.DeciliterPerSecond, "DecilitersPerSecond", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.HectoliterPerDay, "HectolitersPerDay", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.HectoliterPerHour, "HectolitersPerHour", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.HectoliterPerMinute, "HectolitersPerMinute", BaseUnits.Undefined, "VolumeFlow"), + new UnitInfo(VolumeFlowUnit.HectoliterPerSecond, "HectolitersPerSecond", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.KiloliterPerDay, "KilolitersPerDay", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.KiloliterPerHour, "KilolitersPerHour", BaseUnits.Undefined, "VolumeFlow"), new UnitInfo(VolumeFlowUnit.KiloliterPerMinute, "KilolitersPerMinute", BaseUnits.Undefined, "VolumeFlow"), @@ -154,7 +160,7 @@ static VolumeFlow() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VolumeFlow(double value, VolumeFlowUnit unit) + public VolumeFlow(QuantityValue value, VolumeFlowUnit unit) { _value = value; _unit = unit; @@ -168,7 +174,7 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlow(double value, UnitSystem unitSystem) + public VolumeFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -219,10 +225,10 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -247,337 +253,377 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); + public QuantityValue AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); /// /// Gets a value of this quantity converted into /// - public double AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); + public QuantityValue AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); /// /// Gets a value of this quantity converted into /// - public double AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); + public QuantityValue AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); /// /// Gets a value of this quantity converted into /// - public double AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); + public QuantityValue AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); + public QuantityValue CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); /// /// Gets a value of this quantity converted into /// - public double CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); + public QuantityValue CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); /// /// Gets a value of this quantity converted into /// - public double CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); + public QuantityValue CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); + public QuantityValue CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); + public QuantityValue CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); + public QuantityValue CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); + public QuantityValue CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); /// /// Gets a value of this quantity converted into /// - public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); + public QuantityValue CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); /// /// Gets a value of this quantity converted into /// - public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); + public QuantityValue CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); + public QuantityValue CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); + public QuantityValue CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); + public QuantityValue CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); + public QuantityValue CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); + public QuantityValue CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); + public QuantityValue CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); + public QuantityValue CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); + public QuantityValue CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + public QuantityValue CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue DecalitersPerDay => As(VolumeFlowUnit.DecaliterPerDay); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue DecalitersPerHour => As(VolumeFlowUnit.DecaliterPerHour); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue DecalitersPerMinute => As(VolumeFlowUnit.DecaliterPerMinute); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue DecalitersPerSecond => As(VolumeFlowUnit.DecaliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); + public QuantityValue DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); + public QuantityValue DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); + public QuantityValue DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + public QuantityValue DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue HectolitersPerDay => As(VolumeFlowUnit.HectoliterPerDay); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue HectolitersPerHour => As(VolumeFlowUnit.HectoliterPerHour); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue HectolitersPerMinute => As(VolumeFlowUnit.HectoliterPerMinute); + + /// + /// Gets a value of this quantity converted into + /// + public QuantityValue HectolitersPerSecond => As(VolumeFlowUnit.HectoliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); + public QuantityValue KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); /// /// Gets a value of this quantity converted into /// - public double KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); + public QuantityValue KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); /// /// Gets a value of this quantity converted into /// - public double KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); + public QuantityValue KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); + public QuantityValue KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); + public QuantityValue KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); /// /// Gets a value of this quantity converted into /// - public double LitersPerDay => As(VolumeFlowUnit.LiterPerDay); + public QuantityValue LitersPerDay => As(VolumeFlowUnit.LiterPerDay); /// /// Gets a value of this quantity converted into /// - public double LitersPerHour => As(VolumeFlowUnit.LiterPerHour); + public QuantityValue LitersPerHour => As(VolumeFlowUnit.LiterPerHour); /// /// Gets a value of this quantity converted into /// - public double LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); + public QuantityValue LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); /// /// Gets a value of this quantity converted into /// - public double LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); + public QuantityValue LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); + public QuantityValue MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); /// /// Gets a value of this quantity converted into /// - public double MegalitersPerHour => As(VolumeFlowUnit.MegaliterPerHour); + public QuantityValue MegalitersPerHour => As(VolumeFlowUnit.MegaliterPerHour); /// /// Gets a value of this quantity converted into /// - public double MegalitersPerMinute => As(VolumeFlowUnit.MegaliterPerMinute); + public QuantityValue MegalitersPerMinute => As(VolumeFlowUnit.MegaliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double MegalitersPerSecond => As(VolumeFlowUnit.MegaliterPerSecond); + public QuantityValue MegalitersPerSecond => As(VolumeFlowUnit.MegaliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegaukGallonsPerDay => As(VolumeFlowUnit.MegaukGallonPerDay); + public QuantityValue MegaukGallonsPerDay => As(VolumeFlowUnit.MegaukGallonPerDay); /// /// Gets a value of this quantity converted into /// - public double MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); + public QuantityValue MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); /// /// Gets a value of this quantity converted into /// - public double MegausGallonsPerDay => As(VolumeFlowUnit.MegausGallonPerDay); + public QuantityValue MegausGallonsPerDay => As(VolumeFlowUnit.MegausGallonPerDay); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); + public QuantityValue MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); + public QuantityValue MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); + public QuantityValue MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); + public QuantityValue MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); + public QuantityValue MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); + public QuantityValue MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); + public QuantityValue MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); + public QuantityValue MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); + public QuantityValue MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); + public QuantityValue NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); + public QuantityValue NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); + public QuantityValue NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); /// /// Gets a value of this quantity converted into /// - public double NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); + public QuantityValue NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); /// /// Gets a value of this quantity converted into /// - public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); + public QuantityValue OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); /// /// Gets a value of this quantity converted into /// - public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); + public QuantityValue OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); /// /// Gets a value of this quantity converted into /// - public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); + public QuantityValue OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); /// /// Gets a value of this quantity converted into /// - public double OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); + public QuantityValue OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); /// /// Gets a value of this quantity converted into /// - public double UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); + public QuantityValue UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); /// /// Gets a value of this quantity converted into /// - public double UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); + public QuantityValue UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); /// /// Gets a value of this quantity converted into /// - public double UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); + public QuantityValue UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); /// /// Gets a value of this quantity converted into /// - public double UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); + public QuantityValue UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); /// /// Gets a value of this quantity converted into /// - public double UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); + public QuantityValue UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); /// /// Gets a value of this quantity converted into /// - public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); + public QuantityValue UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); /// /// Gets a value of this quantity converted into /// - public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); + public QuantityValue UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); /// /// Gets a value of this quantity converted into /// - public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); + public QuantityValue UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); #endregion @@ -611,10 +657,18 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DecaliterPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DecaliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DecaliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DecaliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.HectoliterPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.HectoliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.HectoliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.HectoliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicMeterPerSecond)); @@ -682,10 +736,18 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerHour, quantity => quantity.ToUnit(VolumeFlowUnit.CubicYardPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerMinute, quantity => quantity.ToUnit(VolumeFlowUnit.CubicYardPerMinute)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.CubicYardPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerDay, quantity => quantity.ToUnit(VolumeFlowUnit.DecaliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerHour, quantity => quantity.ToUnit(VolumeFlowUnit.DecaliterPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerMinute, quantity => quantity.ToUnit(VolumeFlowUnit.DecaliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.DecaliterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerDay, quantity => quantity.ToUnit(VolumeFlowUnit.DeciliterPerDay)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerHour, quantity => quantity.ToUnit(VolumeFlowUnit.DeciliterPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerMinute, quantity => quantity.ToUnit(VolumeFlowUnit.DeciliterPerMinute)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.DeciliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerDay, quantity => quantity.ToUnit(VolumeFlowUnit.HectoliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerHour, quantity => quantity.ToUnit(VolumeFlowUnit.HectoliterPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerMinute, quantity => quantity.ToUnit(VolumeFlowUnit.HectoliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerSecond, quantity => quantity.ToUnit(VolumeFlowUnit.HectoliterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerDay, quantity => quantity.ToUnit(VolumeFlowUnit.KiloliterPerDay)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerHour, quantity => quantity.ToUnit(VolumeFlowUnit.KiloliterPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerMinute, quantity => quantity.ToUnit(VolumeFlowUnit.KiloliterPerMinute)); @@ -757,7 +819,7 @@ public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provi /// /// Creates a from . /// - public static VolumeFlow FromAcreFeetPerDay(double value) + public static VolumeFlow FromAcreFeetPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerDay); } @@ -765,7 +827,7 @@ public static VolumeFlow FromAcreFeetPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromAcreFeetPerHour(double value) + public static VolumeFlow FromAcreFeetPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerHour); } @@ -773,7 +835,7 @@ public static VolumeFlow FromAcreFeetPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromAcreFeetPerMinute(double value) + public static VolumeFlow FromAcreFeetPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerMinute); } @@ -781,7 +843,7 @@ public static VolumeFlow FromAcreFeetPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromAcreFeetPerSecond(double value) + public static VolumeFlow FromAcreFeetPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerSecond); } @@ -789,7 +851,7 @@ public static VolumeFlow FromAcreFeetPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromCentilitersPerDay(double value) + public static VolumeFlow FromCentilitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerDay); } @@ -797,7 +859,7 @@ public static VolumeFlow FromCentilitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromCentilitersPerHour(double value) + public static VolumeFlow FromCentilitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerHour); } @@ -805,7 +867,7 @@ public static VolumeFlow FromCentilitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromCentilitersPerMinute(double value) + public static VolumeFlow FromCentilitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerMinute); } @@ -813,7 +875,7 @@ public static VolumeFlow FromCentilitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCentilitersPerSecond(double value) + public static VolumeFlow FromCentilitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerSecond); } @@ -821,7 +883,7 @@ public static VolumeFlow FromCentilitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicCentimetersPerMinute(double value) + public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicCentimeterPerMinute); } @@ -829,7 +891,7 @@ public static VolumeFlow FromCubicCentimetersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicDecimetersPerMinute(double value) + public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute); } @@ -837,7 +899,7 @@ public static VolumeFlow FromCubicDecimetersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicFeetPerHour(double value) + public static VolumeFlow FromCubicFeetPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour); } @@ -845,7 +907,7 @@ public static VolumeFlow FromCubicFeetPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicFeetPerMinute(double value) + public static VolumeFlow FromCubicFeetPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute); } @@ -853,7 +915,7 @@ public static VolumeFlow FromCubicFeetPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicFeetPerSecond(double value) + public static VolumeFlow FromCubicFeetPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond); } @@ -861,7 +923,7 @@ public static VolumeFlow FromCubicFeetPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicMetersPerDay(double value) + public static VolumeFlow FromCubicMetersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerDay); } @@ -869,7 +931,7 @@ public static VolumeFlow FromCubicMetersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicMetersPerHour(double value) + public static VolumeFlow FromCubicMetersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour); } @@ -877,7 +939,7 @@ public static VolumeFlow FromCubicMetersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicMetersPerMinute(double value) + public static VolumeFlow FromCubicMetersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute); } @@ -885,7 +947,7 @@ public static VolumeFlow FromCubicMetersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicMetersPerSecond(double value) + public static VolumeFlow FromCubicMetersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond); } @@ -893,7 +955,7 @@ public static VolumeFlow FromCubicMetersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicMillimetersPerSecond(double value) + public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond); } @@ -901,7 +963,7 @@ public static VolumeFlow FromCubicMillimetersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicYardsPerDay(double value) + public static VolumeFlow FromCubicYardsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerDay); } @@ -909,7 +971,7 @@ public static VolumeFlow FromCubicYardsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicYardsPerHour(double value) + public static VolumeFlow FromCubicYardsPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour); } @@ -917,7 +979,7 @@ public static VolumeFlow FromCubicYardsPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicYardsPerMinute(double value) + public static VolumeFlow FromCubicYardsPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute); } @@ -925,15 +987,47 @@ public static VolumeFlow FromCubicYardsPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromCubicYardsPerSecond(double value) + public static VolumeFlow FromCubicYardsPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond); } + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerDay(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.DecaliterPerDay); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerHour(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.DecaliterPerHour); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerMinute(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.DecaliterPerMinute); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromDecalitersPerSecond(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.DecaliterPerSecond); + } + /// /// Creates a from . /// - public static VolumeFlow FromDecilitersPerDay(double value) + public static VolumeFlow FromDecilitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerDay); } @@ -941,7 +1035,7 @@ public static VolumeFlow FromDecilitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromDecilitersPerHour(double value) + public static VolumeFlow FromDecilitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerHour); } @@ -949,7 +1043,7 @@ public static VolumeFlow FromDecilitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromDecilitersPerMinute(double value) + public static VolumeFlow FromDecilitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerMinute); } @@ -957,15 +1051,47 @@ public static VolumeFlow FromDecilitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromDecilitersPerSecond(double value) + public static VolumeFlow FromDecilitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerSecond); } + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerDay(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.HectoliterPerDay); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerHour(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.HectoliterPerHour); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerMinute(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.HectoliterPerMinute); + } + + /// + /// Creates a from . + /// + public static VolumeFlow FromHectolitersPerSecond(QuantityValue value) + { + return new VolumeFlow(value, VolumeFlowUnit.HectoliterPerSecond); + } + /// /// Creates a from . /// - public static VolumeFlow FromKilolitersPerDay(double value) + public static VolumeFlow FromKilolitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerDay); } @@ -973,7 +1099,7 @@ public static VolumeFlow FromKilolitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromKilolitersPerHour(double value) + public static VolumeFlow FromKilolitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerHour); } @@ -981,7 +1107,7 @@ public static VolumeFlow FromKilolitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromKilolitersPerMinute(double value) + public static VolumeFlow FromKilolitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerMinute); } @@ -989,7 +1115,7 @@ public static VolumeFlow FromKilolitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromKilolitersPerSecond(double value) + public static VolumeFlow FromKilolitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerSecond); } @@ -997,7 +1123,7 @@ public static VolumeFlow FromKilolitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromKilousGallonsPerMinute(double value) + public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.KilousGallonPerMinute); } @@ -1005,7 +1131,7 @@ public static VolumeFlow FromKilousGallonsPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromLitersPerDay(double value) + public static VolumeFlow FromLitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.LiterPerDay); } @@ -1013,7 +1139,7 @@ public static VolumeFlow FromLitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromLitersPerHour(double value) + public static VolumeFlow FromLitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.LiterPerHour); } @@ -1021,7 +1147,7 @@ public static VolumeFlow FromLitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromLitersPerMinute(double value) + public static VolumeFlow FromLitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.LiterPerMinute); } @@ -1029,7 +1155,7 @@ public static VolumeFlow FromLitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromLitersPerSecond(double value) + public static VolumeFlow FromLitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.LiterPerSecond); } @@ -1037,7 +1163,7 @@ public static VolumeFlow FromLitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegalitersPerDay(double value) + public static VolumeFlow FromMegalitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerDay); } @@ -1045,7 +1171,7 @@ public static VolumeFlow FromMegalitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegalitersPerHour(double value) + public static VolumeFlow FromMegalitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerHour); } @@ -1053,7 +1179,7 @@ public static VolumeFlow FromMegalitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegalitersPerMinute(double value) + public static VolumeFlow FromMegalitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerMinute); } @@ -1061,7 +1187,7 @@ public static VolumeFlow FromMegalitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegalitersPerSecond(double value) + public static VolumeFlow FromMegalitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerSecond); } @@ -1069,7 +1195,7 @@ public static VolumeFlow FromMegalitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegaukGallonsPerDay(double value) + public static VolumeFlow FromMegaukGallonsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerDay); } @@ -1077,7 +1203,7 @@ public static VolumeFlow FromMegaukGallonsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegaukGallonsPerSecond(double value) + public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerSecond); } @@ -1085,7 +1211,7 @@ public static VolumeFlow FromMegaukGallonsPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromMegausGallonsPerDay(double value) + public static VolumeFlow FromMegausGallonsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MegausGallonPerDay); } @@ -1093,7 +1219,7 @@ public static VolumeFlow FromMegausGallonsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromMicrolitersPerDay(double value) + public static VolumeFlow FromMicrolitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerDay); } @@ -1101,7 +1227,7 @@ public static VolumeFlow FromMicrolitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromMicrolitersPerHour(double value) + public static VolumeFlow FromMicrolitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerHour); } @@ -1109,7 +1235,7 @@ public static VolumeFlow FromMicrolitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromMicrolitersPerMinute(double value) + public static VolumeFlow FromMicrolitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerMinute); } @@ -1117,7 +1243,7 @@ public static VolumeFlow FromMicrolitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromMicrolitersPerSecond(double value) + public static VolumeFlow FromMicrolitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerSecond); } @@ -1125,7 +1251,7 @@ public static VolumeFlow FromMicrolitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromMillilitersPerDay(double value) + public static VolumeFlow FromMillilitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerDay); } @@ -1133,7 +1259,7 @@ public static VolumeFlow FromMillilitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromMillilitersPerHour(double value) + public static VolumeFlow FromMillilitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerHour); } @@ -1141,7 +1267,7 @@ public static VolumeFlow FromMillilitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromMillilitersPerMinute(double value) + public static VolumeFlow FromMillilitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerMinute); } @@ -1149,7 +1275,7 @@ public static VolumeFlow FromMillilitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromMillilitersPerSecond(double value) + public static VolumeFlow FromMillilitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerSecond); } @@ -1157,7 +1283,7 @@ public static VolumeFlow FromMillilitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromMillionUsGallonsPerDay(double value) + public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonPerDay); } @@ -1165,7 +1291,7 @@ public static VolumeFlow FromMillionUsGallonsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromNanolitersPerDay(double value) + public static VolumeFlow FromNanolitersPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerDay); } @@ -1173,7 +1299,7 @@ public static VolumeFlow FromNanolitersPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromNanolitersPerHour(double value) + public static VolumeFlow FromNanolitersPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerHour); } @@ -1181,7 +1307,7 @@ public static VolumeFlow FromNanolitersPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromNanolitersPerMinute(double value) + public static VolumeFlow FromNanolitersPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerMinute); } @@ -1189,7 +1315,7 @@ public static VolumeFlow FromNanolitersPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromNanolitersPerSecond(double value) + public static VolumeFlow FromNanolitersPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerSecond); } @@ -1197,7 +1323,7 @@ public static VolumeFlow FromNanolitersPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromOilBarrelsPerDay(double value) + public static VolumeFlow FromOilBarrelsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerDay); } @@ -1205,7 +1331,7 @@ public static VolumeFlow FromOilBarrelsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromOilBarrelsPerHour(double value) + public static VolumeFlow FromOilBarrelsPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerHour); } @@ -1213,7 +1339,7 @@ public static VolumeFlow FromOilBarrelsPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromOilBarrelsPerMinute(double value) + public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerMinute); } @@ -1221,7 +1347,7 @@ public static VolumeFlow FromOilBarrelsPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromOilBarrelsPerSecond(double value) + public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerSecond); } @@ -1229,7 +1355,7 @@ public static VolumeFlow FromOilBarrelsPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromUkGallonsPerDay(double value) + public static VolumeFlow FromUkGallonsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerDay); } @@ -1237,7 +1363,7 @@ public static VolumeFlow FromUkGallonsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromUkGallonsPerHour(double value) + public static VolumeFlow FromUkGallonsPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerHour); } @@ -1245,7 +1371,7 @@ public static VolumeFlow FromUkGallonsPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromUkGallonsPerMinute(double value) + public static VolumeFlow FromUkGallonsPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerMinute); } @@ -1253,7 +1379,7 @@ public static VolumeFlow FromUkGallonsPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromUkGallonsPerSecond(double value) + public static VolumeFlow FromUkGallonsPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerSecond); } @@ -1261,7 +1387,7 @@ public static VolumeFlow FromUkGallonsPerSecond(double value) /// /// Creates a from . /// - public static VolumeFlow FromUsGallonsPerDay(double value) + public static VolumeFlow FromUsGallonsPerDay(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerDay); } @@ -1269,7 +1395,7 @@ public static VolumeFlow FromUsGallonsPerDay(double value) /// /// Creates a from . /// - public static VolumeFlow FromUsGallonsPerHour(double value) + public static VolumeFlow FromUsGallonsPerHour(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerHour); } @@ -1277,7 +1403,7 @@ public static VolumeFlow FromUsGallonsPerHour(double value) /// /// Creates a from . /// - public static VolumeFlow FromUsGallonsPerMinute(double value) + public static VolumeFlow FromUsGallonsPerMinute(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerMinute); } @@ -1285,7 +1411,7 @@ public static VolumeFlow FromUsGallonsPerMinute(double value) /// /// Creates a from . /// - public static VolumeFlow FromUsGallonsPerSecond(double value) + public static VolumeFlow FromUsGallonsPerSecond(QuantityValue value) { return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerSecond); } @@ -1296,7 +1422,7 @@ public static VolumeFlow FromUsGallonsPerSecond(double value) /// Value to convert from. /// Unit to convert from. /// VolumeFlow unit value. - public static VolumeFlow From(double value, VolumeFlowUnit fromUnit) + public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit) { return new VolumeFlow(value, fromUnit); } @@ -1468,25 +1594,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlow operator *(double left, VolumeFlow right) + public static VolumeFlow operator *(QuantityValue left, VolumeFlow right) { return new VolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlow operator *(VolumeFlow left, double right) + public static VolumeFlow operator *(VolumeFlow left, QuantityValue right) { return new VolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlow operator /(VolumeFlow left, double right) + public static VolumeFlow operator /(VolumeFlow left, QuantityValue right) { return new VolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeFlow left, VolumeFlow right) + public static QuantityValue operator /(VolumeFlow left, VolumeFlow right) { return left.CubicMetersPerSecond / right.CubicMetersPerSecond; } @@ -1553,27 +1679,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VolumeFlow left, VolumeFlow right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlow other, VolumeFlow tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VolumeFlow left, VolumeFlow right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeFlow otherQuantity)) @@ -1583,15 +1702,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VolumeFlow other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -1674,10 +1790,10 @@ public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -1694,7 +1810,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeFlow other, VolumeFlow tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -1707,7 +1823,12 @@ public bool Equals(VolumeFlow other, VolumeFlow tolerance) /// A hash code for the current VolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -1718,7 +1839,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowUnit unit) + public QuantityValue As(VolumeFlowUnit unit) { if (Unit == unit) return Value; @@ -1727,7 +1848,7 @@ public double As(VolumeFlowUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1742,7 +1863,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); @@ -1808,140 +1929,156 @@ private bool TryToUnit(VolumeFlowUnit unit, [NotNullWhen(true)] out VolumeFlow? VolumeFlow? convertedOrNull = (Unit, unit) switch { // VolumeFlowUnit -> BaseUnit - (VolumeFlowUnit.AcreFootPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 70.0457, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.AcreFootPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 2.91857, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.AcreFootPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 0.0486427916, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.AcreFootPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 0.000810713194, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CentiliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e-2d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CentiliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e-2d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CentiliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e-2d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CentiliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e-2d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 1.6666666666667e-8, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000.00000, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicFootPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 7.8657907199999087346816086183876e-6, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicFootPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 2118.88000326, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicFootPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 35.314666721, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.AcreFootPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(10000, 700457, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.AcreFootPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(100000, 291857, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.AcreFootPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(2500000000, 121606979, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.AcreFootPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(500000000000, 405356597, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CentiliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 8640000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CentiliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 360000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CentiliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 6000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CentiliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 100000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(16666666666667, 100, false) / BigInteger.Pow(10, 19), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicFootPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(6145149, 781250000000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicFootPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(18435447, 39062500000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicFootPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(55306341, 1953125000, false), VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.CubicMeterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400, VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.CubicMeterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600, VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.CubicMeterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 1e-9, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 1000000000, VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.CubicYardPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 113007, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicYardPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 2.1237634944E-4, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicYardPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 0.0127425809664, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.CubicYardPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 0.764554857984, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.DeciliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e-1d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.DeciliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e-1d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.DeciliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e-1d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.DeciliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e-1d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.KiloliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.KiloliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.KiloliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.KiloliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.KilousGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 15.850323141489, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicYardPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(165919023, 781250000000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicYardPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(497757069, 39062500000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.CubicYardPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1493271207, 1953125000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DecaliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 8640000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DecaliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 360000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DecaliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 6000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DecaliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 100, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DeciliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 864000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DeciliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 36000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DeciliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 600000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.DeciliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 10000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.HectoliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 864000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.HectoliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 36000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.HectoliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 600, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.HectoliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 10, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.KiloliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.KiloliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.KiloliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.KiloliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.KilousGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000000000000, 15850323141489, false), VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.LiterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400000, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.LiterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600000.000, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.LiterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000.00000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.LiterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.LiterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000, VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.LiterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 1000, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaukGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 19005304) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 219.969) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MegausGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 22824465.227) * 1e6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MicroliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e-6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MicroliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e-6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MicroliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e-6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MicroliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e-6d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MilliliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MilliliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MilliliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MilliliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.MillionUsGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 22.824465227, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.NanoliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 86400000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.NanoliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 3600000.000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.NanoliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 60000.00000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.NanoliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow((_value / 1000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.OilBarrelPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 1.8401307283333333333333333333333e-6, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.OilBarrelPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 4.41631375e-5, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.OilBarrelPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 2.64978825e-3, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.OilBarrelPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 6.28981, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(5, 432, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(5, 18, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(50, 3, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 1000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaukGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(125000, 2375663, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000000000, 219969, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MegausGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000000000, 22824465227, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MicroliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MicroliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MicroliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MicroliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 1000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MilliliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MilliliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MilliliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MilliliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 1000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.MillionUsGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000000000, 22824465227, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.NanoliterPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 86400000000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.NanoliterPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 3600000000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.NanoliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 60000000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.NanoliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 1000000000000, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.OilBarrelPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * 18401307283333 / BigInteger.Pow(10, 19), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.OilBarrelPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(3533051, 80000000000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.OilBarrelPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(10599153, 4000000000, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.OilBarrelPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(100000, 628981, false), VolumeFlowUnit.CubicMeterPerSecond), (VolumeFlowUnit.UkGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 19005304, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UkGallonPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 791887.667, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UkGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 13198.2, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UkGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 219.969, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UsGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 22824465.227, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UsGallonPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 951019.38848933424, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UsGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 15850.323141489, VolumeFlowUnit.CubicMeterPerSecond), - (VolumeFlowUnit.UsGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value / 264.1720523581484, VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UkGallonPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000, 791887667, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UkGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(5, 65991, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UkGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000, 219969, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UsGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000, 22824465227, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UsGallonPerHour, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(6250000000, 5943871178058339, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UsGallonPerMinute, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(1000000000, 15850323141489, false), VolumeFlowUnit.CubicMeterPerSecond), + (VolumeFlowUnit.UsGallonPerSecond, VolumeFlowUnit.CubicMeterPerSecond) => new VolumeFlow(_value * new QuantityValue(2500000000000, 660430130895371, false), VolumeFlowUnit.CubicMeterPerSecond), // BaseUnit -> VolumeFlowUnit - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerDay) => new VolumeFlow(_value * 70.0457, VolumeFlowUnit.AcreFootPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerHour) => new VolumeFlow(_value * 2.91857, VolumeFlowUnit.AcreFootPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerMinute) => new VolumeFlow(_value * 0.0486427916, VolumeFlowUnit.AcreFootPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerSecond) => new VolumeFlow(_value * 0.000810713194, VolumeFlowUnit.AcreFootPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerDay) => new VolumeFlow((_value * 86400000) / 1e-2d, VolumeFlowUnit.CentiliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e-2d, VolumeFlowUnit.CentiliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e-2d, VolumeFlowUnit.CentiliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerSecond) => new VolumeFlow((_value * 1000) / 1e-2d, VolumeFlowUnit.CentiliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicCentimeterPerMinute) => new VolumeFlow(_value / 1.6666666666667e-8, VolumeFlowUnit.CubicCentimeterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicDecimeterPerMinute) => new VolumeFlow(_value * 60000.00000, VolumeFlowUnit.CubicDecimeterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerHour) => new VolumeFlow(_value / 7.8657907199999087346816086183876e-6, VolumeFlowUnit.CubicFootPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerMinute) => new VolumeFlow(_value * 2118.88000326, VolumeFlowUnit.CubicFootPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerSecond) => new VolumeFlow(_value * 35.314666721, VolumeFlowUnit.CubicFootPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerDay) => new VolumeFlow(_value * new QuantityValue(700457, 10000, false), VolumeFlowUnit.AcreFootPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerHour) => new VolumeFlow(_value * new QuantityValue(291857, 100000, false), VolumeFlowUnit.AcreFootPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerMinute) => new VolumeFlow(_value * new QuantityValue(121606979, 2500000000, false), VolumeFlowUnit.AcreFootPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.AcreFootPerSecond) => new VolumeFlow(_value * new QuantityValue(405356597, 500000000000, false), VolumeFlowUnit.AcreFootPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerDay) => new VolumeFlow(_value * 8640000000, VolumeFlowUnit.CentiliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerHour) => new VolumeFlow(_value * 360000000, VolumeFlowUnit.CentiliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerMinute) => new VolumeFlow(_value * 6000000, VolumeFlowUnit.CentiliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CentiliterPerSecond) => new VolumeFlow(_value * 100000, VolumeFlowUnit.CentiliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicCentimeterPerMinute) => new VolumeFlow(_value * new QuantityValue(100, 16666666666667, false) * BigInteger.Pow(10, 19), VolumeFlowUnit.CubicCentimeterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicDecimeterPerMinute) => new VolumeFlow(_value * 60000, VolumeFlowUnit.CubicDecimeterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerHour) => new VolumeFlow(_value * new QuantityValue(781250000000, 6145149, false), VolumeFlowUnit.CubicFootPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerMinute) => new VolumeFlow(_value * new QuantityValue(39062500000, 18435447, false), VolumeFlowUnit.CubicFootPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicFootPerSecond) => new VolumeFlow(_value * new QuantityValue(1953125000, 55306341, false), VolumeFlowUnit.CubicFootPerSecond), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMeterPerDay) => new VolumeFlow(_value * 86400, VolumeFlowUnit.CubicMeterPerDay), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMeterPerHour) => new VolumeFlow(_value * 3600, VolumeFlowUnit.CubicMeterPerHour), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMeterPerMinute) => new VolumeFlow(_value * 60, VolumeFlowUnit.CubicMeterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMillimeterPerSecond) => new VolumeFlow(_value / 1e-9, VolumeFlowUnit.CubicMillimeterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMillimeterPerSecond) => new VolumeFlow(_value * 1000000000, VolumeFlowUnit.CubicMillimeterPerSecond), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerDay) => new VolumeFlow(_value * 113007, VolumeFlowUnit.CubicYardPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerHour) => new VolumeFlow(_value / 2.1237634944E-4, VolumeFlowUnit.CubicYardPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerMinute) => new VolumeFlow(_value / 0.0127425809664, VolumeFlowUnit.CubicYardPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerSecond) => new VolumeFlow(_value / 0.764554857984, VolumeFlowUnit.CubicYardPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerDay) => new VolumeFlow((_value * 86400000) / 1e-1d, VolumeFlowUnit.DeciliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e-1d, VolumeFlowUnit.DeciliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e-1d, VolumeFlowUnit.DeciliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerSecond) => new VolumeFlow((_value * 1000) / 1e-1d, VolumeFlowUnit.DeciliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerDay) => new VolumeFlow((_value * 86400000) / 1e3d, VolumeFlowUnit.KiloliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e3d, VolumeFlowUnit.KiloliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e3d, VolumeFlowUnit.KiloliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerSecond) => new VolumeFlow((_value * 1000) / 1e3d, VolumeFlowUnit.KiloliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KilousGallonPerMinute) => new VolumeFlow(_value * 15.850323141489, VolumeFlowUnit.KilousGallonPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerHour) => new VolumeFlow(_value * new QuantityValue(781250000000, 165919023, false), VolumeFlowUnit.CubicYardPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerMinute) => new VolumeFlow(_value * new QuantityValue(39062500000, 497757069, false), VolumeFlowUnit.CubicYardPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicYardPerSecond) => new VolumeFlow(_value * new QuantityValue(1953125000, 1493271207, false), VolumeFlowUnit.CubicYardPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerDay) => new VolumeFlow(_value * 8640000, VolumeFlowUnit.DecaliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerHour) => new VolumeFlow(_value * 360000, VolumeFlowUnit.DecaliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerMinute) => new VolumeFlow(_value * 6000, VolumeFlowUnit.DecaliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DecaliterPerSecond) => new VolumeFlow(_value * 100, VolumeFlowUnit.DecaliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerDay) => new VolumeFlow(_value * 864000000, VolumeFlowUnit.DeciliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerHour) => new VolumeFlow(_value * 36000000, VolumeFlowUnit.DeciliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerMinute) => new VolumeFlow(_value * 600000, VolumeFlowUnit.DeciliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.DeciliterPerSecond) => new VolumeFlow(_value * 10000, VolumeFlowUnit.DeciliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerDay) => new VolumeFlow(_value * 864000, VolumeFlowUnit.HectoliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerHour) => new VolumeFlow(_value * 36000, VolumeFlowUnit.HectoliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerMinute) => new VolumeFlow(_value * 600, VolumeFlowUnit.HectoliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.HectoliterPerSecond) => new VolumeFlow(_value * 10, VolumeFlowUnit.HectoliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerDay) => new VolumeFlow(_value * 86400, VolumeFlowUnit.KiloliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerHour) => new VolumeFlow(_value * 3600, VolumeFlowUnit.KiloliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerMinute) => new VolumeFlow(_value * 60, VolumeFlowUnit.KiloliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KiloliterPerSecond) => new VolumeFlow(_value, VolumeFlowUnit.KiloliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.KilousGallonPerMinute) => new VolumeFlow(_value * new QuantityValue(15850323141489, 1000000000000, false), VolumeFlowUnit.KilousGallonPerMinute), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerDay) => new VolumeFlow(_value * 86400000, VolumeFlowUnit.LiterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerHour) => new VolumeFlow(_value * 3600000.000, VolumeFlowUnit.LiterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerMinute) => new VolumeFlow(_value * 60000.00000, VolumeFlowUnit.LiterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerHour) => new VolumeFlow(_value * 3600000, VolumeFlowUnit.LiterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerMinute) => new VolumeFlow(_value * 60000, VolumeFlowUnit.LiterPerMinute), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.LiterPerSecond) => new VolumeFlow(_value * 1000, VolumeFlowUnit.LiterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerDay) => new VolumeFlow((_value * 86400000) / 1e6d, VolumeFlowUnit.MegaliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e6d, VolumeFlowUnit.MegaliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e6d, VolumeFlowUnit.MegaliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerSecond) => new VolumeFlow((_value * 1000) / 1e6d, VolumeFlowUnit.MegaliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaukGallonPerDay) => new VolumeFlow((_value * 19005304) / 1e6d, VolumeFlowUnit.MegaukGallonPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaukGallonPerSecond) => new VolumeFlow((_value * 219.969) / 1e6d, VolumeFlowUnit.MegaukGallonPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegausGallonPerDay) => new VolumeFlow((_value * 22824465.227) / 1e6d, VolumeFlowUnit.MegausGallonPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerDay) => new VolumeFlow((_value * 86400000) / 1e-6d, VolumeFlowUnit.MicroliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e-6d, VolumeFlowUnit.MicroliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e-6d, VolumeFlowUnit.MicroliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerSecond) => new VolumeFlow((_value * 1000) / 1e-6d, VolumeFlowUnit.MicroliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerDay) => new VolumeFlow((_value * 86400000) / 1e-3d, VolumeFlowUnit.MilliliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e-3d, VolumeFlowUnit.MilliliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e-3d, VolumeFlowUnit.MilliliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerSecond) => new VolumeFlow((_value * 1000) / 1e-3d, VolumeFlowUnit.MilliliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MillionUsGallonPerDay) => new VolumeFlow(_value * 22.824465227, VolumeFlowUnit.MillionUsGallonPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerDay) => new VolumeFlow((_value * 86400000) / 1e-9d, VolumeFlowUnit.NanoliterPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerHour) => new VolumeFlow((_value * 3600000.000) / 1e-9d, VolumeFlowUnit.NanoliterPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerMinute) => new VolumeFlow((_value * 60000.00000) / 1e-9d, VolumeFlowUnit.NanoliterPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerSecond) => new VolumeFlow((_value * 1000) / 1e-9d, VolumeFlowUnit.NanoliterPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerDay) => new VolumeFlow(_value / 1.8401307283333333333333333333333e-6, VolumeFlowUnit.OilBarrelPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerHour) => new VolumeFlow(_value / 4.41631375e-5, VolumeFlowUnit.OilBarrelPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerMinute) => new VolumeFlow(_value / 2.64978825e-3, VolumeFlowUnit.OilBarrelPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerSecond) => new VolumeFlow(_value * 6.28981, VolumeFlowUnit.OilBarrelPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerDay) => new VolumeFlow(_value * new QuantityValue(432, 5, false), VolumeFlowUnit.MegaliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerHour) => new VolumeFlow(_value * new QuantityValue(18, 5, false), VolumeFlowUnit.MegaliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerMinute) => new VolumeFlow(_value * new QuantityValue(3, 50, false), VolumeFlowUnit.MegaliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaliterPerSecond) => new VolumeFlow(_value / 1000, VolumeFlowUnit.MegaliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaukGallonPerDay) => new VolumeFlow(_value * new QuantityValue(2375663, 125000, false), VolumeFlowUnit.MegaukGallonPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegaukGallonPerSecond) => new VolumeFlow(_value * new QuantityValue(219969, 1000000000, false), VolumeFlowUnit.MegaukGallonPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MegausGallonPerDay) => new VolumeFlow(_value * new QuantityValue(22824465227, 1000000000, false), VolumeFlowUnit.MegausGallonPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerDay) => new VolumeFlow(_value * 86400000000000, VolumeFlowUnit.MicroliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerHour) => new VolumeFlow(_value * 3600000000000, VolumeFlowUnit.MicroliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerMinute) => new VolumeFlow(_value * 60000000000, VolumeFlowUnit.MicroliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MicroliterPerSecond) => new VolumeFlow(_value * 1000000000, VolumeFlowUnit.MicroliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerDay) => new VolumeFlow(_value * 86400000000, VolumeFlowUnit.MilliliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerHour) => new VolumeFlow(_value * 3600000000, VolumeFlowUnit.MilliliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerMinute) => new VolumeFlow(_value * 60000000, VolumeFlowUnit.MilliliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerSecond) => new VolumeFlow(_value * 1000000, VolumeFlowUnit.MilliliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MillionUsGallonPerDay) => new VolumeFlow(_value * new QuantityValue(22824465227, 1000000000, false), VolumeFlowUnit.MillionUsGallonPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerDay) => new VolumeFlow(_value * 86400000000000000, VolumeFlowUnit.NanoliterPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerHour) => new VolumeFlow(_value * 3600000000000000, VolumeFlowUnit.NanoliterPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerMinute) => new VolumeFlow(_value * 60000000000000, VolumeFlowUnit.NanoliterPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerSecond) => new VolumeFlow(_value * 1000000000000, VolumeFlowUnit.NanoliterPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerDay) => new VolumeFlow(_value / 18401307283333 * BigInteger.Pow(10, 19), VolumeFlowUnit.OilBarrelPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerHour) => new VolumeFlow(_value * new QuantityValue(80000000000, 3533051, false), VolumeFlowUnit.OilBarrelPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerMinute) => new VolumeFlow(_value * new QuantityValue(4000000000, 10599153, false), VolumeFlowUnit.OilBarrelPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.OilBarrelPerSecond) => new VolumeFlow(_value * new QuantityValue(628981, 100000, false), VolumeFlowUnit.OilBarrelPerSecond), (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerDay) => new VolumeFlow(_value * 19005304, VolumeFlowUnit.UkGallonPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerHour) => new VolumeFlow(_value * 791887.667, VolumeFlowUnit.UkGallonPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerMinute) => new VolumeFlow(_value * 13198.2, VolumeFlowUnit.UkGallonPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerSecond) => new VolumeFlow(_value * 219.969, VolumeFlowUnit.UkGallonPerSecond), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerDay) => new VolumeFlow(_value * 22824465.227, VolumeFlowUnit.UsGallonPerDay), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerHour) => new VolumeFlow(_value * 951019.38848933424, VolumeFlowUnit.UsGallonPerHour), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerMinute) => new VolumeFlow(_value * 15850.323141489, VolumeFlowUnit.UsGallonPerMinute), - (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerSecond) => new VolumeFlow(_value * 264.1720523581484, VolumeFlowUnit.UsGallonPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerHour) => new VolumeFlow(_value * new QuantityValue(791887667, 1000, false), VolumeFlowUnit.UkGallonPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerMinute) => new VolumeFlow(_value * new QuantityValue(65991, 5, false), VolumeFlowUnit.UkGallonPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UkGallonPerSecond) => new VolumeFlow(_value * new QuantityValue(219969, 1000, false), VolumeFlowUnit.UkGallonPerSecond), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerDay) => new VolumeFlow(_value * new QuantityValue(22824465227, 1000, false), VolumeFlowUnit.UsGallonPerDay), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerHour) => new VolumeFlow(_value * new QuantityValue(5943871178058339, 6250000000, false), VolumeFlowUnit.UsGallonPerHour), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerMinute) => new VolumeFlow(_value * new QuantityValue(15850323141489, 1000000000, false), VolumeFlowUnit.UsGallonPerMinute), + (VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerSecond) => new VolumeFlow(_value * new QuantityValue(660430130895371, 2500000000000, false), VolumeFlowUnit.UsGallonPerSecond), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index e8c36f6ba9..695315b5b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,7 +80,7 @@ static VolumeFlowPerArea() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) + public VolumeFlowPerArea(QuantityValue value, VolumeFlowPerAreaUnit unit) { _value = value; _unit = unit; @@ -93,7 +94,7 @@ public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlowPerArea(double value, UnitSystem unitSystem) + public VolumeFlowPerArea(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -144,10 +145,10 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -172,12 +173,12 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); + public QuantityValue CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); + public QuantityValue CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); #endregion @@ -227,7 +228,7 @@ public static string GetAbbreviation(VolumeFlowPerAreaUnit unit, IFormatProvider /// /// Creates a from . /// - public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(double value) + public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(QuantityValue value) { return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); } @@ -235,7 +236,7 @@ public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(double value /// /// Creates a from . /// - public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(double value) + public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(QuantityValue value) { return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); } @@ -246,7 +247,7 @@ public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(double va /// Value to convert from. /// Unit to convert from. /// VolumeFlowPerArea unit value. - public static VolumeFlowPerArea From(double value, VolumeFlowPerAreaUnit fromUnit) + public static VolumeFlowPerArea From(QuantityValue value, VolumeFlowPerAreaUnit fromUnit) { return new VolumeFlowPerArea(value, fromUnit); } @@ -418,25 +419,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(double left, VolumeFlowPerArea right) + public static VolumeFlowPerArea operator *(QuantityValue left, VolumeFlowPerArea right) { return new VolumeFlowPerArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, double right) + public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, QuantityValue right) { return new VolumeFlowPerArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, double right) + public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, QuantityValue right) { return new VolumeFlowPerArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) + public static QuantityValue operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) { return left.CubicMetersPerSecondPerSquareMeter / right.CubicMetersPerSecondPerSquareMeter; } @@ -469,27 +470,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VolumeFlowPerArea left, VolumeFlowPerArea right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VolumeFlowPerArea left, VolumeFlowPerArea right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VolumeFlowPerArea otherQuantity)) @@ -499,15 +493,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VolumeFlowPerArea other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -590,10 +581,10 @@ public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -610,7 +601,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -623,7 +614,12 @@ public bool Equals(VolumeFlowPerArea other, VolumeFlowPerArea tolerance) /// A hash code for the current VolumeFlowPerArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -634,7 +630,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowPerAreaUnit unit) + public QuantityValue As(VolumeFlowPerAreaUnit unit) { if (Unit == unit) return Value; @@ -643,7 +639,7 @@ public double As(VolumeFlowPerAreaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,7 +654,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); @@ -724,10 +720,10 @@ private bool TryToUnit(VolumeFlowPerAreaUnit unit, [NotNullWhen(true)] out Volum VolumeFlowPerArea? convertedOrNull = (Unit, unit) switch { // VolumeFlowPerAreaUnit -> BaseUnit - (VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter) => new VolumeFlowPerArea(_value / 196.850394, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter), + (VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter) => new VolumeFlowPerArea(_value * new QuantityValue(500000, 98425197, false), VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter), // BaseUnit -> VolumeFlowPerAreaUnit - (VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot) => new VolumeFlowPerArea(_value * 196.850394, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot), + (VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot) => new VolumeFlowPerArea(_value * new QuantityValue(98425197, 500000, false), VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 4f6897a1c5..ce6ebe8f15 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,7 +87,7 @@ static VolumePerLength() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VolumePerLength(double value, VolumePerLengthUnit unit) + public VolumePerLength(QuantityValue value, VolumePerLengthUnit unit) { _value = value; _unit = unit; @@ -100,7 +101,7 @@ public VolumePerLength(double value, VolumePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumePerLength(double value, UnitSystem unitSystem) + public VolumePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -151,10 +152,10 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,47 +180,47 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); + public QuantityValue CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); + public QuantityValue CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); /// /// Gets a value of this quantity converted into /// - public double CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + public QuantityValue CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); /// /// Gets a value of this quantity converted into /// - public double ImperialGallonsPerMile => As(VolumePerLengthUnit.ImperialGallonPerMile); + public QuantityValue ImperialGallonsPerMile => As(VolumePerLengthUnit.ImperialGallonPerMile); /// /// Gets a value of this quantity converted into /// - public double LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); + public QuantityValue LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); /// /// Gets a value of this quantity converted into /// - public double LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); + public QuantityValue LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); /// /// Gets a value of this quantity converted into /// - public double LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); + public QuantityValue LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); /// /// Gets a value of this quantity converted into /// - public double OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); + public QuantityValue OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); /// /// Gets a value of this quantity converted into /// - public double UsGallonsPerMile => As(VolumePerLengthUnit.UsGallonPerMile); + public QuantityValue UsGallonsPerMile => As(VolumePerLengthUnit.UsGallonPerMile); #endregion @@ -283,7 +284,7 @@ public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? /// /// Creates a from . /// - public static VolumePerLength FromCubicMetersPerMeter(double value) + public static VolumePerLength FromCubicMetersPerMeter(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.CubicMeterPerMeter); } @@ -291,7 +292,7 @@ public static VolumePerLength FromCubicMetersPerMeter(double value) /// /// Creates a from . /// - public static VolumePerLength FromCubicYardsPerFoot(double value) + public static VolumePerLength FromCubicYardsPerFoot(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerFoot); } @@ -299,7 +300,7 @@ public static VolumePerLength FromCubicYardsPerFoot(double value) /// /// Creates a from . /// - public static VolumePerLength FromCubicYardsPerUsSurveyFoot(double value) + public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); } @@ -307,7 +308,7 @@ public static VolumePerLength FromCubicYardsPerUsSurveyFoot(double value) /// /// Creates a from . /// - public static VolumePerLength FromImperialGallonsPerMile(double value) + public static VolumePerLength FromImperialGallonsPerMile(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.ImperialGallonPerMile); } @@ -315,7 +316,7 @@ public static VolumePerLength FromImperialGallonsPerMile(double value) /// /// Creates a from . /// - public static VolumePerLength FromLitersPerKilometer(double value) + public static VolumePerLength FromLitersPerKilometer(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.LiterPerKilometer); } @@ -323,7 +324,7 @@ public static VolumePerLength FromLitersPerKilometer(double value) /// /// Creates a from . /// - public static VolumePerLength FromLitersPerMeter(double value) + public static VolumePerLength FromLitersPerMeter(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMeter); } @@ -331,7 +332,7 @@ public static VolumePerLength FromLitersPerMeter(double value) /// /// Creates a from . /// - public static VolumePerLength FromLitersPerMillimeter(double value) + public static VolumePerLength FromLitersPerMillimeter(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMillimeter); } @@ -339,7 +340,7 @@ public static VolumePerLength FromLitersPerMillimeter(double value) /// /// Creates a from . /// - public static VolumePerLength FromOilBarrelsPerFoot(double value) + public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.OilBarrelPerFoot); } @@ -347,7 +348,7 @@ public static VolumePerLength FromOilBarrelsPerFoot(double value) /// /// Creates a from . /// - public static VolumePerLength FromUsGallonsPerMile(double value) + public static VolumePerLength FromUsGallonsPerMile(QuantityValue value) { return new VolumePerLength(value, VolumePerLengthUnit.UsGallonPerMile); } @@ -358,7 +359,7 @@ public static VolumePerLength FromUsGallonsPerMile(double value) /// Value to convert from. /// Unit to convert from. /// VolumePerLength unit value. - public static VolumePerLength From(double value, VolumePerLengthUnit fromUnit) + public static VolumePerLength From(QuantityValue value, VolumePerLengthUnit fromUnit) { return new VolumePerLength(value, fromUnit); } @@ -530,25 +531,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumePerLength operator *(double left, VolumePerLength right) + public static VolumePerLength operator *(QuantityValue left, VolumePerLength right) { return new VolumePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumePerLength operator *(VolumePerLength left, double right) + public static VolumePerLength operator *(VolumePerLength left, QuantityValue right) { return new VolumePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumePerLength operator /(VolumePerLength left, double right) + public static VolumePerLength operator /(VolumePerLength left, QuantityValue right) { return new VolumePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumePerLength left, VolumePerLength right) + public static QuantityValue operator /(VolumePerLength left, VolumePerLength right) { return left.CubicMetersPerMeter / right.CubicMetersPerMeter; } @@ -581,27 +582,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VolumePerLength left, VolumePerLength right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumePerLength other, VolumePerLength tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VolumePerLength left, VolumePerLength right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VolumePerLength otherQuantity)) @@ -611,15 +605,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VolumePerLength other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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,10 +693,10 @@ public bool Equals(VolumePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -722,7 +713,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumePerLength other, VolumePerLength tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -735,7 +726,12 @@ public bool Equals(VolumePerLength other, VolumePerLength tolerance) /// A hash code for the current VolumePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -746,7 +742,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumePerLengthUnit unit) + public QuantityValue As(VolumePerLengthUnit unit) { if (Unit == unit) return Value; @@ -755,7 +751,7 @@ public double As(VolumePerLengthUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -770,7 +766,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); @@ -836,24 +832,24 @@ private bool TryToUnit(VolumePerLengthUnit unit, [NotNullWhen(true)] out VolumeP VolumePerLength? convertedOrNull = (Unit, unit) switch { // VolumePerLengthUnit -> BaseUnit - (VolumePerLengthUnit.CubicYardPerFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * 2.50838208, VolumePerLengthUnit.CubicMeterPerMeter), - (VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * 2.50837706323584, VolumePerLengthUnit.CubicMeterPerMeter), - (VolumePerLengthUnit.ImperialGallonPerMile, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / (1000 * 1609.344 / 4.54609), VolumePerLengthUnit.CubicMeterPerMeter), - (VolumePerLengthUnit.LiterPerKilometer, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / 1e6, VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.CubicYardPerFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * new QuantityValue(3919347, 1562500, false), VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * new QuantityValue(1959669580653, 781250000000, false), VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.ImperialGallonPerMile, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * new QuantityValue(454609, 160934400000, false), VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.LiterPerKilometer, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / 1000000, VolumePerLengthUnit.CubicMeterPerMeter), (VolumePerLengthUnit.LiterPerMeter, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / 1000, VolumePerLengthUnit.CubicMeterPerMeter), (VolumePerLengthUnit.LiterPerMillimeter, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value, VolumePerLengthUnit.CubicMeterPerMeter), - (VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / 1.91713408, VolumePerLengthUnit.CubicMeterPerMeter), - (VolumePerLengthUnit.UsGallonPerMile, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value / (1000 * 1609.344 / 3.785411784), VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * new QuantityValue(781250, 1497761, false), VolumePerLengthUnit.CubicMeterPerMeter), + (VolumePerLengthUnit.UsGallonPerMile, VolumePerLengthUnit.CubicMeterPerMeter) => new VolumePerLength(_value * new QuantityValue(112903, 48000000000, false), VolumePerLengthUnit.CubicMeterPerMeter), // BaseUnit -> VolumePerLengthUnit - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.CubicYardPerFoot) => new VolumePerLength(_value / 2.50838208, VolumePerLengthUnit.CubicYardPerFoot), - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.CubicYardPerUsSurveyFoot) => new VolumePerLength(_value / 2.50837706323584, VolumePerLengthUnit.CubicYardPerUsSurveyFoot), - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.ImperialGallonPerMile) => new VolumePerLength(_value * (1000 * 1609.344 / 4.54609), VolumePerLengthUnit.ImperialGallonPerMile), - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerKilometer) => new VolumePerLength(_value * 1e6, VolumePerLengthUnit.LiterPerKilometer), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.CubicYardPerFoot) => new VolumePerLength(_value * new QuantityValue(1562500, 3919347, false), VolumePerLengthUnit.CubicYardPerFoot), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.CubicYardPerUsSurveyFoot) => new VolumePerLength(_value * new QuantityValue(781250000000, 1959669580653, false), VolumePerLengthUnit.CubicYardPerUsSurveyFoot), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.ImperialGallonPerMile) => new VolumePerLength(_value * new QuantityValue(160934400000, 454609, false), VolumePerLengthUnit.ImperialGallonPerMile), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerKilometer) => new VolumePerLength(_value * 1000000, VolumePerLengthUnit.LiterPerKilometer), (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerMeter) => new VolumePerLength(_value * 1000, VolumePerLengthUnit.LiterPerMeter), (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerMillimeter) => new VolumePerLength(_value, VolumePerLengthUnit.LiterPerMillimeter), - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.OilBarrelPerFoot) => new VolumePerLength(_value * 1.91713408, VolumePerLengthUnit.OilBarrelPerFoot), - (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.UsGallonPerMile) => new VolumePerLength(_value * (1000 * 1609.344 / 3.785411784), VolumePerLengthUnit.UsGallonPerMile), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.OilBarrelPerFoot) => new VolumePerLength(_value * new QuantityValue(1497761, 781250, false), VolumePerLengthUnit.OilBarrelPerFoot), + (VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.UsGallonPerMile) => new VolumePerLength(_value * new QuantityValue(48000000000, 112903, false), VolumePerLengthUnit.UsGallonPerMile), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 3fb4f2833f..a47d47fe75 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -51,7 +52,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -89,7 +90,7 @@ static VolumetricHeatCapacity() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) + public VolumetricHeatCapacity(QuantityValue value, VolumetricHeatCapacityUnit unit) { _value = value; _unit = unit; @@ -103,7 +104,7 @@ public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumetricHeatCapacity(double value, UnitSystem unitSystem) + public VolumetricHeatCapacity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -154,10 +155,10 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -182,47 +183,47 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); + public QuantityValue BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); /// /// Gets a value of this quantity converted into /// - public double CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); + public QuantityValue CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); + public QuantityValue JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); + public QuantityValue JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); /// /// Gets a value of this quantity converted into /// - public double KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); + public QuantityValue KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); + public QuantityValue KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); + public QuantityValue KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); + public QuantityValue MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); /// /// Gets a value of this quantity converted into /// - public double MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); + public QuantityValue MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); #endregion @@ -286,7 +287,7 @@ public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, IFormatPro /// /// Creates a from . /// - public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(double value) + public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); } @@ -294,7 +295,7 @@ public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(double /// /// Creates a from . /// - public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius(double value) + public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); } @@ -302,7 +303,7 @@ public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius /// /// Creates a from . /// - public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(double value) + public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); } @@ -310,7 +311,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(double /// /// Creates a from . /// - public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(double value) + public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); } @@ -318,7 +319,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(double value) /// /// Creates a from . /// - public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCelsius(double value) + public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCelsius(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); } @@ -326,7 +327,7 @@ public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCel /// /// Creates a from . /// - public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(double value) + public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); } @@ -334,7 +335,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(do /// /// Creates a from . /// - public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(double value) + public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); } @@ -342,7 +343,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(double va /// /// Creates a from . /// - public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(double value) + public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); } @@ -350,7 +351,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(do /// /// Creates a from . /// - public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(double value) + public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(QuantityValue value) { return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); } @@ -361,7 +362,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(double va /// Value to convert from. /// Unit to convert from. /// VolumetricHeatCapacity unit value. - public static VolumetricHeatCapacity From(double value, VolumetricHeatCapacityUnit fromUnit) + public static VolumetricHeatCapacity From(QuantityValue value, VolumetricHeatCapacityUnit fromUnit) { return new VolumetricHeatCapacity(value, fromUnit); } @@ -533,25 +534,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(double left, VolumetricHeatCapacity right) + public static VolumetricHeatCapacity operator *(QuantityValue left, VolumetricHeatCapacity right) { return new VolumetricHeatCapacity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, double right) + public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, QuantityValue right) { return new VolumetricHeatCapacity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, double right) + public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, QuantityValue right) { return new VolumetricHeatCapacity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) + public static QuantityValue operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return left.JoulesPerCubicMeterKelvin / right.JoulesPerCubicMeterKelvin; } @@ -584,27 +585,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is VolumetricHeatCapacity otherQuantity)) @@ -614,15 +608,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(VolumetricHeatCapacity other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -705,10 +696,10 @@ public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -725,7 +716,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -738,7 +729,12 @@ public bool Equals(VolumetricHeatCapacity other, VolumetricHeatCapacity toleranc /// A hash code for the current VolumetricHeatCapacity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -749,7 +745,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumetricHeatCapacityUnit unit) + public QuantityValue As(VolumetricHeatCapacityUnit unit) { if (Unit == unit) return Value; @@ -758,7 +754,7 @@ public double As(VolumetricHeatCapacityUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -773,7 +769,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); @@ -839,24 +835,24 @@ private bool TryToUnit(VolumetricHeatCapacityUnit unit, [NotNullWhen(true)] out VolumetricHeatCapacity? convertedOrNull = (Unit, unit) switch { // VolumetricHeatCapacityUnit -> BaseUnit - (VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value / 1.4910660e-5, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value / 2.388459e-7, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * new QuantityValue(50000000000, 745533, false), VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * new QuantityValue(10000000000000, 2388459, false), VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), (VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value / 2.388459e-7) * 1e3d, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) * 1e3d, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) * 1e3d, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) * 1e6d, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) * 1e6d, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * new QuantityValue(10000000000000000, 2388459, false), VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * 1000, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * 1000, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * 1000000, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value * 1000000, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin), // BaseUnit -> VolumetricHeatCapacityUnit - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit) => new VolumetricHeatCapacity(_value * 1.4910660e-5, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius) => new VolumetricHeatCapacity(_value * 2.388459e-7, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit) => new VolumetricHeatCapacity(_value * new QuantityValue(745533, 50000000000, false), VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius) => new VolumetricHeatCapacity(_value * new QuantityValue(2388459, 10000000000000, false), VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius), (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius) => new VolumetricHeatCapacity(_value, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius) => new VolumetricHeatCapacity((_value * 2.388459e-7) / 1e3d, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius) => new VolumetricHeatCapacity((_value) / 1e3d, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) / 1e3d, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius) => new VolumetricHeatCapacity((_value) / 1e6d, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius), - (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin) => new VolumetricHeatCapacity((_value) / 1e6d, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius) => new VolumetricHeatCapacity(_value * new QuantityValue(2388459, 10000000000000000, false), VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius) => new VolumetricHeatCapacity(_value / 1000, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value / 1000, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius) => new VolumetricHeatCapacity(_value / 1000000, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius), + (VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin) => new VolumetricHeatCapacity(_value / 1000000, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 8b5b59fdd2..1d03a46d25 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -24,6 +24,7 @@ using System.Runtime.Serialization; using UnitsNet.InternalHelpers; using UnitsNet.Units; +using System.Numerics; #nullable enable @@ -48,7 +49,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 1)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,7 +84,7 @@ static WarpingMomentOfInertia() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) + public WarpingMomentOfInertia(QuantityValue value, WarpingMomentOfInertiaUnit unit) { _value = value; _unit = unit; @@ -97,7 +98,7 @@ public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public WarpingMomentOfInertia(double value, UnitSystem unitSystem) + public WarpingMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -148,10 +149,10 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; /// - double IQuantity.Value => _value; + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,32 +177,32 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + public QuantityValue CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); /// /// Gets a value of this quantity converted into /// - public double DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + public QuantityValue DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); /// /// Gets a value of this quantity converted into /// - public double FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); + public QuantityValue FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); /// /// Gets a value of this quantity converted into /// - public double InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); + public QuantityValue InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); /// /// Gets a value of this quantity converted into /// - public double MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); + public QuantityValue MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); /// /// Gets a value of this quantity converted into /// - public double MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + public QuantityValue MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); #endregion @@ -259,7 +260,7 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatPro /// /// Creates a from . /// - public static WarpingMomentOfInertia FromCentimetersToTheSixth(double value) + public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); } @@ -267,7 +268,7 @@ public static WarpingMomentOfInertia FromCentimetersToTheSixth(double value) /// /// Creates a from . /// - public static WarpingMomentOfInertia FromDecimetersToTheSixth(double value) + public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); } @@ -275,7 +276,7 @@ public static WarpingMomentOfInertia FromDecimetersToTheSixth(double value) /// /// Creates a from . /// - public static WarpingMomentOfInertia FromFeetToTheSixth(double value) + public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.FootToTheSixth); } @@ -283,7 +284,7 @@ public static WarpingMomentOfInertia FromFeetToTheSixth(double value) /// /// Creates a from . /// - public static WarpingMomentOfInertia FromInchesToTheSixth(double value) + public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.InchToTheSixth); } @@ -291,7 +292,7 @@ public static WarpingMomentOfInertia FromInchesToTheSixth(double value) /// /// Creates a from . /// - public static WarpingMomentOfInertia FromMetersToTheSixth(double value) + public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MeterToTheSixth); } @@ -299,7 +300,7 @@ public static WarpingMomentOfInertia FromMetersToTheSixth(double value) /// /// Creates a from . /// - public static WarpingMomentOfInertia FromMillimetersToTheSixth(double value) + public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue value) { return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); } @@ -310,7 +311,7 @@ public static WarpingMomentOfInertia FromMillimetersToTheSixth(double value) /// Value to convert from. /// Unit to convert from. /// WarpingMomentOfInertia unit value. - public static WarpingMomentOfInertia From(double value, WarpingMomentOfInertiaUnit fromUnit) + public static WarpingMomentOfInertia From(QuantityValue value, WarpingMomentOfInertiaUnit fromUnit) { return new WarpingMomentOfInertia(value, fromUnit); } @@ -482,25 +483,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(double left, WarpingMomentOfInertia right) + public static WarpingMomentOfInertia operator *(QuantityValue left, WarpingMomentOfInertia right) { return new WarpingMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, double right) + public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, QuantityValue right) { return new WarpingMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, double right) + public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, QuantityValue right) { return new WarpingMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static QuantityValue operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.MetersToTheSixth / right.MetersToTheSixth; } @@ -533,27 +534,20 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi return left.Value > right.ToUnit(left.Unit).Value; } - // We use obsolete attribute to communicate the preferred equality members to use. - // CS0809: Obsolete member 'memberA' overrides non-obsolete member 'memberB'. - #pragma warning disable CS0809 - - /// Indicates strict equality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict equality of two quantities. public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.Equals(right); } - /// Indicates strict inequality of two quantities, where both and are exactly equal. - [Obsolete("For null checks, use `x is null` syntax to not invoke overloads. For equality checks, use Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")] + /// Indicates strict inequality of two quantities. public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return !(left == right); } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public override bool Equals(object? obj) { if (obj is null || !(obj is WarpingMomentOfInertia otherQuantity)) @@ -563,15 +557,12 @@ public override bool Equals(object? obj) } /// - /// Indicates strict equality of two quantities, where both and are exactly equal. - [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.")] + /// Indicates strict equality of two quantities. public bool Equals(WarpingMomentOfInertia other) { - return new { Value, Unit }.Equals(new { other.Value, other.Unit }); + return _value.Equals(other.As(this.Unit)); } - #pragma warning restore CS0809 - /// Compares the current with another object of the same type and returns an integer that indicates whether 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. /// @@ -654,10 +645,10 @@ public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0."); - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), - tolerance: tolerance, + tolerance: (QuantityValue)tolerance, comparisonType: ComparisonType.Absolute); } @@ -674,7 +665,7 @@ public bool Equals(IQuantity? other, IQuantity tolerance) /// public bool Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia tolerance) { - return UnitsNet.Comparison.Equals( + return UnitsNet.QuantityValueComparison.Equals( referenceValue: this.Value, otherValue: other.As(this.Unit), tolerance: tolerance.As(this.Unit), @@ -687,7 +678,12 @@ public bool Equals(WarpingMomentOfInertia other, WarpingMomentOfInertia toleranc /// A hash code for the current WarpingMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + var valueInBaseUnit = As(BaseUnit); + #if NET7_0_OR_GREATER + return HashCode.Combine(Info.Name, valueInBaseUnit); + #else + return new { Info.Name, valueInBaseUnit }.GetHashCode(); + #endif } #endregion @@ -698,7 +694,7 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(WarpingMomentOfInertiaUnit unit) + public QuantityValue As(WarpingMomentOfInertiaUnit unit) { if (Unit == unit) return Value; @@ -707,7 +703,7 @@ public double As(WarpingMomentOfInertiaUnit unit) } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -722,7 +718,7 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); @@ -788,18 +784,18 @@ private bool TryToUnit(WarpingMomentOfInertiaUnit unit, [NotNullWhen(true)] out WarpingMomentOfInertia? convertedOrNull = (Unit, unit) switch { // WarpingMomentOfInertiaUnit -> BaseUnit - (WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1e12, WarpingMomentOfInertiaUnit.MeterToTheSixth), - (WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1e6, WarpingMomentOfInertiaUnit.MeterToTheSixth), - (WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value * Math.Pow(0.3048, 6), WarpingMomentOfInertiaUnit.MeterToTheSixth), - (WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value * Math.Pow(2.54e-2, 6), WarpingMomentOfInertiaUnit.MeterToTheSixth), - (WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1e18, WarpingMomentOfInertiaUnit.MeterToTheSixth), + (WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1000000000000, WarpingMomentOfInertiaUnit.MeterToTheSixth), + (WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1000000, WarpingMomentOfInertiaUnit.MeterToTheSixth), + (WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value * new QuantityValue(3058791354808281, 3814697265625000000, false), WarpingMomentOfInertiaUnit.MeterToTheSixth), + (WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value * new QuantityValue(8391745829378, 3125, false) / BigInteger.Pow(10, 19), WarpingMomentOfInertiaUnit.MeterToTheSixth), + (WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth) => new WarpingMomentOfInertia(_value / 1000000000000000000, WarpingMomentOfInertiaUnit.MeterToTheSixth), // BaseUnit -> WarpingMomentOfInertiaUnit - (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.CentimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1e12, WarpingMomentOfInertiaUnit.CentimeterToTheSixth), - (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.DecimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1e6, WarpingMomentOfInertiaUnit.DecimeterToTheSixth), - (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.FootToTheSixth) => new WarpingMomentOfInertia(_value / Math.Pow(0.3048, 6), WarpingMomentOfInertiaUnit.FootToTheSixth), - (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.InchToTheSixth) => new WarpingMomentOfInertia(_value / Math.Pow(2.54e-2, 6), WarpingMomentOfInertiaUnit.InchToTheSixth), - (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.MillimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1e18, WarpingMomentOfInertiaUnit.MillimeterToTheSixth), + (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.CentimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1000000000000, WarpingMomentOfInertiaUnit.CentimeterToTheSixth), + (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.DecimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1000000, WarpingMomentOfInertiaUnit.DecimeterToTheSixth), + (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.FootToTheSixth) => new WarpingMomentOfInertia(_value * new QuantityValue(3814697265625000000, 3058791354808281, false), WarpingMomentOfInertiaUnit.FootToTheSixth), + (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.InchToTheSixth) => new WarpingMomentOfInertia(_value * new QuantityValue(3125, 8391745829378, false) * BigInteger.Pow(10, 19), WarpingMomentOfInertiaUnit.InchToTheSixth), + (WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.MillimeterToTheSixth) => new WarpingMomentOfInertia(_value * 1000000000000000000, WarpingMomentOfInertiaUnit.MillimeterToTheSixth), _ => null }; diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 8f90900f35..9432eb50b6 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -122,6 +122,7 @@ public partial class Quantity { "PowerRatio", PowerRatio.Info }, { "Pressure", Pressure.Info }, { "PressureChangeRate", PressureChangeRate.Info }, + { "RadiationEquivalentDose", RadiationEquivalentDose.Info }, { "RadiationExposure", RadiationExposure.Info }, { "Radioactivity", Radioactivity.Info }, { "Ratio", Ratio.Info }, @@ -169,7 +170,7 @@ public partial class Quantity /// The of the quantity to create. /// The value to construct the quantity with. /// The created quantity. - public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value) + public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValue value) { return quantityInfo.Name switch { @@ -257,6 +258,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value "PowerRatio" => PowerRatio.From(value, PowerRatio.BaseUnit), "Pressure" => Pressure.From(value, Pressure.BaseUnit), "PressureChangeRate" => PressureChangeRate.From(value, PressureChangeRate.BaseUnit), + "RadiationEquivalentDose" => RadiationEquivalentDose.From(value, RadiationEquivalentDose.BaseUnit), "RadiationExposure" => RadiationExposure.From(value, RadiationExposure.BaseUnit), "Radioactivity" => Radioactivity.From(value, Radioactivity.BaseUnit), "Ratio" => Ratio.From(value, Ratio.BaseUnit), @@ -307,7 +309,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value /// Unit enum value. /// The resulting quantity if successful, otherwise default. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(double value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) { quantity = unit switch { @@ -395,6 +397,7 @@ public static bool TryFrom(double value, Enum? unit, [NotNullWhen(true)] out IQu PowerRatioUnit powerRatioUnit => PowerRatio.From(value, powerRatioUnit), PressureUnit pressureUnit => Pressure.From(value, pressureUnit), PressureChangeRateUnit pressureChangeRateUnit => PressureChangeRate.From(value, pressureChangeRateUnit), + RadiationEquivalentDoseUnit radiationEquivalentDoseUnit => RadiationEquivalentDose.From(value, radiationEquivalentDoseUnit), RadiationExposureUnit radiationExposureUnit => RadiationExposure.From(value, radiationExposureUnit), RadioactivityUnit radioactivityUnit => Radioactivity.From(value, radioactivityUnit), RatioUnit ratioUnit => Ratio.From(value, ratioUnit), @@ -543,6 +546,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, Type _ when quantityType == typeof(PowerRatio) => parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity), Type _ when quantityType == typeof(Pressure) => parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity), Type _ when quantityType == typeof(PressureChangeRate) => parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity), + Type _ when quantityType == typeof(RadiationEquivalentDose) => parser.TryParse(quantityString, formatProvider, RadiationEquivalentDose.From, out quantity), Type _ when quantityType == typeof(RadiationExposure) => parser.TryParse(quantityString, formatProvider, RadiationExposure.From, out quantity), Type _ when quantityType == typeof(Radioactivity) => parser.TryParse(quantityString, formatProvider, Radioactivity.From, out quantity), Type _ when quantityType == typeof(Ratio) => parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity), @@ -672,6 +676,7 @@ internal static IEnumerable GetQuantityTypes() yield return typeof(PowerRatio); yield return typeof(Pressure); yield return typeof(PressureChangeRate); + yield return typeof(RadiationEquivalentDose); yield return typeof(RadiationExposure); yield return typeof(Radioactivity); yield return typeof(Ratio); diff --git a/UnitsNet/GeneratedCode/Resources/Irradiation.restext b/UnitsNet/GeneratedCode/Resources/Irradiation.restext index b2a605bb57..03acc1e02a 100644 --- a/UnitsNet/GeneratedCode/Resources/Irradiation.restext +++ b/UnitsNet/GeneratedCode/Resources/Irradiation.restext @@ -1,6 +1,8 @@ +BtusPerSquareFoot=Btu/ft² JoulesPerSquareCentimeter=J/cm² JoulesPerSquareMeter=J/m² JoulesPerSquareMillimeter=J/mm² +KilobtusPerSquareFoot=kBtu/ft² KilojoulesPerSquareMeter=kJ/m² KilowattHoursPerSquareMeter=kWh/m² MillijoulesPerSquareCentimeter=mJ/cm² diff --git a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.restext b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.restext new file mode 100644 index 0000000000..c7e8643b87 --- /dev/null +++ b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.restext @@ -0,0 +1,6 @@ +Microsieverts=µSv +MilliroentgensEquivalentMan=mrem +Millisieverts=mSv +Nanosieverts=nSv +RoentgensEquivalentMan=rem +Sieverts=Sv diff --git a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.ru-RU.restext b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.ru-RU.restext new file mode 100644 index 0000000000..4b8eaee757 --- /dev/null +++ b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDose.ru-RU.restext @@ -0,0 +1,4 @@ +Microsieverts=мкЗв +Millisieverts=мЗв +Nanosieverts=нЗв +Sieverts=Зв diff --git a/UnitsNet/GeneratedCode/Resources/VolumeFlow.restext b/UnitsNet/GeneratedCode/Resources/VolumeFlow.restext index 73c8bc54e0..b071b56273 100644 --- a/UnitsNet/GeneratedCode/Resources/VolumeFlow.restext +++ b/UnitsNet/GeneratedCode/Resources/VolumeFlow.restext @@ -20,10 +20,18 @@ CubicYardsPerDay=cy/day CubicYardsPerHour=yd³/h CubicYardsPerMinute=yd³/min CubicYardsPerSecond=yd³/s +DecalitersPerDay=dal/day,daL/d,daLPD +DecalitersPerHour=daL/h,daLPH +DecalitersPerMinute=daL/min,daLPM +DecalitersPerSecond=daL/s,daLPS DecilitersPerDay=dl/day,dL/d,dLPD DecilitersPerHour=dL/h,dLPH DecilitersPerMinute=dL/min,dLPM DecilitersPerSecond=dL/s,dLPS +HectolitersPerDay=hl/day,hL/d,hLPD +HectolitersPerHour=hL/h,hLPH +HectolitersPerMinute=hL/min,hLPM +HectolitersPerSecond=hL/s,hLPS KilolitersPerDay=kl/day,kL/d,kLPD KilolitersPerHour=kL/h,kLPH KilolitersPerMinute=kL/min,kLPM diff --git a/UnitsNet/GeneratedCode/Resources/VolumeFlow.ru-RU.restext b/UnitsNet/GeneratedCode/Resources/VolumeFlow.ru-RU.restext index 6e5a483b50..289ed120cc 100644 --- a/UnitsNet/GeneratedCode/Resources/VolumeFlow.ru-RU.restext +++ b/UnitsNet/GeneratedCode/Resources/VolumeFlow.ru-RU.restext @@ -7,9 +7,15 @@ CubicMetersPerHour=м³/ч CubicMetersPerMinute=м³/мин CubicMetersPerSecond=м³/с CubicMillimetersPerSecond=мм³/с +DecalitersPerHour=дал/ч +DecalitersPerMinute=дал/мин +DecalitersPerSecond=дал/c DecilitersPerHour=дл/ч DecilitersPerMinute=дл/мин DecilitersPerSecond=дл/c +HectolitersPerHour=гл/ч +HectolitersPerMinute=гл/мин +HectolitersPerSecond=гл/c KilolitersPerHour=кл/ч KilolitersPerMinute=кл/мин KilolitersPerSecond=кл/c diff --git a/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs index 449fdf2491..26d131063a 100644 --- a/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs @@ -25,9 +25,11 @@ namespace UnitsNet.Units public enum IrradiationUnit { + BtuPerSquareFoot = 15, JoulePerSquareCentimeter = 1, JoulePerSquareMeter = 2, JoulePerSquareMillimeter = 3, + KilobtuPerSquareFoot = 9, KilojoulePerSquareMeter = 4, KilowattHourPerSquareMeter = 5, MillijoulePerSquareCentimeter = 6, diff --git a/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs b/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs new file mode 100644 index 0000000000..2095852833 --- /dev/null +++ b/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseUnit.g.cs @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// 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. + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Units +{ + // Disable missing XML comment warnings for the generated unit enums. + #pragma warning disable 1591 + + public enum RadiationEquivalentDoseUnit + { + Microsievert = 1, + MilliroentgenEquivalentMan = 2, + Millisievert = 7, + Nanosievert = 5, + RoentgenEquivalentMan = 4, + + /// + /// The sievert is a unit in the International System of Units (SI) intended to represent the stochastic health risk of ionizing radiation, which is defined as the probability of causing radiation-induced cancer and genetic damage. + /// + /// https://en.wikipedia.org/wiki/Sievert + Sievert = 9, + } + + #pragma warning restore 1591 +} diff --git a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs index ab8b2bca49..6c14bc7b98 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -47,10 +47,18 @@ public enum VolumeFlowUnit CubicYardPerHour = 20, CubicYardPerMinute = 21, CubicYardPerSecond = 22, + DecaliterPerDay = 71, + DecaliterPerHour = 78, + DecaliterPerMinute = 67, + DecaliterPerSecond = 70, DeciliterPerDay = 23, DeciliterPerHour = 24, DeciliterPerMinute = 25, DeciliterPerSecond = 26, + HectoliterPerDay = 74, + HectoliterPerHour = 72, + HectoliterPerMinute = 75, + HectoliterPerSecond = 69, KiloliterPerDay = 27, KiloliterPerHour = 28, KiloliterPerMinute = 29, diff --git a/UnitsNet/GenericMath/GenericMathExtensions.cs b/UnitsNet/GenericMath/GenericMathExtensions.cs index 9ef41a69e4..a0279744f7 100644 --- a/UnitsNet/GenericMath/GenericMathExtensions.cs +++ b/UnitsNet/GenericMath/GenericMathExtensions.cs @@ -54,7 +54,7 @@ public static T Sum(this IEnumerable source) /// The value type. /// The average. public static T Average(this IEnumerable source) - where T : IAdditionOperators, IAdditiveIdentity, IDivisionOperators + where T : IAdditionOperators, IAdditiveIdentity, IDivisionOperators { // Put accumulator on right hand side of the addition operator to construct quantities with the same unit as the values. // The addition operator implementation picks the unit from the left hand side, and the additive identity (e.g. Length.Zero) is always the base unit. diff --git a/UnitsNet/IArithmeticQuantity.cs b/UnitsNet/IArithmeticQuantity.cs index 031a4510e0..de648cd61c 100644 --- a/UnitsNet/IArithmeticQuantity.cs +++ b/UnitsNet/IArithmeticQuantity.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; @@ -16,8 +16,8 @@ public interface IArithmeticQuantity : IQuantity , IAdditiveIdentity , ISubtractionOperators - , IMultiplyOperators - , IDivisionOperators + , IMultiplyOperators + , IDivisionOperators , IUnaryNegationOperators #endif where TSelf : IArithmeticQuantity diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index c3ff8b17d6..0210366f9a 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -31,7 +31,7 @@ public interface IQuantity : IFormattable /// The unit enum value. The unit must be compatible, so for you should provide a value. /// Value converted to the specified unit. /// Wrong unit enum type was given. - double As(Enum unit); + QuantityValue As(Enum unit); /// /// Gets the value in the unit determined by the given . If multiple units were found for the given , @@ -39,7 +39,7 @@ public interface IQuantity : IFormattable /// /// The to convert the quantity value to. /// The converted value. - double As(UnitSystem unitSystem); + QuantityValue As(UnitSystem unitSystem); /// /// @@ -72,7 +72,7 @@ public interface IQuantity : IFormattable /// /// The value this quantity was constructed with. See also . /// - double Value { get; } + QuantityValue Value { get; } /// /// Converts this to an in the given . @@ -117,7 +117,7 @@ public interface IQuantity : IQuantity /// Convert to a unit representation . /// /// Value converted to the specified unit. - double As(TUnitType unit); + QuantityValue As(TUnitType unit); /// new TUnitType Unit { get; } diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index fcbca7350d..4a39172bc4 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -4,6 +4,7 @@ using System; using System.Globalization; using System.Linq; +using System.Text.RegularExpressions; using UnitsNet.Units; namespace UnitsNet @@ -109,10 +110,62 @@ public static string Format(IQuantity quantity, string for public static string Format(IQuantity quantity, string? format, IFormatProvider? formatProvider) where TUnitType : Enum { + // formatProvider ??= CultureInfo.CurrentCulture; + // return FormatUntrimmed(quantity, format, formatProvider).TrimEnd(); + formatProvider ??= CultureInfo.CurrentCulture; - return FormatUntrimmed(quantity, format, formatProvider).TrimEnd(); + + if (format is null or "" or "g") + { + format = "s"; // TODO "s" or "S"? + } + else if (format is "G") + { + format = "S"; + } + + var formatSpecifier = format[0]; // netstandard2.0 nullable quirk + + switch (formatSpecifier) + { + case 'A' or 'a': + { + if (format.Length == 1) + { + return UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(quantity.Unit, formatProvider); + } + + // "An": The n-th unit abbreviation for + if (!int.TryParse(format.Substring(1), out var abbreviationIndex)) + { + throw new FormatException($"The {format} format string is not supported."); + } + + var abbreviations = UnitsNetSetup.Default.UnitAbbreviations.GetUnitAbbreviations(quantity.Unit, formatProvider); + + if (abbreviationIndex >= abbreviations.Length) + { + throw new FormatException($"The {format} format string is invalid because the abbreviation index does not exist."); + } + + return abbreviations[abbreviationIndex]; + } + case 'V' or 'v': + return quantity.Value.ToString(formatProvider); + case 'U' or 'u': + return quantity.Unit.ToString(); + case 'Q' or 'q': + return quantity.QuantityInfo.Name; + default: // case of 'S' or 's' or 'G' or 'g' (and anything else) defaults to "{value:format} {abbreviation}" (trimmed as necessary) + { + var valueString = quantity.Value.ToString(format, formatProvider); + var abbreviation = UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(quantity.Unit, formatProvider); + return string.IsNullOrEmpty(abbreviation) ? valueString : valueString + ' ' + abbreviation; + } + } } + [Obsolete] private static string FormatUntrimmed(IQuantity quantity, string? format, IFormatProvider? formatProvider) where TUnitType : Enum { @@ -147,7 +200,7 @@ private static string FormatUntrimmed(IQuantity quantity, return ToStringWithSignificantDigitsAfterRadix(quantity, formatProvider, 2); case 'A': case 'a': - var abbreviations = UnitAbbreviationsCache.Default.GetUnitAbbreviations(quantity.Unit, formatProvider); + var abbreviations = UnitsNetSetup.Default.UnitAbbreviations.GetUnitAbbreviations(quantity.Unit, formatProvider); if (precisionSpecifier >= abbreviations.Length) throw new FormatException($"The {format} format string is invalid because the abbreviation index does not exist."); @@ -155,7 +208,7 @@ private static string FormatUntrimmed(IQuantity quantity, return abbreviations[precisionSpecifier]; case 'V': case 'v': - return quantity.Value.ToString(formatProvider); + return quantity.Value.ToDouble().ToString(formatProvider); case 'U': case 'u': return quantity.Unit.ToString(); @@ -172,17 +225,20 @@ private static string FormatUntrimmed(IQuantity quantity, else { // Anything else is a standard numeric format string with default unit abbreviation postfix. - - var abbreviations = UnitAbbreviationsCache.Default.GetUnitAbbreviations(quantity.Unit, formatProvider); - return string.Format(formatProvider, $"{{0:{format}}} {{1}}", quantity.Value, abbreviations.First()); + var abbreviation = UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(quantity.Unit, formatProvider); + return string.Format(formatProvider, $"{{0:{format}}} {{1}}", quantity.Value, abbreviation); } } - private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int number) where TUnitType : Enum + private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int precisionSpecifier) + where TUnitType : Enum { - string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value, number); - object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value, formatProvider, Enumerable.Empty()); - return string.Format(formatProvider, formatForSignificantDigits, formatArgs); + // string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value.ToDouble(), precisionSpecifier); + // object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value.ToDouble(), formatProvider, Enumerable.Empty()); + // return string.Format(formatProvider, formatForSignificantDigits, formatArgs); + var valueString = quantity.Value.ToString($"g{precisionSpecifier}", formatProvider); + var abbreviation = UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(quantity.Unit, formatProvider); + return $"{valueString} {abbreviation}"; } } } diff --git a/UnitsNet/QuantityInfoLookup.cs b/UnitsNet/QuantityInfoLookup.cs index 386e797cf0..f0fe443c68 100644 --- a/UnitsNet/QuantityInfoLookup.cs +++ b/UnitsNet/QuantityInfoLookup.cs @@ -103,7 +103,7 @@ public void AddUnitInfo(Enum unit, UnitInfo unitInfo) /// Unit enum value. /// An object. /// Unit value is not a know unit enum type. - public IQuantity From(double value, Enum unit) + public IQuantity From(QuantityValue value, Enum unit) { // TODO Support custom units, currently only hardcoded built-in quantities are supported. return Quantity.TryFrom(value, unit, out IQuantity? quantity) @@ -111,16 +111,17 @@ public IQuantity From(double value, Enum unit) : throw new UnitNotFoundException($"Unit value {unit} of type {unit.GetType()} is not a known unit enum type. Expected types like UnitsNet.Units.LengthUnit. Did you pass in a custom enum type defined outside the UnitsNet library?"); } - /// - public bool TryFrom(double value, Enum unit, [NotNullWhen(true)] out IQuantity? quantity) + /// + // [Obsolete("Please use the Quantity.TryFrom")] // TODO not sure this if this method is still needed (unless we add back the QuantityValue) + public bool TryFrom(QuantityValue value, Enum unit, [NotNullWhen(true)] out IQuantity? quantity) { - // Implicit cast to QuantityValue would prevent TryFrom from being called, - // so we need to explicitly check this here for double arguments. - if (double.IsNaN(value) || double.IsInfinity(value)) - { - quantity = default(IQuantity); - return false; - } + // // Implicit cast to QuantityValue would prevent TryFrom from being called, + // // so we need to explicitly check this here for double arguments. + // if (double.IsNaN(value) || double.IsInfinity(value)) + // { + // quantity = default(IQuantity); + // return false; + // } // TODO Support custom units, currently only hardcoded built-in quantities are supported. return Quantity.TryFrom(value, unit, out quantity); diff --git a/UnitsNet/QuantityTypeConverter.cs b/UnitsNet/QuantityTypeConverter.cs index 40f5b66d65..5addda1211 100644 --- a/UnitsNet/QuantityTypeConverter.cs +++ b/UnitsNet/QuantityTypeConverter.cs @@ -173,11 +173,11 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source { IQuantity? quantity = null; - if (double.TryParse(stringValue, NumberStyles.Any, culture, out double dvalue)) + if (QuantityValue.TryParse(stringValue, NumberStyles.Any, culture, out QuantityValue fraction)) { var defaultUnit = GetAttribute(context) ?? new DefaultUnitAttribute(default(TQuantity).Unit); if(defaultUnit.UnitType != null) - quantity = Quantity.From(dvalue, defaultUnit.UnitType); + quantity = Quantity.From(fraction, defaultUnit.UnitType); } else { diff --git a/UnitsNet/QuantityValue.CompareTo.cs b/UnitsNet/QuantityValue.CompareTo.cs new file mode 100644 index 0000000000..c723aad56d --- /dev/null +++ b/UnitsNet/QuantityValue.CompareTo.cs @@ -0,0 +1,76 @@ +// 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; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + /// + /// Greater-than operator + /// + public static bool operator >(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) > 0; + } + + /// + /// Less-than operator + /// + public static bool operator <(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) < 0; + } + + /// + /// Greater-than-or-equal operator + /// + public static bool operator >=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) >= 0; + } + + /// + /// Less-than-or-equal operator + /// + public static bool operator <=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) <= 0; + } + + /// + /// Compares this QuantityValue instance to another QuantityValue instance. + /// + /// The QuantityValue to compare with this instance. + /// + /// A value indicating the relative order of the QuantityValue instances being compared. + /// Less than zero: This instance is less than the other instance. + /// Zero: This instance is equal to the other instance. + /// Greater than zero: This instance is greater than the other instance. + /// + public int CompareTo(QuantityValue other) + { + return _fraction.CompareTo(other._fraction); + } + + /// + /// Compares this QuantityValue instance to another object. + /// + /// The object to compare with this instance. + /// + /// A value indicating the relative order of the QuantityValue instances being compared. + /// Less than zero: This instance is less than the other instance. + /// Zero: This instance is equal to the other instance. + /// Greater than zero: This instance is greater than the other instance. + /// + public int CompareTo(object? obj) + { + return obj switch + { + null => 1, + QuantityValue other => CompareTo(other), + _ => throw new ArgumentException($"Object must be of type {nameof(QuantityValue)}") + }; + } +} diff --git a/UnitsNet/QuantityValue.ConvertFromNumber.cs b/UnitsNet/QuantityValue.ConvertFromNumber.cs new file mode 100644 index 0000000000..807deba7f2 --- /dev/null +++ b/UnitsNet/QuantityValue.ConvertFromNumber.cs @@ -0,0 +1,184 @@ +// 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.Numerics; +using Fractions; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + /// Implicit cast from to . + public static implicit operator QuantityValue(byte value) + { + return new QuantityValue(new Fraction(value)); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(short value) + { + return new QuantityValue(value); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(int value) + { + return new QuantityValue(value); + } + + /// Implicit cast from to . + [CLSCompliant(false)] + public static implicit operator QuantityValue(uint value) + { + return new QuantityValue(value); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(long value) + { + return new QuantityValue(value); + } + + /// Implicit cast from to . + [CLSCompliant(false)] + public static implicit operator QuantityValue(ulong value) + { + return new QuantityValue(value); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(float value) + { + return new QuantityValue(new Fraction(value)); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(double value) + { + // return FromDouble(value); + return FromDoubleRounded(value); + // return new QuantityValue(new Fraction(value)); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(decimal value) + { + return new QuantityValue(new Fraction(value)); + } + + /// Implicit cast from to . + public static implicit operator QuantityValue(BigInteger value) + { + return new QuantityValue(value); + } + + /// + /// Creates a new QuantityValue from a decimal number. + /// + /// The decimal number to convert into a QuantityValue. + /// A new QuantityValue that represents the given decimal number. + public static QuantityValue FromDecimal(decimal value) + { + return new QuantityValue(new Fraction(value)); + } + + /// + /// Converts a floating point value to a QuantityValue. The value is rounded if possible. + /// + /// The floating point value to convert. + /// + /// A QuantityValue representing the rounded floating point value. + /// + /// The double data type stores its values as 64-bit floating point numbers in accordance with the IEC 60559:1989 (IEEE + /// 754) standard for binary floating-point arithmetic. + /// However, the double data type cannot precisely store some binary fractions. For instance, 1/10, which is accurately + /// represented by .1 as a decimal fraction, is represented by .0001100110011... as a binary fraction, with the pattern + /// 0011 repeating indefinitely. + /// In such cases, the floating-point value provides an approximate representation of the number. + /// + /// This method can be used to avoid large numbers in the numerator and denominator. However, be aware that the + /// creation speed is significantly slower than using the pure value resulting from casting to double. + /// + /// + /// + /// This example shows how to use the method. + /// + /// QuantityValue qv = QuantityValue.FromDoubleRounded(0.1); + /// // Output: 1/10, which is exactly 0.1 + /// + /// + public static QuantityValue FromDoubleRounded(double value, int nbSignificantDigits = 15) + { + if (value == 0) + { + return Zero; + } + + // TODO replace these with constants once the issue is resolved: https://github.com/danm-de/Fractions/issues/26 + if (double.IsNaN(value)) + { + return new QuantityValue(BigInteger.Zero, BigInteger.Zero, false); + } + + if (double.IsPositiveInfinity(value)) + { + return new QuantityValue(BigInteger.One, BigInteger.Zero, false); + } + + if (double.IsNegativeInfinity(value)) + { + return new QuantityValue(BigInteger.MinusOne, BigInteger.Zero, false); + } + + // Determine the number of decimal places to keep + var magnitude = Math.Floor(Math.Log10(Math.Abs(value))); + if (magnitude > nbSignificantDigits) + { + var digitsToKeep = new BigInteger(value / Math.Pow(10, magnitude - nbSignificantDigits)); + return digitsToKeep * BigInteger.Pow(Ten, (int)magnitude - nbSignificantDigits); + } + + // "decimal" values + var truncatedValue = Math.Truncate(value); + var integerPart = new BigInteger(truncatedValue); + + var decimalPlaces = Math.Min(-(int)magnitude + nbSignificantDigits - 1, 308); + var scaleFactor = Math.Pow(10, decimalPlaces); + // Get the fractional part + var fractionalPartDouble = Math.Round((value - truncatedValue) * scaleFactor); + if (fractionalPartDouble == 0) // rounded to integer + { + return new QuantityValue(new Fraction(integerPart)); + } + + var denominator = BigInteger.Pow(Ten, decimalPlaces); + BigInteger numerator = integerPart * denominator + new BigInteger(fractionalPartDouble); + return new QuantityValue(numerator, denominator); + } + + /// + /// Converts a floating point value to a QuantityValue. + /// + /// The floating point value to convert. + /// A QuantityValue representing the given floating point value. + /// + /// The double data type stores its values as 64-bit floating point numbers in accordance with the IEC 60559:1989 (IEEE + /// 754) standard for binary floating-point arithmetic. + /// However, the double data type cannot precisely store some binary fractions. For instance, 1/10, which is accurately + /// represented by .1 as a decimal fraction, is represented by .0001100110011... as a binary fraction, with the pattern + /// 0011 repeating indefinitely. + /// In such cases, the floating-point value provides an approximate representation of the number. + /// + /// + /// This example shows how to use the method. + /// + /// QuantityValue qv = QuantityValue.FromDouble(0.1); + /// // Output: 3602879701896397/36028797018963968, which is approximately 0.10000000000000000555111512312578 + /// + /// + public static QuantityValue FromExactDouble(double value) + { + return new QuantityValue(Fraction.FromDouble(value)); + } +} diff --git a/UnitsNet/QuantityValue.ConvertToNumber.cs b/UnitsNet/QuantityValue.ConvertToNumber.cs new file mode 100644 index 0000000000..139075712b --- /dev/null +++ b/UnitsNet/QuantityValue.ConvertToNumber.cs @@ -0,0 +1,98 @@ +// 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.Numerics; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + /// Explicit cast from to . + public static explicit operator double(QuantityValue value) + { + return (double)value._fraction; + } + + /// + /// Returns the quantity as (rounded!) floating point value. + /// + /// A floating point value + public double ToDouble() + { + return (double)_fraction; + } + + + /// Explicit cast from to . + public static explicit operator decimal(QuantityValue value) + { + return (decimal)value._fraction; + } + + /// + /// Returns the quantity as (rounded!) floating point value. + /// + /// A floating point value + public decimal ToDecimal() + { + return (decimal)_fraction; + } + + /// Explicit cast from to . + public static explicit operator float(QuantityValue value) + { + return (float)(double)value; + } + + /// Explicit cast from to . + public static explicit operator BigInteger(QuantityValue value) + { + return (BigInteger)value._fraction; + } + + /// Explicit cast from to . + public static explicit operator long(QuantityValue value) + { + return (long)value._fraction; + } + + /// Explicit cast from to . + [CLSCompliant(false)] + public static explicit operator ulong(QuantityValue value) + { + return (ulong)value._fraction; + } + + /// Explicit cast from to . + public static explicit operator int(QuantityValue value) + { + return (int)value._fraction; + } + + /// Explicit cast from to . + [CLSCompliant(false)] + public static explicit operator uint(QuantityValue value) + { + return (uint)value._fraction; + } + + /// Explicit cast from to . + public static explicit operator short(QuantityValue value) + { + return (short)value._fraction; + } + + /// Explicit cast from to . + [CLSCompliant(false)] + public static explicit operator ushort(QuantityValue value) + { + return (ushort)(short)value; + } + + /// Explicit cast from to . + public static explicit operator byte(QuantityValue value) + { + return (byte)(short)value; + } +} diff --git a/UnitsNet/QuantityValue.ConvertToType.cs b/UnitsNet/QuantityValue.ConvertToType.cs new file mode 100644 index 0000000000..9f4b5a2837 --- /dev/null +++ b/UnitsNet/QuantityValue.ConvertToType.cs @@ -0,0 +1,153 @@ +// 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; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + #region Implementation of IConvertible + + TypeCode IConvertible.GetTypeCode() + { + return TypeCode.Object; + } + + bool IConvertible.ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to bool is not supported."); + } + + byte IConvertible.ToByte(IFormatProvider? provider) + { + return (byte)this; + } + + char IConvertible.ToChar(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to char is not supported."); + } + + DateTime IConvertible.ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to DateTime is not supported."); + } + + decimal IConvertible.ToDecimal(IFormatProvider? provider) + { + return ToDecimal(); + } + + double IConvertible.ToDouble(IFormatProvider? provider) + { + return ToDouble(); + } + + short IConvertible.ToInt16(IFormatProvider? provider) + { + return (short)this; + } + + int IConvertible.ToInt32(IFormatProvider? provider) + { + return (int)this; + } + + long IConvertible.ToInt64(IFormatProvider? provider) + { + return (long)this; + } + + sbyte IConvertible.ToSByte(IFormatProvider? provider) + { + return (sbyte)this; + } + + float IConvertible.ToSingle(IFormatProvider? provider) + { + return (float)this; + } + + ushort IConvertible.ToUInt16(IFormatProvider? provider) + { + return (ushort)this; + } + + uint IConvertible.ToUInt32(IFormatProvider? provider) + { + return (uint)this; + } + + ulong IConvertible.ToUInt64(IFormatProvider? provider) + { + return (ulong)this; + } + + object IConvertible.ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == null) + { + throw new ArgumentNullException(nameof(conversionType)); + } + + if (conversionType == typeof(string)) + { + return ToString(provider); + } + + if (conversionType == typeof(double)) + { + return ToDouble(); + } + + if (conversionType == typeof(decimal)) + { + return ToDecimal(); + } + + if (conversionType == typeof(float)) + { + return (float)this; + } + + if (conversionType == typeof(long)) + { + return (long)this; + } + + if (conversionType == typeof(ulong)) + { + return (ulong)this; + } + + if (conversionType == typeof(int)) + { + return (int)this; + } + + if (conversionType == typeof(uint)) + { + return (uint)this; + } + + if (conversionType == typeof(short)) + { + return (short)this; + } + + if (conversionType == typeof(ushort)) + { + return (ushort)this; + } + + if (conversionType == typeof(byte)) + { + return (byte)this; + } + + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to {conversionType} is not supported."); + } + + #endregion +} diff --git a/UnitsNet/QuantityValue.Equality.cs b/UnitsNet/QuantityValue.Equality.cs new file mode 100644 index 0000000000..8f0530fac2 --- /dev/null +++ b/UnitsNet/QuantityValue.Equality.cs @@ -0,0 +1,58 @@ +// 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; + +public readonly partial struct QuantityValue +{ + /// + /// Determines whether this QuantityValue instance is equal to another QuantityValue instance. + /// + /// The QuantityValue to compare with this instance. + /// True if the two QuantityValue instances are equal, false otherwise. + public bool Equals(QuantityValue other) + { + return _fraction.Equals(other._fraction); + } + + /// + /// Determines whether this QuantityValue instance is equal to another object. + /// + /// The object to compare with this instance. + /// True if the object is a QuantityValue instance and is equal to this instance, false otherwise. + public override bool Equals(object? obj) + { + return obj is QuantityValue other && Equals(other); + } + + /// + /// Returns the hash code for this QuantityValue instance. + /// + /// The hash code. + public override int GetHashCode() + { + return _fraction.GetHashCode(); + } + + /// + /// Compares two QuantityValue instances for equality. + /// + /// The first QuantityValue. + /// The second QuantityValue. + /// True if the two QuantityValue instances are equal, false otherwise. + public static bool operator ==(QuantityValue a, QuantityValue b) + { + return a._fraction == b._fraction; + } + + /// + /// Compares two QuantityValue instances for inequality. + /// + /// The first QuantityValue. + /// The second QuantityValue. + /// True if the two QuantityValue instances are not equal, false otherwise. + public static bool operator !=(QuantityValue a, QuantityValue b) + { + return a._fraction != b._fraction; + } +} diff --git a/UnitsNet/QuantityValue.FromString.cs b/UnitsNet/QuantityValue.FromString.cs new file mode 100644 index 0000000000..42c673b14b --- /dev/null +++ b/UnitsNet/QuantityValue.FromString.cs @@ -0,0 +1,212 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Globalization; +using System.Numerics; +using Fractions; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + internal static readonly BigInteger Ten = 10; + + /// + /// Parses a string representation of a quantity value into a QuantityValue object. + /// + /// The string representation of the quantity value. + /// + /// A NumberStyles value that indicates the style elements that can be present in + /// valueString. + /// + /// A QuantityValue object that represents the parsed string. + /// Thrown when the provided string argument is null. + /// + /// Thrown when the format of the provided string argument is invalid and cannot + /// be successfully parsed into a Fraction. + /// + public static QuantityValue Parse(string valueString, IFormatProvider? parseNumberStyles) + { + return Parse(valueString, NumberStyles.Float, parseNumberStyles); + } + + /// + /// Parses a string representation of a quantity value into a QuantityValue object. + /// + /// The string representation of the quantity value. + /// + /// A NumberStyles value that indicates the style elements that can be present in + /// valueString. + /// + /// + /// An IFormatProvider that supplies culture-specific formatting information about + /// valueString. + /// + /// A QuantityValue object that represents the parsed string. + /// Thrown when the provided string argument is null. + /// + /// Thrown when the format of the provided string argument is invalid and cannot + /// be successfully parsed into a Fraction. + /// + public static QuantityValue Parse(string valueString, NumberStyles parseNumberStyles, IFormatProvider? formatProvider) + { + if (TryParse(valueString, parseNumberStyles, formatProvider, out QuantityValue valueParsed)) + { + return valueParsed; + } + + throw new FormatException( + $"The format of the provided string argument '{valueString}' is invalid and cannot be successfully parsed into a QuantityValue."); + } + + /// + /// Tries to convert the string representation of a quantity value to its QuantityValue equivalent, and returns a value + /// that indicates whether the conversion succeeded. + /// + /// The string representation of a quantity value. This parameter can be null. + /// + /// A NumberStyles value that indicates the style elements that can be present in + /// valueString. + /// + /// + /// An IFormatProvider that supplies culture-specific formatting information about + /// valueString. This parameter can be null. + /// + /// + /// When this method returns, contains the QuantityValue equivalent to the quantity value + /// contained in valueString, if the conversion succeeded, or zero if the conversion failed. The conversion fails if + /// the valueString parameter is null or is not of the correct format. This parameter is passed uninitialized. + /// + /// true if valueString was converted successfully; otherwise, false. + public static bool TryParse(string? valueString, NumberStyles parseNumberStyles, IFormatProvider? formatProvider, out QuantityValue quantityValue) + { + // check out the code dotnet runtime: src/libraries/System.Private.CoreLib/src/System/Number.Parsing.cs + if (string.IsNullOrEmpty(valueString)) + { + quantityValue = default; + return false; + } + + if (parseNumberStyles.HasFlag(NumberStyles.AllowExponent)) + { + return TryParseWithExponent(valueString!, parseNumberStyles, formatProvider, out quantityValue); + } + + if (parseNumberStyles.HasFlag(NumberStyles.AllowDecimalPoint)) + { + return TryParseDecimalNumber(valueString!, parseNumberStyles, formatProvider, out quantityValue); + } + + if(BigInteger.TryParse(valueString!, parseNumberStyles, formatProvider, out BigInteger bigInteger)) + { + quantityValue = bigInteger; + return true; + } + + quantityValue = default; + return false; + } + + private static bool TryParseWithExponent(string valueString, NumberStyles parseNumberStyles, IFormatProvider? formatProvider, out QuantityValue quantityValue) + { + parseNumberStyles &= ~NumberStyles.AllowExponent; + var exponentIndex = valueString.IndexOfAny(['e', 'E'], 1); + if (exponentIndex == -1) + { + return parseNumberStyles.HasFlag(NumberStyles.AllowDecimalPoint) + ? TryParseDecimalNumber(valueString, parseNumberStyles, formatProvider, out quantityValue) + : TryParseInteger(valueString, parseNumberStyles, formatProvider, out quantityValue); + } + + var exponentString = valueString.Substring(exponentIndex + 1); + if (!int.TryParse(exponentString, parseNumberStyles, formatProvider, out var exponent)) + { + quantityValue = default; + return false; + } + + // we've got an exponent: try to parse the coefficient + var coefficientString = valueString.Substring(0, exponentIndex); + if (parseNumberStyles.HasFlag(NumberStyles.AllowDecimalPoint)) + { + if (!TryParseDecimalNumber(coefficientString, parseNumberStyles, formatProvider, out quantityValue)) + { + return false; + } + } + else + { + if (!TryParseInteger(coefficientString, parseNumberStyles, formatProvider, out quantityValue)) + { + return false; + } + } + + quantityValue *= Pow(Ten, exponent); + return true; + } + + private static bool TryParseDecimalNumber(string valueString, NumberStyles parseNumberStyles, IFormatProvider? formatProvider, out QuantityValue quantityValue) + { + // valueString can be either a big-integer expression or one of the form "123.456...890" (possibly longer than the decimal range/precision) + // // TODO test the short-path + // if (valueString.Length < 30 && decimal.TryParse(valueString, parseNumberStyles, formatProvider, out var decimalValue)) + // { + // quantityValue = decimalValue; + // return true; + // } + // note: this whole function could probably be implemented without any string allocations + // 1. clean up the whitespaces + if (parseNumberStyles.HasFlag(NumberStyles.AllowLeadingWhite) && parseNumberStyles.HasFlag(NumberStyles.AllowTrailingWhite)) + { + valueString = valueString.Trim(); + parseNumberStyles &= ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite); + } + else if (parseNumberStyles.HasFlag(NumberStyles.AllowLeadingWhite)) + { + valueString = valueString.TrimStart(); + parseNumberStyles &= ~NumberStyles.AllowLeadingWhite; + } + else if (parseNumberStyles.HasFlag(NumberStyles.AllowTrailingWhite)) + { + valueString = valueString.TrimEnd(); + parseNumberStyles &= ~NumberStyles.AllowTrailingWhite; + } + + // 2. find the position of the decimal separator (if any) + var numberFormatInfo = NumberFormatInfo.GetInstance(formatProvider); + var decimalSeparatorIndex = valueString.IndexOf(numberFormatInfo.NumberDecimalSeparator, 0, StringComparison.Ordinal); + if (decimalSeparatorIndex == -1) + { + return TryParseInteger(valueString, parseNumberStyles, formatProvider, out quantityValue); // TODO check if the parseNumberStyles need to be adjusted + } + + // 3. try to parse the numerator + var numeratorString = valueString.Substring(0, decimalSeparatorIndex) + valueString.Substring(decimalSeparatorIndex + 1); + if (!BigInteger.TryParse(numeratorString, parseNumberStyles, formatProvider, out BigInteger numerator)) + { + quantityValue = default; + return false; + } + + // 4. construct the fraction using the corresponding decimal power for the denominator + var nbDecimals = valueString.Length - decimalSeparatorIndex - 1; + var denominator = BigInteger.Pow(Ten, nbDecimals); + quantityValue = new QuantityValue(numerator, denominator); + return true; + } + + private static bool TryParseInteger(string valueString, NumberStyles parseNumberStyles, IFormatProvider? formatProvider, out QuantityValue quantityValue) + { + if (BigInteger.TryParse(valueString, parseNumberStyles, formatProvider, out BigInteger bigInteger)) + { + quantityValue = new QuantityValue(bigInteger); + return true; + } + + quantityValue = default; + return false; + } + +} diff --git a/UnitsNet/QuantityValue.ToString.cs b/UnitsNet/QuantityValue.ToString.cs new file mode 100644 index 0000000000..d40f5f19ba --- /dev/null +++ b/UnitsNet/QuantityValue.ToString.cs @@ -0,0 +1,725 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Globalization; +using System.Numerics; +using System.Text; +using Fractions; + +namespace UnitsNet; + +public readonly partial struct QuantityValue +{ + /// Returns the string representation of the numeric value. + public override string ToString() + { + return ToString("G"); + } + + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// + /// A standard numeric format string (must be valid for either double or decimal, depending on the + /// base type) + /// + /// The string representation + public string ToString(string format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// The culture to use + /// The string representation + public string ToString(IFormatProvider? formatProvider) + { + return ToString(string.Empty, formatProvider); + } + + /// + /// Returns the string representation of the underlying value + /// + /// + /// Standard format specifiers. Because the underlying value can be double or decimal, the meaning can + /// vary + /// + /// Culture specific settings + /// A string representation of the number + public string ToString(string? format, IFormatProvider? formatProvider) + { + return formatProvider?.GetFormat(typeof(QuantityValue)) is ICustomFormatter formatter + ? formatter.Format(format, this, formatProvider) + : DefaultQuantityValueFormatter.Instance.Format(format, _fraction, formatProvider); + } +} + +internal class DefaultQuantityValueFormatter : ICustomFormatter +{ + /// + /// + /// + /// On .NET Framework and .NET Core up to .NET Core 2.0, the runtime selects the result with the greater least + /// significant digit (that is, using ). + /// + /// + /// On .NET Core 2.1 and later, the runtime selects the result with an even least significant digit (that is, + /// using ). + /// + /// + /// + private const MidpointRounding DefaultMidpointRoundingMode = +#if NETCOREAPP2_1_OR_GREATER + MidpointRounding.ToEven; +#else + MidpointRounding.AwayFromZero; +#endif + + public static readonly ICustomFormatter Instance = new DefaultQuantityValueFormatter(); + private static readonly BigInteger Ten = new(10); + + public string Format(string? format, object? arg, IFormatProvider? formatProvider) + { + if (arg is not Fraction fraction) + { + throw new FormatException(); + } + + formatProvider ??= CultureInfo.CurrentCulture; + var numberFormatInfo = (NumberFormatInfo)formatProvider.GetFormat(typeof(NumberFormatInfo))!; + + // TODO include these once they become supported + // if (fraction.Denominator == BigInteger.Zero) + // { + // if (fraction.Numerator == BigInteger.Zero) + // { + // return numberFormatInfo.NaNSymbol; + // } + // + // if (fraction.Numerator == BigInteger.One) + // { + // return numberFormatInfo.PositiveInfinitySymbol; + // } + // + // if (fraction.Numerator == BigInteger.MinusOne) + // { + // return numberFormatInfo.NegativeInfinitySymbol; + // } + // } + + if (format is null or "") + { + return FormatGeneral(fraction, "g", numberFormatInfo); + } + + var formatCharacter = format[0]; + return formatCharacter switch + { + 'g' or 'G' => FormatGeneral(fraction, format, numberFormatInfo), + 'f' or 'F' => FormatWithFixedPointFormat(fraction, format, numberFormatInfo), + 'n' or 'N' => FormatWithStandardNumericFormat(fraction, format, numberFormatInfo), + 'e' or 'E' => FormatWithScientificFormat(fraction, format, numberFormatInfo), + 'r' or 'R' => FormatGeneral(fraction, "G32", numberFormatInfo), // TODO see about replacing this with the "1/3" format + // 'p' or 'P' => fraction.ToDouble().ToString(format, formatProvider), // TODO see about implementing this + // 'c' or 'C' => fraction.ToDouble().ToString(format, formatProvider), // TODO see about implementing this + 's' or 'S' => FormatWithSignificantDigitsAfterRadix(fraction, format, numberFormatInfo), + _ => fraction.ToDouble() + .ToString(format, formatProvider) // (not implemented|custom formats) handed over to the double (possible loss of precision) + }; + } + + private static int GetPrecisionDigitsOrDefault(string format, int defaultValue) + { + return format.Length > 1 ? GetPrecisionDigits(format) : defaultValue; + } + + private static int GetPrecisionDigits(string format) + { + if (!int.TryParse(format.Substring(1), out var nbDecimals) || nbDecimals < 0) + { + throw new FormatException($"The {format} format string is not supported."); + } + + return nbDecimals; + } + + /// + /// Handles the standard decimal formats "Fx" + /// + /// + /// The fixed-point ("F") format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" + /// indicates a digit (0-9). The string starts with a minus sign if the number is negative. + /// + /// + /// + /// + /// The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the + /// current NumberFormatInfo.NumberDecimalDigits property supplies the numeric precision. + /// + private static string FormatWithFixedPointFormat(Fraction fraction, string format, NumberFormatInfo formatProvider) + { + if (fraction.Numerator == BigInteger.Zero) + { + return 0d.ToString(format, formatProvider); + } + + if (fraction.Denominator.IsOne) + { + return fraction.Numerator.ToString(format, formatProvider)!; + } + + var maxNbDecimalsAfterRadix = GetPrecisionDigitsOrDefault(format, formatProvider.NumberDecimalDigits); + + var sb = new StringBuilder(12 + maxNbDecimalsAfterRadix); + +#if NETCOREAPP2_1_OR_GREATER + if (fraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + fraction = fraction.Abs(); + } + + if (maxNbDecimalsAfterRadix == 0) + { + return sb.Append(Round(fraction.Numerator, fraction.Denominator).ToString(format, formatProvider)!).ToString(); + } + + Fraction roundedFraction = Round(fraction, maxNbDecimalsAfterRadix); + if (roundedFraction.Numerator.IsZero || roundedFraction.Denominator.IsOne) + { + return sb.Append(roundedFraction.Numerator.ToString(format, formatProvider)!).ToString(); + } + + return AppendDecimals(sb, roundedFraction, formatProvider, maxNbDecimalsAfterRadix).ToString(); +#else + // On .NET Framework and .NET Core up to .NET Core 2.0 the string format does not append the '-' sign when a value is rounded to 0. + if (maxNbDecimalsAfterRadix == 0) + { + return sb.Append(Round(fraction.Numerator, fraction.Denominator).ToString(format, formatProvider)!).ToString(); + } + + Fraction roundedFraction = Round(fraction, maxNbDecimalsAfterRadix); + if (roundedFraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + roundedFraction = roundedFraction.Abs(); + } + + if (roundedFraction.Numerator.IsZero || roundedFraction.Denominator.IsOne) + { + return sb.Append(roundedFraction.Numerator.ToString(format, formatProvider)!).ToString(); + } + + return AppendDecimals(sb, roundedFraction, formatProvider, maxNbDecimalsAfterRadix).ToString(); +#endif + } + + /// + /// Handles the standard decimal formats: "Fx" and "Nx" + /// + /// + /// The fixed-point ("F") format specifier converts a number to a string of the form "-ddd.ddd…" where each "d" + /// indicates a digit (0-9). The string starts with a minus sign if the number is negative. + /// + /// + /// The numeric ("N") format specifier converts a number to a string of the form "-d,ddd,ddd.ddd…", where "-" + /// indicates + /// a negative number symbol if required, "d" indicates a digit (0-9), "," indicates a group separator, and "." + /// indicates a decimal point symbol. + /// + /// + /// + /// + /// The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the + /// current NumberFormatInfo.NumberDecimalDigits property supplies the numeric precision. + /// + private static string FormatWithStandardNumericFormat(Fraction fraction, string format, NumberFormatInfo formatProvider) + { + if (formatProvider.NumberNegativePattern != 1 && formatProvider.NumberNegativePattern != 2) + { + // TODO see about implementing the other patterns if necessary + // https://learn.microsoft.com/en-us/dotnet/api/system.globalization.numberformatinfo.numbernegativepattern?view=netframework-4.8 + throw new NotSupportedException($"The selected NumberNegativePattern is not currently not supported by the {nameof(DefaultQuantityValueFormatter)}."); + } + + if (fraction.Numerator == BigInteger.Zero) + { + return 0d.ToString(format, formatProvider); + } + + if (fraction.Denominator.IsOne) + { + return fraction.Numerator.ToString(format, formatProvider)!; + } + + var maxNbDecimals = GetPrecisionDigitsOrDefault(format, formatProvider.NumberDecimalDigits); + + var sb = new StringBuilder(3 + maxNbDecimals); + + #if NETCOREAPP2_1_OR_GREATER + if (fraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + if (formatProvider.NumberNegativePattern == 2) + { + sb.Append(' '); + } + + fraction = fraction.Abs(); + } + + if (maxNbDecimals == 0) + { + return sb.Append(Round(fraction.Numerator, fraction.Denominator).ToString(format, formatProvider)!).ToString(); + } + + Fraction roundedFraction = Round(fraction, maxNbDecimals); + if (roundedFraction.Numerator.IsZero || roundedFraction.Denominator.IsOne) + { + return sb.Append(roundedFraction.Numerator.ToString(format, formatProvider)!).ToString(); + } + + return AppendDecimals(sb, roundedFraction, formatProvider, maxNbDecimals, "N0").ToString(); + #else + // On .NET Framework and .NET Core up to .NET Core 2.0 the string format does not append the '-' sign when a value is rounded to 0. + if (maxNbDecimals == 0) + { + return sb.Append(Round(fraction.Numerator, fraction.Denominator).ToString(format, formatProvider)!).ToString(); + } + + Fraction roundedFraction = Round(fraction, maxNbDecimals); + if (roundedFraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + if (formatProvider.NumberNegativePattern == 2) + { + sb.Append(' '); + } + + roundedFraction = roundedFraction.Abs(); + } + + if (roundedFraction.Numerator.IsZero || roundedFraction.Denominator.IsOne) + { + return sb.Append(roundedFraction.Numerator.ToString(format, formatProvider)!).ToString(); + } + + return AppendDecimals(sb, roundedFraction, formatProvider, maxNbDecimals, "N0").ToString(); + #endif + } + + /// + /// Exponential format specifier (E) + /// The exponential ("E") format specifier converts a number to a string of the form "-d.ddd…E+ddd" or "-d.ddd…e+ddd", + /// where each "d" indicates a digit (0-9). The string starts with a minus sign if the number is negative. Exactly one + /// digit always precedes the decimal point. + /// The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier + /// is omitted, a default of six digits after the decimal point is used. + /// The case of the format specifier indicates whether to prefix the exponent with an "E" or an "e". The exponent + /// always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet + /// this minimum, if required. + /// + private static string FormatWithScientificFormat(Fraction fraction, string format, NumberFormatInfo formatProvider) + { + if (fraction.Numerator == BigInteger.Zero) + { + return 0d.ToString(format, formatProvider); + } + + if (fraction.Denominator.IsOne) + { + return fraction.Numerator.ToString(format, formatProvider)!; + } + + var maxNbDecimals = GetPrecisionDigitsOrDefault(format, 6); + var sb = new StringBuilder(6 + maxNbDecimals); + + if (fraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + fraction = fraction.Abs(); + } + + var exponent = GetExponentPower(fraction, out BigInteger exponentTerm); + Fraction mantissa = exponent switch + { + 0 => Round(fraction, maxNbDecimals), + > 0 => Round(fraction / exponentTerm, maxNbDecimals), + _ => Round(fraction * exponentTerm, maxNbDecimals) + }; + + if (mantissa.Denominator.IsOne) + { + sb.Append(mantissa.Numerator.ToString($"F{maxNbDecimals}", formatProvider)); + } + else + { + AppendDecimals(sb, mantissa, formatProvider, maxNbDecimals); + } + + return WithAppendedExponent(sb, exponent, formatProvider, format[0]); + + static string WithAppendedExponent(StringBuilder sb, int exponent, NumberFormatInfo numberFormat, char exponentSymbol) + { + return exponent >= 0 + ? sb.Append(exponentSymbol).Append(numberFormat.PositiveSign).Append(exponent.ToString("D3", numberFormat)).ToString() + : sb.Append(exponentSymbol).Append(exponent.ToString("D3", numberFormat)).ToString(); + } + } + + /// + /// The general ("G") format specifier converts a number to the more compact of either fixed-point or scientific + /// notation, depending on the type of the number and whether a precision specifier is present. The precision specifier + /// defines the maximum number of significant digits that can appear in the result string. If the precision specifier + /// is omitted or zero, the type of the number determines the default precision. + /// + private static string FormatGeneral(Fraction fraction, string format, NumberFormatInfo formatProvider) + { + if (fraction.Numerator == BigInteger.Zero) + { + return 0d.ToString(format, formatProvider); + } + + var maxNbDecimals = GetPrecisionDigitsOrDefault(format, 19); + if (maxNbDecimals == 0) + { + maxNbDecimals = 19; + } + + var sb = new StringBuilder(3 + maxNbDecimals); + + if (fraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + fraction = fraction.Abs(); + } + + var exponent = GetExponentPower(fraction, out BigInteger exponentTerm); + + if (exponent == maxNbDecimals - 1) + { + // integral result: both 123400 (1.234e5) and 123400.01 (1.234001e+005) result in "123400" with the "G6" format + return sb.Append(Round(fraction.Numerator, fraction.Denominator)).ToString(); + } + + if (exponent > maxNbDecimals - 1) + { + // we are required to shorten down a number of the form 123400 (1.234E+05) + Fraction mantissa = Round(fraction / exponentTerm, maxNbDecimals - 1); + AppendSignificantDecimals(sb, mantissa, formatProvider, maxNbDecimals - 1); + return AppendExponentWithSignificantDigits(sb, exponent, formatProvider, format[0] is 'g' ? 'e' : 'E').ToString(); + } + + switch (exponent) + { + case >= 0: // the required number of significant digits is less than the specified limit: e.g. 123.45 with the "G20" + return AppendSignificantDecimals(sb, fraction, formatProvider, maxNbDecimals - exponent - 1).ToString(); + case <= -5: // the largest value would have the form: 1.23e-5 (0.000123) + Fraction mantissa = Round(fraction * exponentTerm, maxNbDecimals - 1); + AppendSignificantDecimals(sb, mantissa, formatProvider, maxNbDecimals - 1); + return AppendExponentWithSignificantDigits(sb, exponent, formatProvider, format[0] is 'g' ? 'e' : 'E').ToString(); + default: + // the smallest value would have the form: 1.23e-4 (0.00123) + Fraction roundedDecimal = Round(fraction, maxNbDecimals - exponent - 1); + return AppendSignificantDecimals(sb, roundedDecimal, formatProvider, maxNbDecimals - exponent - 1).ToString(); + } + } + + /// + /// Formats the given fraction with a specified number of significant digits after the radix point. + /// + /// The fraction to format. + /// + /// The format string to use. The format string should specify the maximum number of digits after the + /// radix point. + /// + /// An object that supplies culture-specific formatting information. + /// + /// A string representation of the fraction, formatted with the specified number of significant digits after the + /// radix point. + /// + /// + /// The method formats the fraction based on the absolute value of the fraction: + /// + /// + /// For values greater than 1e5 (e.g., 1230000), the fraction is formatted as a number with an exponent (e.g., + /// 1.23e6). + /// + /// + /// For values less than or equal to 1e-4 (e.g., 0.000123), the fraction is formatted as a number with an + /// exponent (e.g., 1.23e-4). + /// + /// + /// For values between 1e-3 and 1e5 (e.g., 0.00123 to 123000), the fraction is formatted as a decimal number. + /// + /// + /// + private static string FormatWithSignificantDigitsAfterRadix(Fraction fraction, string format, NumberFormatInfo formatProvider) + { + if (fraction.Numerator == BigInteger.Zero) + { + return 0d.ToString(formatProvider); + } + + const string quotientFormat = "N0"; + var maxDigitsAfterRadix = GetPrecisionDigitsOrDefault(format, 2); + + var sb = new StringBuilder(3 + maxDigitsAfterRadix); + + if (fraction.IsNegative) + { + sb.Append(formatProvider.NegativeSign); + fraction = fraction.Abs(); + } + + var exponent = GetExponentPower(fraction, out BigInteger exponentTerm); + Fraction mantissa; + switch (exponent) + { + case > 5: // the smallest value would have the form: 1.23e6 (1230000) + mantissa = Round(fraction / exponentTerm, maxDigitsAfterRadix); + AppendSignificantDecimals(sb, mantissa, formatProvider, maxDigitsAfterRadix, quotientFormat); + return AppendExponentWithSignificantDigits(sb, exponent, formatProvider, format[0] is 's' ? 'e' : 'E').ToString(); + case <= -4: // the largest value would have the form: 1.23e-4 (0.000123) + mantissa = Round(fraction * exponentTerm, maxDigitsAfterRadix); + AppendSignificantDecimals(sb, mantissa, formatProvider, maxDigitsAfterRadix, quotientFormat); + return AppendExponentWithSignificantDigits(sb, exponent, formatProvider, format[0] is 's' ? 'e' : 'E').ToString(); + case < 0: // the smallest value would have the form: 1.23e-3 (0.00123) + var leadingZeroes = -exponent; + maxDigitsAfterRadix += leadingZeroes - 1; + mantissa = Round(fraction, maxDigitsAfterRadix); + return AppendSignificantDecimals(sb, mantissa, formatProvider, maxDigitsAfterRadix, quotientFormat).ToString(); + default: // the largest value would have the form: 1.23e5 (123000) + mantissa = Round(fraction, maxDigitsAfterRadix); + return AppendSignificantDecimals(sb, mantissa, formatProvider, maxDigitsAfterRadix, quotientFormat).ToString(); + } + } + + + private static StringBuilder AppendDecimals(StringBuilder sb, Fraction fraction, NumberFormatInfo formatProvider, int nbDecimals, + string quotientFormat = "F0", + MidpointRounding roundingMode = DefaultMidpointRoundingMode) + { + var quotient = BigInteger.DivRem(fraction.Numerator, fraction.Denominator, out BigInteger remainder); + + sb.Append(quotient.ToString(quotientFormat, formatProvider)).Append(formatProvider.NumberDecimalSeparator); + + remainder = BigInteger.Abs(remainder); + + var decimalsAdded = 0; + while (!remainder.IsZero && decimalsAdded++ < nbDecimals - 1) + { + quotient = BigInteger.DivRem(remainder * Ten, fraction.Denominator, out remainder); + sb.Append(quotient.ToString(formatProvider)); + } + + if (remainder.IsZero) + { + sb.Append('0', nbDecimals - decimalsAdded); + } + else + { + quotient = Round(remainder * Ten, fraction.Denominator, roundingMode); + sb.Append(quotient.ToString(formatProvider)); + } + + return sb; + } + + private static StringBuilder AppendSignificantDecimals(StringBuilder sb, Fraction mantissa, NumberFormatInfo formatProvider, int maxNbDecimals, + string quotientFormat = "F0") + { + var quotient = BigInteger.DivRem(mantissa.Numerator, mantissa.Denominator, out BigInteger remainder); + + sb.Append(quotient.ToString(quotientFormat, formatProvider)); + + if (remainder.IsZero) + { + return sb; + } + + sb.Append(formatProvider.NumberDecimalSeparator); + + var nbDecimals = 0; + while (nbDecimals++ < maxNbDecimals - 1) + { + quotient = BigInteger.DivRem(remainder * Ten, mantissa.Denominator, out remainder); + sb.Append(quotient.ToString(formatProvider)); + if (remainder == BigInteger.Zero) + { + return sb; + } + } + + quotient = Round(remainder * Ten, mantissa.Denominator); + sb.Append(quotient.ToString(formatProvider)); + return sb; + } + + private static StringBuilder AppendExponentWithSignificantDigits(StringBuilder sb, int exponent, NumberFormatInfo formatProvider, char exponentSymbol) + { + return exponent switch + { + <= -1000 => sb.Append(exponentSymbol).Append(exponent.ToString(formatProvider)), + <= 0 => sb.Append(exponentSymbol).Append(exponent.ToString("D2", formatProvider)), + < 100 => sb.Append(exponentSymbol).Append(formatProvider.PositiveSign).Append(exponent.ToString("D2", formatProvider)), + < 1000 => sb.Append(exponentSymbol).Append(formatProvider.PositiveSign).Append(exponent.ToString("D3", formatProvider)), + _ => sb.Append(exponentSymbol).Append(formatProvider.PositiveSign).Append(exponent.ToString(formatProvider)) + }; + } + + #region Rounding functions (would probably become redundant soon) + + /// + /// Rounds the given Fraction to the specified number of digits. + /// + /// The Fraction to be rounded. + /// The number of decimal places in the return value. + /// + /// A new Fraction that is the nearest number with the specified number of digits. + private static Fraction Round(Fraction x, int nbDigits, MidpointRounding rounding = DefaultMidpointRoundingMode) + { + var factor = BigInteger.Pow(Ten, nbDigits); + BigInteger roundedNumerator = Round(x.Numerator * factor, x.Denominator, rounding); + return new Fraction(roundedNumerator, factor); + } + + /// + /// Rounds the given Fraction to the specified precision using the specified rounding strategy. + /// + /// The numerator of the fraction to be rounded. + /// The denominator of the fraction to be rounded. + /// One of the enumeration values that specifies which rounding strategy to use. + /// The number rounded to using the rounding strategy. + private static BigInteger Round(BigInteger numerator, BigInteger denominator, MidpointRounding mode = DefaultMidpointRoundingMode) + { + if (numerator.IsZero || denominator.IsOne) + { + return numerator; + } + + return mode switch + { + MidpointRounding.AwayFromZero => RoundAwayFromZero(numerator, denominator), + MidpointRounding.ToEven => RoundToEven(numerator, denominator), +#if NET + MidpointRounding.ToZero => BigInteger.Divide(numerator, denominator), + MidpointRounding.ToPositiveInfinity => RoundToPositiveInfinity(numerator, denominator), + MidpointRounding.ToNegativeInfinity => RoundToNegativeInfinity(numerator, denominator), +#endif + _ => throw new ArgumentOutOfRangeException(nameof(mode)) + }; + + static BigInteger RoundAwayFromZero(BigInteger numerator, BigInteger denominator) + { + return numerator.Sign == denominator.Sign + ? BigInteger.Divide(numerator + denominator / 2, denominator) + : BigInteger.Divide(numerator - denominator / 2, denominator); + } + + static BigInteger RoundToEven(BigInteger numerator, BigInteger denominator) + { + var quotient = BigInteger.DivRem(numerator, denominator, out BigInteger remainder); + BigInteger half = denominator / 2; + if (numerator.Sign == denominator.Sign) + { + // For positive values or when both values are negative + if (remainder > half || (remainder == half && !quotient.IsEven)) + { + return quotient + 1; + } + } + else + { + // For negative values + remainder = -remainder; + if (remainder > half || (remainder == half && !quotient.IsEven)) + { + return quotient - 1; + } + } + + return quotient; + } +#if NET + static BigInteger RoundToPositiveInfinity(BigInteger numerator, BigInteger denominator) { + var quotient = BigInteger.DivRem(numerator, denominator, out var remainder); + return remainder.Sign == 1 ? quotient + 1 : quotient; + } + + static BigInteger RoundToNegativeInfinity(BigInteger numerator, BigInteger denominator) { + var quotient = BigInteger.DivRem(numerator, denominator, out var remainder); + return remainder.Sign == -1 ? quotient - 1 : quotient; + } +#endif + } + + #endregion + + private static int GetExponentPower(Fraction fraction, out BigInteger powerOfTen) + { + // if (fraction.IsZero) + // return 1; + // fraction = fraction.Abs(); + // if (fraction == Fraction.One) + // return 1; + + if (fraction.Numerator > fraction.Denominator) + { + var nbDigits = CountDigits(fraction.Numerator / fraction.Denominator, out powerOfTen); + if (fraction.Numerator * powerOfTen < Ten * fraction.Denominator) + { + return nbDigits; + } + + powerOfTen /= Ten; + return nbDigits - 1; + } + else + { + var nbDigits = CountDigits(fraction.Denominator / fraction.Numerator, out powerOfTen); + if (fraction.Numerator * powerOfTen < Ten * fraction.Denominator) + { + return -nbDigits; + } + + powerOfTen /= Ten; + return -nbDigits + 1; + } + } + +#if NET5_0_OR_GREATER + private static readonly double Log10Of2 = Math.Log10(2); + private static int CountDigits(BigInteger value, out BigInteger powerOfTen) + { + var numBits = value.GetBitLength(); + var base10Digits = (int)(numBits * Log10Of2); + powerOfTen = BigInteger.Pow(Ten, base10Digits); + + if (value < powerOfTen) + { + return base10Digits; + } + + powerOfTen *= Ten; + return base10Digits + 1; + } +#else + private static int CountDigits(BigInteger value, out BigInteger powerOfTen) + { + var base10Digits = (int)Math.Ceiling(BigInteger.Log10(value)); + powerOfTen = BigInteger.Pow(Ten, base10Digits); + + if (value < powerOfTen) + { + return base10Digits; + } + + powerOfTen *= Ten; + return base10Digits + 1; + } +#endif +} diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs new file mode 100644 index 0000000000..46aff2f5c7 --- /dev/null +++ b/UnitsNet/QuantityValue.cs @@ -0,0 +1,231 @@ +// 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.ComponentModel; +using System.Numerics; +using System.Runtime.Serialization; +using Fractions; + +namespace UnitsNet; + +/// +/// A type that supports implicit cast from all .NET numeric types, in order to avoid a large number of overloads +/// and binary size for all From(value, unit) factory methods, for each of the 700+ units in the library. +/// stores the value internally using a fraction represented by two +/// , allowing it to represent arbitrary values without loss of precision. +/// +/// +/// +/// At the time of this writing, this reduces the number of From(value, unit) overloads to 1/4th: +/// From 8 (int, long, double, decimal + each nullable) down to 2 (QuantityValue and QuantityValue?). +/// This also adds more numeric types with no extra overhead, such as float, short and byte. +/// +/// +[DataContract] +[TypeConverter(typeof (QuantityValueTypeConverter))] +public readonly partial struct QuantityValue : IFormattable, IConvertible, IEquatable, IComparable, IComparable +{ + /// + /// The value 0 + /// + public static readonly QuantityValue Zero = new(Fraction.Zero); + + [DataMember(Name = "Fraction")] + private readonly Fraction _fraction; // TODO the struct is missing the [DataContract] definition + + private QuantityValue(Fraction value) + { + _fraction = value; + } + + /// + /// Construct using a value and . + /// + /// Numerator + /// Denominator + public QuantityValue(BigInteger numerator, BigInteger denominator) + { + _fraction = new Fraction(numerator, denominator, true); + } + + /// + /// Construct using a value and . + /// + /// Numerator + /// Denominator + /// If true the fraction will be created as reduced/simplified fraction. + /// Turning off the normalization is only allowed as part of an intermediate calculation (1/2 != 2/4). + internal QuantityValue(BigInteger numerator, BigInteger denominator, bool normalize) + { + _fraction = new Fraction(numerator, denominator, normalize); + } + + /// + /// Deconstructs the QuantityValue object into its numerator and denominator components. + /// + /// Output parameter for the numerator component. + /// Output parameter for the denominator component. + public void Deconstruct(out BigInteger numerator, out BigInteger denominator) + { + numerator = _fraction.Numerator; + denominator = _fraction.Denominator; + } + + + #region Math Operators + + /// + /// Adds two QuantityValue instances. + /// + /// The first QuantityValue. + /// The second QuantityValue. + /// The sum of the two QuantityValue instances. + public static QuantityValue operator +(QuantityValue a, QuantityValue b) + { + return new QuantityValue(a._fraction + b._fraction); + } + + /// + /// Subtracts one QuantityValue from another. + /// + /// The QuantityValue to subtract from. + /// The QuantityValue to subtract. + /// The difference between the two QuantityValue instances. + public static QuantityValue operator -(QuantityValue a, QuantityValue b) + { + return new QuantityValue(a._fraction - b._fraction); + } + + /// + /// Returns the negated value of the operand + /// + /// Value to negate + /// -v + public static QuantityValue operator -(QuantityValue v) + { + return new QuantityValue(-1 * v._fraction); + } + + /// + /// Multiplies two QuantityValue instances. + /// + /// The first QuantityValue. + /// The second QuantityValue. + /// The product of the two QuantityValue instances. + public static QuantityValue operator *(QuantityValue a, QuantityValue b) + { + return new QuantityValue(a._fraction * b._fraction); + } + + /// + /// Divides one QuantityValue by another. + /// + /// The QuantityValue to divide. + /// The QuantityValue to divide by. + /// The quotient of the two QuantityValue instances. + public static QuantityValue operator /(QuantityValue a, QuantityValue b) + { + return new QuantityValue(a._fraction / b._fraction); + } + + /// + /// Returns the remainder of dividing one QuantityValue by another. + /// + /// The QuantityValue to divide. + /// The QuantityValue to divide by. + /// The remainder of the division of the two QuantityValue instances. + public static QuantityValue operator %(QuantityValue a, QuantityValue b) + { + return new QuantityValue(a._fraction % b._fraction); + } + + /// + /// Raises a QuantityValue to the specified power. + /// + /// The QuantityValue to raise to the power. + /// The power to raise the QuantityValue to. + /// The QuantityValue raised to the specified power. + public static QuantityValue operator ^(QuantityValue a, int power) + { + return new QuantityValue(Fraction.Pow(a._fraction, power)); + } + + /// + /// Raises a QuantityValue to the specified power. + /// + /// The QuantityValue to raise to the power. + /// The power to raise the QuantityValue to. + /// The QuantityValue raised to the specified power. + public static QuantityValue Pow(QuantityValue a, int power) + { + return a ^ power; + } + + /// + /// Calculates the square root of a given QuantityValue. + /// + /// The QuantityValue for which to calculate the square root. + /// The number of decimal places of accuracy for the square root calculation. Default is 30. + /// A new QuantityValue that is the square root of the input QuantityValue. + /// Thrown when the input QuantityValue is negative. + /// Thrown when the accuracy is less than or equal to zero. + /// + /// Uses Babylonian Method of computing square roots: increasing the accuracy would result in longer calculation + /// times. + /// + public static QuantityValue Sqrt(QuantityValue a, int accuracy = 30) + { + return new QuantityValue(a._fraction.Sqrt(accuracy)); + } + + /// + /// Returns the absolute value of a specified . + /// + /// A . + /// The absolute value of . + public static QuantityValue Abs(QuantityValue value) + { + return new QuantityValue(Fraction.Abs(value._fraction)); + } + + /// + /// Calculates and returns the reciprocal of the specified . + /// + /// A whose reciprocal is to be calculated. + /// A new that is the reciprocal of the input value. + /// + /// In mathematics, a multiplicative inverse or reciprocal for a number x, denoted by 1/x or x^-1, is a + /// number + /// which when multiplied by x yields the multiplicative identity, 1. The multiplicative inverse of a fraction a/b is + /// b/a. For the multiplicative inverse of a real number, divide 1 by the number. For example, the reciprocal of 5 is + /// one fifth (1/5 or 0.2), and the reciprocal of 0.25 is 1 divided by 0.25, or 4. + /// + public static QuantityValue Inverse(QuantityValue value) + { + return new QuantityValue(value._fraction.Reciprocal()); + } + + /// + /// Rounds the given QuantityValue to the specified number of digits. + /// + /// The QuantityValue to be rounded. + /// The number of decimal places in the return value. + /// A new QuantityValue that is the nearest number with the specified number of digits. + public static QuantityValue Round(QuantityValue x, int nbDigits) + { + var factor = BigInteger.Pow(10, nbDigits); + BigInteger numerator = x._fraction.Numerator * factor; + BigInteger denominator = x._fraction.Denominator; + BigInteger roundedNumerator; + roundedNumerator = numerator.Sign < 0 + ? BigInteger.Divide(numerator - denominator / 2, denominator) + : BigInteger.Divide(numerator + denominator / 2, denominator); + + return new QuantityValue(roundedNumerator, factor); + } + + + #endregion + +} diff --git a/UnitsNet/QuantityValueComparison.cs b/UnitsNet/QuantityValueComparison.cs new file mode 100644 index 0000000000..09408b872d --- /dev/null +++ b/UnitsNet/QuantityValueComparison.cs @@ -0,0 +1,124 @@ +// 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; + +namespace UnitsNet; + +/// +/// Helper methods to perform relative and absolute comparison. +/// +public static class QuantityValueComparison +{ + /// + /// + /// Checks if two values are equal with a given relative or absolute tolerance. + /// + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// Equals(a, b, 0.01, ComparisonType.Relative); + /// + /// + /// + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// + /// The reference value. If using relative tolerance, it is the value which the relative + /// tolerance will be calculated against. + /// + /// The value to compare to. + /// The absolute or relative tolerance value. Must be greater than or equal to 0. + /// Whether the tolerance is absolute or relative. + /// + public static bool Equals(QuantityValue referenceValue, QuantityValue otherValue, QuantityValue tolerance, ComparisonType comparisonType) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); + + switch (comparisonType) + { + case ComparisonType.Relative: + return EqualsRelative(referenceValue, otherValue, tolerance); + case ComparisonType.Absolute: + return EqualsAbsolute(referenceValue, otherValue, tolerance); + default: + throw new InvalidOperationException("The given ComparisonType is not supported."); + } + } + + /// + /// Checks if two values are equal with a given relative tolerance. + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// EqualsRelative(a, b, 0.01); + /// + /// + /// + /// + /// The reference value which the tolerance will be calculated against. + /// The value to compare to. + /// The relative tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given relative tolerance, otherwise false. + public static bool EqualsRelative(QuantityValue referenceValue, QuantityValue otherValue, QuantityValue tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); + + var maxVariation = QuantityValue.Abs(referenceValue * tolerance); + return QuantityValue.Abs(referenceValue - otherValue) <= maxVariation; + } + + /// + /// Checks if two values are equal with a given absolute tolerance. + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// The first value. + /// The second value. + /// The absolute tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given absolute tolerance, otherwise false. + public static bool EqualsAbsolute(QuantityValue value1, QuantityValue value2, QuantityValue tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); + + return QuantityValue.Abs(value1 - value2) <= tolerance; + } +} diff --git a/UnitsNet/QuantityValueTypeConverter.cs b/UnitsNet/QuantityValueTypeConverter.cs new file mode 100644 index 0000000000..fad4b3c7b5 --- /dev/null +++ b/UnitsNet/QuantityValueTypeConverter.cs @@ -0,0 +1,136 @@ +// 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.ComponentModel; +using System.Globalization; +using System.Numerics; +using Fractions; + +namespace UnitsNet; + +/// +/// +public class QuantityValueTypeConverter : TypeConverter +{ + // TODO see about maybe implementing these without the lookup + private static readonly HashSet Supported_Types = + [ + typeof(string), + typeof(int), + typeof(long), + typeof(decimal), + typeof(double), + typeof(QuantityValue), + typeof(Fraction), + typeof(BigInteger) + ]; + + private static readonly Dictionary> Convert_To_Dictionary = + new() + { + { typeof(string), (o, info) => ((QuantityValue)o).ToString(info) }, + { typeof(int), (o, _) => (int)(QuantityValue)o }, + { typeof(long), (o, _) => (long)(QuantityValue)o }, + { typeof(decimal), (o, _) => ((QuantityValue)o).ToDecimal() }, + { typeof(double), (o, _) => ((QuantityValue)o).ToDouble() }, + { + typeof(Fraction), (o, _) => + { + (BigInteger numerator, BigInteger denominator) = (QuantityValue)o; + return new Fraction(numerator, denominator); + } + }, + { typeof(BigInteger), (o, _) => (BigInteger)(QuantityValue)o }, + { typeof(QuantityValue), (o, _) => (QuantityValue)o } + }; + + private static readonly Dictionary> Convert_From_Dictionary = + new() + { + { typeof(string), (o, info) => QuantityValue.Parse((string)o, info) }, + { typeof(int), (o, _) => new QuantityValue((int)o, 1) }, + { typeof(long), (o, _) => new QuantityValue((long)o, 1) }, + { typeof(decimal), (o, _) => QuantityValue.FromDecimal((decimal)o) }, + { typeof(double), (o, _) => QuantityValue.FromDoubleRounded((double)o) }, + { + typeof(Fraction), (o, _) => + { + var fraction = (Fraction)o; + return new QuantityValue(fraction.Numerator, fraction.Denominator); + } + }, + { typeof(BigInteger), (o, _) => new QuantityValue((BigInteger)o, 1) }, + { typeof(QuantityValue), (o, _) => (QuantityValue)o } + }; + + /// + /// Returns whether the type converter can convert an object to the specified type. + /// + /// An object that provides a format context. + /// The type you want to convert to. + /// true if this converter can perform the conversion; otherwise, false. + public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) + { + return destinationType != null && Supported_Types.Contains(destinationType); + } + + /// + /// Returns whether this converter can convert an object of the given type to the type of this converter, using the + /// specified context. + /// + /// An that provides a format context. + /// A that represents the type you want to convert from. + /// trueif this converter can perform the conversion; otherwise, false. + public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) + { + return Supported_Types.Contains(sourceType); + } + + /// + /// Converts the given value object to the specified type, using the specified context and culture information. + /// + /// An that provides a format context. + /// A CultureInfo. If null is passed, the current culture is assumed. + /// The to convert. + /// The to convert the value parameter to. + /// An that represents the converted value. + public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, + Type destinationType) + { + if (value is not null && Convert_To_Dictionary.TryGetValue(destinationType, out Func? func)) + { + return func(value, culture); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + /// + /// Converts the given object to the type of this converter, using the specified context and culture information. + /// + /// An that provides a format context. + /// The to use as the current culture. + /// The to convert. + /// An that represents the converted value. + public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value) + { + if (value is null) + { + return QuantityValue.Zero; + } + + if (Convert_From_Dictionary.TryGetValue(value.GetType(), out Func? func)) + { + return func(value, culture); + } + + if (context is null || culture is null) + { + return ConvertFrom(value); + } + + return base.ConvertFrom(context, culture, value); + } +} diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 4f030b422b..113ca4fedd 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -278,7 +278,7 @@ public bool TryGetConversionFunction(ConversionFunctionLookupKey lookupKey, [Not /// From unit enum value. /// To unit enum value, must be compatible with . /// The converted value in the new unit representation. - public static double Convert(double fromValue, Enum fromUnitValue, Enum toUnitValue) + public static QuantityValue Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) { return Quantity .From(fromValue, fromUnitValue) @@ -293,7 +293,7 @@ public static double Convert(double fromValue, Enum fromUnitValue, Enum toUnitVa /// To unit enum value, must be compatible with . /// The converted value, if successful. Otherwise default. /// True if successful. - public static bool TryConvert(double fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) + public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out QuantityValue convertedValue) { convertedValue = 0; if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity? fromQuantity)) @@ -330,7 +330,7 @@ public static bool TryConvert(double fromValue, Enum fromUnitValue, Enum toUnitV /// Output value as the result of converting to . /// No units match the abbreviation. /// More than one unit matches the abbreviation. - public static double ConvertByName(double fromValue, string quantityName, string fromUnit, string toUnit) + public static QuantityValue ConvertByName(QuantityValue fromValue, string quantityName, string fromUnit, string toUnit) { if (!TryParseUnit(quantityName, toUnit, out Enum? toUnitValue)) // ex: LengthUnit.Centimeter { @@ -358,9 +358,9 @@ public static double ConvertByName(double fromValue, string quantityName, string /// Result if conversion was successful, 0 if not. /// bool ok = TryConvertByName(5, "Length", "Meter", "Centimeter", out double centimeters); // 500 /// True if conversion was successful. - public static bool TryConvertByName(double inputValue, string quantityName, string fromUnit, string toUnit, out double result) + public static bool TryConvertByName(QuantityValue inputValue, string quantityName, string fromUnit, string toUnit, out QuantityValue result) { - result = 0d; + result = QuantityValue.Zero; if (!TryGetUnitType(quantityName, out Type? unitType)) return false; @@ -395,7 +395,7 @@ public static bool TryConvertByName(double inputValue, string quantityName, stri /// The abbreviation of the unit in the thread's current culture, such as "m". /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// Output value as the result of converting to . - public static double ConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) + public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) { return ConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, null); } @@ -423,7 +423,7 @@ public static double ConvertByAbbreviation(double fromValue, string quantityName /// are mapped to the abbreviation. /// /// More than one unit matches the abbreviation. - public static double ConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) + public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) { if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); @@ -455,7 +455,7 @@ public static double ConvertByAbbreviation(double fromValue, string quantityName /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result) + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result) { return TryConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, out result, null); } @@ -479,10 +479,10 @@ public static bool TryConvertByAbbreviation(double fromValue, string quantityNam /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result, + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result, string? culture) { - result = 0d; + result = QuantityValue.Zero; if (!TryGetUnitType(quantityName, out Type? unitType)) return false; diff --git a/UnitsNet/UnitFormatter.cs b/UnitsNet/UnitFormatter.cs index 06ecbbf700..245e7f3185 100644 --- a/UnitsNet/UnitFormatter.cs +++ b/UnitsNet/UnitFormatter.cs @@ -10,6 +10,7 @@ namespace UnitsNet /// /// Utility class for formatting units and values. /// + [Obsolete("Implement as a formatter for the QuantityValue")] internal static class UnitFormatter { /// diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index 472f25c9b7..a57083c18d 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -9,6 +9,11 @@ namespace UnitsNet /// public static class UnitMath { + /// + /// Represents the PI constant as a rational fraction. + /// + public static readonly QuantityValue PI = QuantityValue.FromDoubleRounded(Math.PI); + /// Returns the absolute value of a . /// /// A quantity with a value that is greater than or equal to , @@ -30,10 +35,11 @@ public static TQuantity Abs(this TQuantity value) where TQuantity : I /// /// source contains quantity types different from . /// - public static TQuantity Sum(this IEnumerable source, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Sum(this IEnumerable source, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Sum(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From(QuantityValue.FromDoubleRounded(source.Sum(x => x.As(unitType).ToDouble())), unitType); // TODO } /// @@ -44,7 +50,8 @@ public static TQuantity Sum(this IEnumerable source, Enum /// 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 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. @@ -52,8 +59,9 @@ public static TQuantity Sum(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Sum(this IEnumerable source, Func selector, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Sum(this IEnumerable source, Func selector, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return source.Select(selector).Sum(unitType); } @@ -79,8 +87,9 @@ public static TQuantity Min(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// - public static TQuantity Min(this IEnumerable source, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Min(this IEnumerable source, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return (TQuantity) Quantity.From(source.Min(x => x.As(unitType)), unitType); } @@ -93,7 +102,8 @@ public static TQuantity Min(this IEnumerable source, Enum /// 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 quantity that is produced by this operation. + /// The type of unit enum. /// The min of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -102,8 +112,9 @@ public static TQuantity Min(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Min(this IEnumerable source, Func selector, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Min(this IEnumerable source, Func selector, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return source.Select(selector).Min(unitType); } @@ -129,8 +140,9 @@ public static TQuantity Max(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// - public static TQuantity Max(this IEnumerable source, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Max(this IEnumerable source, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return (TQuantity) Quantity.From(source.Max(x => x.As(unitType)), unitType); } @@ -143,7 +155,8 @@ public static TQuantity Max(this IEnumerable source, Enum /// 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 quantity that is produced by this operation. + /// The type of unit enum. /// The max of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -152,8 +165,9 @@ public static TQuantity Max(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Max(this IEnumerable source, Func selector, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Max(this IEnumerable source, Func selector, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return source.Select(selector).Max(unitType); } @@ -169,10 +183,11 @@ public static TQuantity Max(this IEnumerable source /// /// source contains quantity types different from . /// - public static TQuantity Average(this IEnumerable source, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Average(this IEnumerable source, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Average(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From(QuantityValue.FromDoubleRounded(source.Average(x => x.As(unitType).ToDouble())), unitType); // TODO } /// @@ -183,7 +198,8 @@ public static TQuantity Average(this IEnumerable source, E /// 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 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. @@ -192,8 +208,9 @@ public static TQuantity Average(this IEnumerable source, E /// /// source contains quantity types different from . /// - public static TQuantity Average(this IEnumerable source, Func selector, Enum unitType) - where TQuantity : IQuantity + public static TQuantity Average(this IEnumerable source, Func selector, TUnitType unitType) + where TUnitType : Enum + where TQuantity : IQuantity { return source.Select(selector).Average(unitType); } diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index cb2b309e5c..7e67dcc177 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -1,8 +1,8 @@ - + UnitsNet - 6.0.0-pre002 + 6.0.0-pre006 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. @@ -12,7 +12,7 @@ logo-32.png https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png https://github.com/angularsen/UnitsNet - MIT + MIT-0 false unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable README.md @@ -24,7 +24,7 @@ latest enable UnitsNet - netstandard2.0;net7.0 + netstandard2.0;net8.0 @@ -50,7 +50,8 @@ - + +