From 301ecc5d833147d16c1d0b440d7d0d3c6b70bc7d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 24 Nov 2025 11:52:09 +0100 Subject: [PATCH 1/4] Added PoundPerSquareFoot and PoundPerThousandSquareFeet --- Common/UnitDefinitions/AreaDensity.json | 32 ++++++++++++ Common/UnitEnumValues.g.json | 4 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 24 +++++++++ .../GeneratedCode/Units/AreaDensityUnit.g.cs | 2 + .../NumberToAreaDensityExtensionsTest.g.cs | 8 +++ .../NumberToAreaDensityExtensions.g.cs | 16 ++++++ .../NumberToAreaDensityExtensionsTest.g.cs | 8 +++ .../NumberToAreaDensityExtensions.g.cs | 22 ++++++++ UnitsNet.Tests/CustomCode/AreaDensityTests.cs | 4 ++ .../GeneratedCode/IQuantityTests.g.cs | 2 +- .../TestsBase/AreaDensityTestsBase.g.cs | 50 +++++++++++++++++++ .../GeneratedCode/Quantities/AreaDensity.g.cs | 36 +++++++++++++ .../Resources/AreaDensity.restext | 2 + .../GeneratedCode/Units/AreaDensityUnit.g.cs | 2 + global.json | 6 +-- 15 files changed, 213 insertions(+), 5 deletions(-) diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index 4e66410de6..6b523e238e 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -56,6 +56,38 @@ "Abbreviations": [ "mg/m²" ] } ] + }, + { + "SingularName": "PoundPerSquareFoot", + "PluralName": "PoundPerSquareFoot", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * 4.8824", + "FromBaseToUnitFunc": "{x} / 4.8824", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "lbs/ft²", "lbs/SF" ] + } + ] + }, + { + "SingularName": "PoundPerThousandSquareFeet", + "PluralName": "PoundPerThousandSquareFeet", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * 4.8824 / 1000", + "FromBaseToUnitFunc": "{x} / 4.8824 * 1000", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "lbs/MSF" ] + } + ] } ] } diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 3ebdc3d87d..a7d6f6ff94 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -86,7 +86,9 @@ "AreaDensity": { "KilogramPerSquareMeter": 1, "GramPerSquareMeter": 6, - "MilligramPerSquareMeter": 10 + "MilligramPerSquareMeter": 10, + "PoundPerThousandSquareFeet": 3, + "PoundPerSquareFoot": 8 }, "AreaMomentOfInertia": { "CentimeterToTheFourth": 1, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index 5ba01d91a1..4a57d1e4d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -93,6 +93,16 @@ public AreaDensity(double value, AreaDensityUnit unit) /// public double MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + #endregion #region Static Factory Methods @@ -112,6 +122,16 @@ public AreaDensity(double value, AreaDensityUnit unit) /// public static AreaDensity FromMilligramsPerSquareMeter(double milligramspersquaremeter) => new AreaDensity(milligramspersquaremeter, AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerSquareFoot(double poundpersquarefoot) => new AreaDensity(poundpersquarefoot, AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerThousandSquareFeet(double poundperthousandsquarefeet) => new AreaDensity(poundperthousandsquarefeet, AreaDensityUnit.PoundPerThousandSquareFeet); + /// /// Dynamically convert from value and unit enum to . /// @@ -155,6 +175,8 @@ private double GetValueInBaseUnit() AreaDensityUnit.GramPerSquareMeter => _value / 1000, AreaDensityUnit.KilogramPerSquareMeter => _value, AreaDensityUnit.MilligramPerSquareMeter => _value / 1000000, + AreaDensityUnit.PoundPerSquareFoot => _value * 4.8824, + AreaDensityUnit.PoundPerThousandSquareFeet => _value * 4.8824 / 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to base units.") }; } @@ -171,6 +193,8 @@ private double GetValueAs(AreaDensityUnit unit) AreaDensityUnit.GramPerSquareMeter => baseUnitValue * 1000, AreaDensityUnit.KilogramPerSquareMeter => baseUnitValue, AreaDensityUnit.MilligramPerSquareMeter => baseUnitValue * 1000000, + AreaDensityUnit.PoundPerSquareFoot => baseUnitValue / 4.8824, + AreaDensityUnit.PoundPerThousandSquareFeet => baseUnitValue / 4.8824 * 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs index bacdc7e8f4..06c176003f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -33,6 +33,8 @@ public enum AreaDensityUnit GramPerSquareMeter = 6, KilogramPerSquareMeter = 1, MilligramPerSquareMeter = 10, + PoundPerSquareFoot = 8, + PoundPerThousandSquareFeet = 3, } #pragma warning restore 1591 diff --git a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index 5c8fb6a388..158f3dfb23 100644 --- a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -36,5 +36,13 @@ public void NumberToKilogramsPerSquareMeterTest() => public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter); + [Fact] + public void NumberToPoundPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot); + + [Fact] + public void NumberToPoundPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet); + } } diff --git a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 76d03f1fc8..2f868788ef 100644 --- a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -66,6 +66,22 @@ public AreaDensity MilligramsPerSquareMeter => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif + /// + public AreaDensity PoundPerSquareFoot +#if NET7_0_OR_GREATER + => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); +#else + => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); +#endif + + /// + public AreaDensity PoundPerThousandSquareFeet +#if NET7_0_OR_GREATER + => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); +#else + => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); +#endif + } } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index fa46181b00..ef2c0860b9 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -36,5 +36,13 @@ public void NumberToKilogramsPerSquareMeterTest() => public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter()); + [Fact] + public void NumberToPoundPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot()); + + [Fact] + public void NumberToPoundPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet()); + } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 0ce7edeee7..14051bd61b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -65,5 +65,27 @@ public static AreaDensity MilligramsPerSquareMeter(this T value) => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif + /// + public static AreaDensity PoundPerSquareFoot(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber + => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); +#else + , IConvertible + => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); +#endif + + /// + public static AreaDensity PoundPerThousandSquareFeet(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber + => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); +#else + , IConvertible + => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); +#endif + } } diff --git a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs index f9a113d705..964d45f0cb 100644 --- a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs @@ -34,6 +34,10 @@ public class AreaDensityTests : AreaDensityTestsBase protected override double MilligramsPerSquareMeterInOneKilogramPerSquareMeter => 1000000; + protected override double PoundPerSquareFootInOneKilogramPerSquareMeter => 1 / 4.8824; + + protected override double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter => 1000 / 4.8824; + [Fact] public void AreaDensityTimesAreaEqualsMass() { diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 9dfabd182a..cbac582132 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -40,7 +40,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, AmplitudeRatioUnit.DecibelVolt, Quantity.From(3, AmplitudeRatioUnit.DecibelVolt)); Assertion(3, AngleUnit.Revolution, Quantity.From(3, AngleUnit.Revolution)); Assertion(3, AreaUnit.UsSurveySquareFoot, Quantity.From(3, AreaUnit.UsSurveySquareFoot)); - Assertion(3, AreaDensityUnit.MilligramPerSquareMeter, Quantity.From(3, AreaDensityUnit.MilligramPerSquareMeter)); + Assertion(3, AreaDensityUnit.PoundPerThousandSquareFeet, Quantity.From(3, AreaDensityUnit.PoundPerThousandSquareFeet)); Assertion(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth, Quantity.From(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth)); Assertion(3, BitRateUnit.TeraoctetPerSecond, Quantity.From(3, BitRateUnit.TeraoctetPerSecond)); Assertion(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, Quantity.From(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 9389bf8362..2cfbdf08d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -43,11 +43,15 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected abstract double GramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double MilligramsPerSquareMeterInOneKilogramPerSquareMeter { get; } + protected abstract double PoundPerSquareFootInOneKilogramPerSquareMeter { get; } + protected abstract double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global protected virtual double GramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double MilligramsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double PoundPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundPerThousandSquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaDensityUnit unit) @@ -57,6 +61,8 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase AreaDensityUnit.GramPerSquareMeter => (GramsPerSquareMeterInOneKilogramPerSquareMeter, GramsPerSquareMeterTolerance), AreaDensityUnit.KilogramPerSquareMeter => (KilogramsPerSquareMeterInOneKilogramPerSquareMeter, KilogramsPerSquareMeterTolerance), AreaDensityUnit.MilligramPerSquareMeter => (MilligramsPerSquareMeterInOneKilogramPerSquareMeter, MilligramsPerSquareMeterTolerance), + AreaDensityUnit.PoundPerSquareFoot => (PoundPerSquareFootInOneKilogramPerSquareMeter, PoundPerSquareFootTolerance), + AreaDensityUnit.PoundPerThousandSquareFeet => (PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, PoundPerThousandSquareFeetTolerance), _ => throw new NotSupportedException() }; } @@ -66,6 +72,8 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase new object[] { AreaDensityUnit.GramPerSquareMeter }, new object[] { AreaDensityUnit.KilogramPerSquareMeter }, new object[] { AreaDensityUnit.MilligramPerSquareMeter }, + new object[] { AreaDensityUnit.PoundPerSquareFoot }, + new object[] { AreaDensityUnit.PoundPerThousandSquareFeet }, }; [Fact] @@ -140,6 +148,8 @@ public void KilogramPerSquareMeterToAreaDensityUnits() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.GramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.MilligramsPerSquareMeter, MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerSquareFoot, PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerThousandSquareFeet, PoundPerThousandSquareFeetTolerance); } [Fact] @@ -178,6 +188,8 @@ public void As() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.GramPerSquareMeter), GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.MilligramPerSquareMeter), MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerSquareFoot), PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerThousandSquareFeet), PoundPerThousandSquareFeetTolerance); } [Fact] @@ -248,6 +260,9 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() [InlineData("en-US", "4.2 gsm", AreaDensityUnit.GramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 kg/m²", AreaDensityUnit.KilogramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] + [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void Parse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { using var _ = new CultureScope(culture); @@ -261,6 +276,9 @@ public void Parse(string culture, string quantityString, AreaDensityUnit expecte [InlineData("en-US", "4.2 gsm", AreaDensityUnit.GramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 kg/m²", AreaDensityUnit.KilogramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] + [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void TryParse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { using var _ = new CultureScope(culture); @@ -274,6 +292,9 @@ public void TryParse(string culture, string quantityString, AreaDensityUnit expe [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { // Fallback culture "en-US" is always localized @@ -287,6 +308,9 @@ public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensi [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { // Currently, no abbreviations are localized for Icelandic, so it should fall back to "en-US" when parsing. @@ -300,6 +324,9 @@ public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { using var _ = new CultureScope(culture); @@ -312,6 +339,9 @@ public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, Ar [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { AreaDensityUnit parsedUnit = AreaDensity.ParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture)); @@ -323,6 +353,9 @@ public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensi [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { // Fallback culture "en-US" is always localized @@ -336,6 +369,9 @@ public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDe [InlineData("gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { // Currently, no abbreviations are localized for Icelandic, so it should fall back to "en-US" when parsing. @@ -349,6 +385,9 @@ public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(stri [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { using var _ = new CultureScope(culture); @@ -361,6 +400,9 @@ public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, [InlineData("en-US", "gsm", AreaDensityUnit.GramPerSquareMeter)] [InlineData("en-US", "kg/m²", AreaDensityUnit.KilogramPerSquareMeter)] [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] + [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { Assert.True(AreaDensity.TryParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture), out AreaDensityUnit parsedUnit)); @@ -371,6 +413,8 @@ public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDe [InlineData("en-US", AreaDensityUnit.GramPerSquareMeter, "g/m²")] [InlineData("en-US", AreaDensityUnit.KilogramPerSquareMeter, "kg/m²")] [InlineData("en-US", AreaDensityUnit.MilligramPerSquareMeter, "mg/m²")] + [InlineData("en-US", AreaDensityUnit.PoundPerSquareFoot, "lbs/ft²")] + [InlineData("en-US", AreaDensityUnit.PoundPerThousandSquareFeet, "lbs/MSF")] public void GetAbbreviationForCulture(string culture, AreaDensityUnit unit, string expectedAbbreviation) { var defaultAbbreviation = AreaDensity.GetAbbreviation(unit, CultureInfo.GetCultureInfo(culture)); @@ -458,6 +502,8 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, AreaDensity.FromGramsPerSquareMeter(kilogrampersquaremeter.GramsPerSquareMeter).KilogramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromMilligramsPerSquareMeter(kilogrampersquaremeter.MilligramsPerSquareMeter).KilogramsPerSquareMeter, MilligramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerSquareFoot(kilogrampersquaremeter.PoundPerSquareFoot).KilogramsPerSquareMeter, PoundPerSquareFootTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerThousandSquareFeet(kilogrampersquaremeter.PoundPerThousandSquareFeet).KilogramsPerSquareMeter, PoundPerThousandSquareFeetTolerance); } [Fact] @@ -617,6 +663,8 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 g/m²", new AreaDensity(1, AreaDensityUnit.GramPerSquareMeter).ToString()); Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString()); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString()); + Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString()); + Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString()); } [Fact] @@ -628,6 +676,8 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 g/m²", new AreaDensity(1, AreaDensityUnit.GramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString(swedishCulture)); + Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString(swedishCulture)); + Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString(swedishCulture)); } [Fact] diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 2b662909c4..7c75006534 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -121,6 +121,8 @@ public static IEnumerable> GetDefaultMappings() yield return new (AreaDensityUnit.GramPerSquareMeter, "GramPerSquareMeter", "GramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram)); yield return new (AreaDensityUnit.KilogramPerSquareMeter, "KilogramPerSquareMeter", "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)); yield return new (AreaDensityUnit.MilligramPerSquareMeter, "MilligramPerSquareMeter", "MilligramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Milligram)); + yield return new (AreaDensityUnit.PoundPerSquareFoot, "PoundPerSquareFoot", "PoundPerSquareFoot", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); + yield return new (AreaDensityUnit.PoundPerThousandSquareFeet, "PoundPerThousandSquareFeet", "PoundPerThousandSquareFeet", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); } } @@ -241,6 +243,16 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public double MilligramsPerSquareMeter => As(AreaDensityUnit.MilligramPerSquareMeter); + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + + /// + /// Gets a value of this quantity converted into + /// + public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + #endregion #region Static Methods @@ -254,6 +266,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: AreaDensityUnit -> BaseUnit unitConverter.SetConversionFunction(AreaDensityUnit.GramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); unitConverter.SetConversionFunction(AreaDensityUnit.MilligramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.KilogramPerSquareMeter)); // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity); @@ -261,6 +275,8 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> AreaDensityUnit unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.GramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.GramPerSquareMeter)); unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.MilligramPerSquareMeter, quantity => quantity.ToUnit(AreaDensityUnit.MilligramPerSquareMeter)); + unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot, quantity => quantity.ToUnit(AreaDensityUnit.PoundPerSquareFoot)); + unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet, quantity => quantity.ToUnit(AreaDensityUnit.PoundPerThousandSquareFeet)); } /// @@ -312,6 +328,22 @@ public static AreaDensity FromMilligramsPerSquareMeter(double value) return new AreaDensity(value, AreaDensityUnit.MilligramPerSquareMeter); } + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerSquareFoot(double value) + { + return new AreaDensity(value, AreaDensityUnit.PoundPerSquareFoot); + } + + /// + /// Creates a from . + /// + public static AreaDensity FromPoundPerThousandSquareFeet(double value) + { + return new AreaDensity(value, AreaDensityUnit.PoundPerThousandSquareFeet); + } + /// /// Dynamically convert from value and unit enum to . /// @@ -717,10 +749,14 @@ private bool TryToUnit(AreaDensityUnit unit, [NotNullWhen(true)] out AreaDensity // AreaDensityUnit -> BaseUnit (AreaDensityUnit.GramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000, AreaDensityUnit.KilogramPerSquareMeter), (AreaDensityUnit.MilligramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000000, AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824, AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824 / 1000, AreaDensityUnit.KilogramPerSquareMeter), // BaseUnit -> AreaDensityUnit (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.GramPerSquareMeter) => new AreaDensity(_value * 1000, AreaDensityUnit.GramPerSquareMeter), (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.MilligramPerSquareMeter) => new AreaDensity(_value * 1000000, AreaDensityUnit.MilligramPerSquareMeter), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot) => new AreaDensity(_value / 4.8824, AreaDensityUnit.PoundPerSquareFoot), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet) => new AreaDensity(_value / 4.8824 * 1000, AreaDensityUnit.PoundPerThousandSquareFeet), _ => null }; diff --git a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext index 6a33618aa9..f49fd52017 100644 --- a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext +++ b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext @@ -1,3 +1,5 @@ GramsPerSquareMeter=g/m²,gsm KilogramsPerSquareMeter=kg/m² MilligramsPerSquareMeter=mg/m² +PoundPerSquareFoot=lbs/ft²,lbs/SF +PoundPerThousandSquareFeet=lbs/MSF diff --git a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs index bacdc7e8f4..06c176003f 100644 --- a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -33,6 +33,8 @@ public enum AreaDensityUnit GramPerSquareMeter = 6, KilogramPerSquareMeter = 1, MilligramPerSquareMeter = 10, + PoundPerSquareFoot = 8, + PoundPerThousandSquareFeet = 3, } #pragma warning restore 1591 diff --git a/global.json b/global.json index b2ff2b6822..a11f48e193 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "9.0.0", - "allowPrerelease": true, - "rollForward": "latestMajor" + "version": "10.0.0", + "rollForward": "latestMajor", + "allowPrerelease": true } } \ No newline at end of file From 6cc4911c97a160f79b623debe2686b6b410d822a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 8 Dec 2025 12:14:47 +0100 Subject: [PATCH 2/4] Improved accuracy of conversion formula, reverted unwanted global.json changes --- Common/UnitDefinitions/AreaDensity.json | 8 ++++---- global.json | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index 6b523e238e..f8aac24b4b 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -64,8 +64,8 @@ "L": "Foot", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * 4.8824", - "FromBaseToUnitFunc": "{x} / 4.8824", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.092903", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903)", "Localization": [ { "Culture": "en-US", @@ -80,8 +80,8 @@ "L": "Foot", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * 4.8824 / 1000", - "FromBaseToUnitFunc": "{x} / 4.8824 * 1000", + "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.092903) / 1000", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903) * 1000", "Localization": [ { "Culture": "en-US", diff --git a/global.json b/global.json index a11f48e193..b2ff2b6822 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "10.0.0", - "rollForward": "latestMajor", - "allowPrerelease": true + "version": "9.0.0", + "allowPrerelease": true, + "rollForward": "latestMajor" } } \ No newline at end of file From d5d39897b64ff74670432e5aee77833e96af9d67 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 May 2026 08:25:26 +0200 Subject: [PATCH 3/4] Fixed code review issues --- Common/UnitDefinitions/AreaDensity.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index f8aac24b4b..a48c5cb9f3 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -59,13 +59,13 @@ }, { "SingularName": "PoundPerSquareFoot", - "PluralName": "PoundPerSquareFoot", + "PluralName": "PoundsPerSquareFoot", "BaseUnits": { "L": "Foot", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.092903", - "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903)", + "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.09290304)", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.09290304)", "Localization": [ { "Culture": "en-US", @@ -75,17 +75,17 @@ }, { "SingularName": "PoundPerThousandSquareFeet", - "PluralName": "PoundPerThousandSquareFeet", + "PluralName": "PoundsPerThousandSquareFeet", "BaseUnits": { "L": "Foot", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.092903) / 1000", - "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.092903) * 1000", + "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.09290304) / 1000", + "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.09290304) * 1000", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "lbs/MSF" ] + "Abbreviations": [ "lbs/1000ft²", "lbs/MSF" ] } ] } From 05fca627a280707a4ccf75c38a7d06b4854a6317 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 May 2026 08:38:35 +0200 Subject: [PATCH 4/4] Regenerated code and updated tests --- .../GeneratedCode/Quantities/AreaDensity.g.cs | 16 ++++---- .../NumberToAreaDensityExtensionsTest.g.cs | 8 ++-- .../NumberToAreaDensityExtensions.g.cs | 16 ++++---- .../NumberToAreaDensityExtensionsTest.g.cs | 8 ++-- .../NumberToAreaDensityExtensions.g.cs | 16 ++++---- UnitsNet.Tests/CustomCode/AreaDensityTests.cs | 4 +- .../TestsBase/AreaDensityTestsBase.g.cs | 40 ++++++++++++------- .../GeneratedCode/Quantities/AreaDensity.g.cs | 20 +++++----- .../Resources/AreaDensity.restext | 4 +- 9 files changed, 71 insertions(+), 61 deletions(-) diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index 4a57d1e4d9..d8e7ac925c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -96,12 +96,12 @@ public AreaDensity(double value, AreaDensityUnit unit) /// /// Gets a value of this quantity converted into /// - public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + public double PoundsPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + public double PoundsPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); #endregion @@ -125,12 +125,12 @@ public AreaDensity(double value, AreaDensityUnit unit) /// /// Creates a from . /// - public static AreaDensity FromPoundPerSquareFoot(double poundpersquarefoot) => new AreaDensity(poundpersquarefoot, AreaDensityUnit.PoundPerSquareFoot); + public static AreaDensity FromPoundsPerSquareFoot(double poundspersquarefoot) => new AreaDensity(poundspersquarefoot, AreaDensityUnit.PoundPerSquareFoot); /// /// Creates a from . /// - public static AreaDensity FromPoundPerThousandSquareFeet(double poundperthousandsquarefeet) => new AreaDensity(poundperthousandsquarefeet, AreaDensityUnit.PoundPerThousandSquareFeet); + public static AreaDensity FromPoundsPerThousandSquareFeet(double poundsperthousandsquarefeet) => new AreaDensity(poundsperthousandsquarefeet, AreaDensityUnit.PoundPerThousandSquareFeet); /// /// Dynamically convert from value and unit enum to . @@ -175,8 +175,8 @@ private double GetValueInBaseUnit() AreaDensityUnit.GramPerSquareMeter => _value / 1000, AreaDensityUnit.KilogramPerSquareMeter => _value, AreaDensityUnit.MilligramPerSquareMeter => _value / 1000000, - AreaDensityUnit.PoundPerSquareFoot => _value * 4.8824, - AreaDensityUnit.PoundPerThousandSquareFeet => _value * 4.8824 / 1000, + AreaDensityUnit.PoundPerSquareFoot => _value * (0.45359237 / 0.09290304), + AreaDensityUnit.PoundPerThousandSquareFeet => _value * (0.45359237 / 0.09290304) / 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to base units.") }; } @@ -193,8 +193,8 @@ private double GetValueAs(AreaDensityUnit unit) AreaDensityUnit.GramPerSquareMeter => baseUnitValue * 1000, AreaDensityUnit.KilogramPerSquareMeter => baseUnitValue, AreaDensityUnit.MilligramPerSquareMeter => baseUnitValue * 1000000, - AreaDensityUnit.PoundPerSquareFoot => baseUnitValue / 4.8824, - AreaDensityUnit.PoundPerThousandSquareFeet => baseUnitValue / 4.8824 * 1000, + AreaDensityUnit.PoundPerSquareFoot => baseUnitValue / (0.45359237 / 0.09290304), + AreaDensityUnit.PoundPerThousandSquareFeet => baseUnitValue / (0.45359237 / 0.09290304) * 1000, _ => throw new NotImplementedException($"Can't convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index 158f3dfb23..e93616d7b8 100644 --- a/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.CS14.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -37,12 +37,12 @@ public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter); [Fact] - public void NumberToPoundPerSquareFootTest() => - Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot); + public void NumberToPoundsPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundsPerSquareFoot(2), 2.PoundsPerSquareFoot); [Fact] - public void NumberToPoundPerThousandSquareFeetTest() => - Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet); + public void NumberToPoundsPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundsPerThousandSquareFeet(2), 2.PoundsPerThousandSquareFeet); } } diff --git a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 2f868788ef..1d53b14517 100644 --- a/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions.CS14/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -66,20 +66,20 @@ public AreaDensity MilligramsPerSquareMeter => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif - /// - public AreaDensity PoundPerSquareFoot + /// + public AreaDensity PoundsPerSquareFoot #if NET7_0_OR_GREATER - => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); + => AreaDensity.FromPoundsPerSquareFoot(double.CreateChecked(value)); #else - => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); + => AreaDensity.FromPoundsPerSquareFoot(value.ToDouble(null)); #endif - /// - public AreaDensity PoundPerThousandSquareFeet + /// + public AreaDensity PoundsPerThousandSquareFeet #if NET7_0_OR_GREATER - => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); + => AreaDensity.FromPoundsPerThousandSquareFeet(double.CreateChecked(value)); #else - => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); + => AreaDensity.FromPoundsPerThousandSquareFeet(value.ToDouble(null)); #endif } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index ef2c0860b9..331cf37fff 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -37,12 +37,12 @@ public void NumberToMilligramsPerSquareMeterTest() => Assert.Equal(AreaDensity.FromMilligramsPerSquareMeter(2), 2.MilligramsPerSquareMeter()); [Fact] - public void NumberToPoundPerSquareFootTest() => - Assert.Equal(AreaDensity.FromPoundPerSquareFoot(2), 2.PoundPerSquareFoot()); + public void NumberToPoundsPerSquareFootTest() => + Assert.Equal(AreaDensity.FromPoundsPerSquareFoot(2), 2.PoundsPerSquareFoot()); [Fact] - public void NumberToPoundPerThousandSquareFeetTest() => - Assert.Equal(AreaDensity.FromPoundPerThousandSquareFeet(2), 2.PoundPerThousandSquareFeet()); + public void NumberToPoundsPerThousandSquareFeetTest() => + Assert.Equal(AreaDensity.FromPoundsPerThousandSquareFeet(2), 2.PoundsPerThousandSquareFeet()); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 14051bd61b..a6ef399ee4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -65,26 +65,26 @@ public static AreaDensity MilligramsPerSquareMeter(this T value) => AreaDensity.FromMilligramsPerSquareMeter(value.ToDouble(null)); #endif - /// - public static AreaDensity PoundPerSquareFoot(this T value) + /// + public static AreaDensity PoundsPerSquareFoot(this T value) where T : notnull #if NET7_0_OR_GREATER , INumber - => AreaDensity.FromPoundPerSquareFoot(double.CreateChecked(value)); + => AreaDensity.FromPoundsPerSquareFoot(double.CreateChecked(value)); #else , IConvertible - => AreaDensity.FromPoundPerSquareFoot(value.ToDouble(null)); + => AreaDensity.FromPoundsPerSquareFoot(value.ToDouble(null)); #endif - /// - public static AreaDensity PoundPerThousandSquareFeet(this T value) + /// + public static AreaDensity PoundsPerThousandSquareFeet(this T value) where T : notnull #if NET7_0_OR_GREATER , INumber - => AreaDensity.FromPoundPerThousandSquareFeet(double.CreateChecked(value)); + => AreaDensity.FromPoundsPerThousandSquareFeet(double.CreateChecked(value)); #else , IConvertible - => AreaDensity.FromPoundPerThousandSquareFeet(value.ToDouble(null)); + => AreaDensity.FromPoundsPerThousandSquareFeet(value.ToDouble(null)); #endif } diff --git a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs index 964d45f0cb..ef084f8e9e 100644 --- a/UnitsNet.Tests/CustomCode/AreaDensityTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaDensityTests.cs @@ -34,9 +34,9 @@ public class AreaDensityTests : AreaDensityTestsBase protected override double MilligramsPerSquareMeterInOneKilogramPerSquareMeter => 1000000; - protected override double PoundPerSquareFootInOneKilogramPerSquareMeter => 1 / 4.8824; + protected override double PoundsPerSquareFootInOneKilogramPerSquareMeter => 1 / (0.45359237 / 0.09290304); - protected override double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter => 1000 / 4.8824; + protected override double PoundsPerThousandSquareFeetInOneKilogramPerSquareMeter => 1000 / (0.45359237 / 0.09290304); [Fact] public void AreaDensityTimesAreaEqualsMass() diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 2cfbdf08d1..aaae4f345e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -43,15 +43,15 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected abstract double GramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } protected abstract double MilligramsPerSquareMeterInOneKilogramPerSquareMeter { get; } - protected abstract double PoundPerSquareFootInOneKilogramPerSquareMeter { get; } - protected abstract double PoundPerThousandSquareFeetInOneKilogramPerSquareMeter { get; } + protected abstract double PoundsPerSquareFootInOneKilogramPerSquareMeter { get; } + protected abstract double PoundsPerThousandSquareFeetInOneKilogramPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global protected virtual double GramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } protected virtual double MilligramsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double PoundPerSquareFootTolerance { get { return 1e-5; } } - protected virtual double PoundPerThousandSquareFeetTolerance { get { return 1e-5; } } + protected virtual double PoundsPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundsPerThousandSquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaDensityUnit unit) @@ -61,8 +61,8 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase AreaDensityUnit.GramPerSquareMeter => (GramsPerSquareMeterInOneKilogramPerSquareMeter, GramsPerSquareMeterTolerance), AreaDensityUnit.KilogramPerSquareMeter => (KilogramsPerSquareMeterInOneKilogramPerSquareMeter, KilogramsPerSquareMeterTolerance), AreaDensityUnit.MilligramPerSquareMeter => (MilligramsPerSquareMeterInOneKilogramPerSquareMeter, MilligramsPerSquareMeterTolerance), - AreaDensityUnit.PoundPerSquareFoot => (PoundPerSquareFootInOneKilogramPerSquareMeter, PoundPerSquareFootTolerance), - AreaDensityUnit.PoundPerThousandSquareFeet => (PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, PoundPerThousandSquareFeetTolerance), + AreaDensityUnit.PoundPerSquareFoot => (PoundsPerSquareFootInOneKilogramPerSquareMeter, PoundsPerSquareFootTolerance), + AreaDensityUnit.PoundPerThousandSquareFeet => (PoundsPerThousandSquareFeetInOneKilogramPerSquareMeter, PoundsPerThousandSquareFeetTolerance), _ => throw new NotSupportedException() }; } @@ -148,8 +148,8 @@ public void KilogramPerSquareMeterToAreaDensityUnits() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.GramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.MilligramsPerSquareMeter, MilligramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerSquareFoot, PoundPerSquareFootTolerance); - AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundPerThousandSquareFeet, PoundPerThousandSquareFeetTolerance); + AssertEx.EqualTolerance(PoundsPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundsPerSquareFoot, PoundsPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundsPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.PoundsPerThousandSquareFeet, PoundsPerThousandSquareFeetTolerance); } [Fact] @@ -188,8 +188,8 @@ public void As() AssertEx.EqualTolerance(GramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.GramPerSquareMeter), GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(MilligramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.MilligramPerSquareMeter), MilligramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(PoundPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerSquareFoot), PoundPerSquareFootTolerance); - AssertEx.EqualTolerance(PoundPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerThousandSquareFeet), PoundPerThousandSquareFeetTolerance); + AssertEx.EqualTolerance(PoundsPerSquareFootInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerSquareFoot), PoundsPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundsPerThousandSquareFeetInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.PoundPerThousandSquareFeet), PoundsPerThousandSquareFeetTolerance); } [Fact] @@ -262,6 +262,7 @@ public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void Parse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { @@ -278,6 +279,7 @@ public void Parse(string culture, string quantityString, AreaDensityUnit expecte [InlineData("en-US", "4.2 mg/m²", AreaDensityUnit.MilligramPerSquareMeter, 4.2)] [InlineData("en-US", "4.2 lbs/ft²", AreaDensityUnit.PoundPerSquareFoot, 4.2)] [InlineData("en-US", "4.2 lbs/SF", AreaDensityUnit.PoundPerSquareFoot, 4.2)] + [InlineData("en-US", "4.2 lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] [InlineData("en-US", "4.2 lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet, 4.2)] public void TryParse(string culture, string quantityString, AreaDensityUnit expectedUnit, double expectedValue) { @@ -294,6 +296,7 @@ public void TryParse(string culture, string quantityString, AreaDensityUnit expe [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { @@ -310,6 +313,7 @@ public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensi [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { @@ -326,6 +330,7 @@ public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { @@ -341,6 +346,7 @@ public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, Ar [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { @@ -355,6 +361,7 @@ public void ParseUnit_WithCulture(string culture, string abbreviation, AreaDensi [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDensityUnit expectedUnit) { @@ -371,6 +378,7 @@ public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, AreaDe [InlineData("mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, AreaDensityUnit expectedUnit) { @@ -387,6 +395,7 @@ public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(stri [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { @@ -402,6 +411,7 @@ public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, [InlineData("en-US", "mg/m²", AreaDensityUnit.MilligramPerSquareMeter)] [InlineData("en-US", "lbs/ft²", AreaDensityUnit.PoundPerSquareFoot)] [InlineData("en-US", "lbs/SF", AreaDensityUnit.PoundPerSquareFoot)] + [InlineData("en-US", "lbs/1000ft²", AreaDensityUnit.PoundPerThousandSquareFeet)] [InlineData("en-US", "lbs/MSF", AreaDensityUnit.PoundPerThousandSquareFeet)] public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDensityUnit expectedUnit) { @@ -414,7 +424,7 @@ public void TryParseUnit_WithCulture(string culture, string abbreviation, AreaDe [InlineData("en-US", AreaDensityUnit.KilogramPerSquareMeter, "kg/m²")] [InlineData("en-US", AreaDensityUnit.MilligramPerSquareMeter, "mg/m²")] [InlineData("en-US", AreaDensityUnit.PoundPerSquareFoot, "lbs/ft²")] - [InlineData("en-US", AreaDensityUnit.PoundPerThousandSquareFeet, "lbs/MSF")] + [InlineData("en-US", AreaDensityUnit.PoundPerThousandSquareFeet, "lbs/1000ft²")] public void GetAbbreviationForCulture(string culture, AreaDensityUnit unit, string expectedAbbreviation) { var defaultAbbreviation = AreaDensity.GetAbbreviation(unit, CultureInfo.GetCultureInfo(culture)); @@ -502,8 +512,8 @@ public void ConversionRoundTrip() AssertEx.EqualTolerance(1, AreaDensity.FromGramsPerSquareMeter(kilogrampersquaremeter.GramsPerSquareMeter).KilogramsPerSquareMeter, GramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(1, AreaDensity.FromMilligramsPerSquareMeter(kilogrampersquaremeter.MilligramsPerSquareMeter).KilogramsPerSquareMeter, MilligramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerSquareFoot(kilogrampersquaremeter.PoundPerSquareFoot).KilogramsPerSquareMeter, PoundPerSquareFootTolerance); - AssertEx.EqualTolerance(1, AreaDensity.FromPoundPerThousandSquareFeet(kilogrampersquaremeter.PoundPerThousandSquareFeet).KilogramsPerSquareMeter, PoundPerThousandSquareFeetTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundsPerSquareFoot(kilogrampersquaremeter.PoundsPerSquareFoot).KilogramsPerSquareMeter, PoundsPerSquareFootTolerance); + AssertEx.EqualTolerance(1, AreaDensity.FromPoundsPerThousandSquareFeet(kilogrampersquaremeter.PoundsPerThousandSquareFeet).KilogramsPerSquareMeter, PoundsPerThousandSquareFeetTolerance); } [Fact] @@ -664,7 +674,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString()); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString()); Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString()); - Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString()); + Assert.Equal("1 lbs/1000ft²", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString()); } [Fact] @@ -677,7 +687,7 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 mg/m²", new AreaDensity(1, AreaDensityUnit.MilligramPerSquareMeter).ToString(swedishCulture)); Assert.Equal("1 lbs/ft²", new AreaDensity(1, AreaDensityUnit.PoundPerSquareFoot).ToString(swedishCulture)); - Assert.Equal("1 lbs/MSF", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString(swedishCulture)); + Assert.Equal("1 lbs/1000ft²", new AreaDensity(1, AreaDensityUnit.PoundPerThousandSquareFeet).ToString(swedishCulture)); } [Fact] diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 7c75006534..86f61faafd 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -121,8 +121,8 @@ public static IEnumerable> GetDefaultMappings() yield return new (AreaDensityUnit.GramPerSquareMeter, "GramPerSquareMeter", "GramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Gram)); yield return new (AreaDensityUnit.KilogramPerSquareMeter, "KilogramPerSquareMeter", "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)); yield return new (AreaDensityUnit.MilligramPerSquareMeter, "MilligramPerSquareMeter", "MilligramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Milligram)); - yield return new (AreaDensityUnit.PoundPerSquareFoot, "PoundPerSquareFoot", "PoundPerSquareFoot", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); - yield return new (AreaDensityUnit.PoundPerThousandSquareFeet, "PoundPerThousandSquareFeet", "PoundPerThousandSquareFeet", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); + yield return new (AreaDensityUnit.PoundPerSquareFoot, "PoundPerSquareFoot", "PoundsPerSquareFoot", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); + yield return new (AreaDensityUnit.PoundPerThousandSquareFeet, "PoundPerThousandSquareFeet", "PoundsPerThousandSquareFeet", new BaseUnits(length: LengthUnit.Foot, mass: MassUnit.Pound)); } } @@ -246,12 +246,12 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// Gets a value of this quantity converted into /// - public double PoundPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); + public double PoundsPerSquareFoot => As(AreaDensityUnit.PoundPerSquareFoot); /// /// Gets a value of this quantity converted into /// - public double PoundPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); + public double PoundsPerThousandSquareFeet => As(AreaDensityUnit.PoundPerThousandSquareFeet); #endregion @@ -331,7 +331,7 @@ public static AreaDensity FromMilligramsPerSquareMeter(double value) /// /// Creates a from . /// - public static AreaDensity FromPoundPerSquareFoot(double value) + public static AreaDensity FromPoundsPerSquareFoot(double value) { return new AreaDensity(value, AreaDensityUnit.PoundPerSquareFoot); } @@ -339,7 +339,7 @@ public static AreaDensity FromPoundPerSquareFoot(double value) /// /// Creates a from . /// - public static AreaDensity FromPoundPerThousandSquareFeet(double value) + public static AreaDensity FromPoundsPerThousandSquareFeet(double value) { return new AreaDensity(value, AreaDensityUnit.PoundPerThousandSquareFeet); } @@ -749,14 +749,14 @@ private bool TryToUnit(AreaDensityUnit unit, [NotNullWhen(true)] out AreaDensity // AreaDensityUnit -> BaseUnit (AreaDensityUnit.GramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000, AreaDensityUnit.KilogramPerSquareMeter), (AreaDensityUnit.MilligramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value / 1000000, AreaDensityUnit.KilogramPerSquareMeter), - (AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824, AreaDensityUnit.KilogramPerSquareMeter), - (AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * 4.8824 / 1000, AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerSquareFoot, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * (0.45359237 / 0.09290304), AreaDensityUnit.KilogramPerSquareMeter), + (AreaDensityUnit.PoundPerThousandSquareFeet, AreaDensityUnit.KilogramPerSquareMeter) => new AreaDensity(_value * (0.45359237 / 0.09290304) / 1000, AreaDensityUnit.KilogramPerSquareMeter), // BaseUnit -> AreaDensityUnit (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.GramPerSquareMeter) => new AreaDensity(_value * 1000, AreaDensityUnit.GramPerSquareMeter), (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.MilligramPerSquareMeter) => new AreaDensity(_value * 1000000, AreaDensityUnit.MilligramPerSquareMeter), - (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot) => new AreaDensity(_value / 4.8824, AreaDensityUnit.PoundPerSquareFoot), - (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet) => new AreaDensity(_value / 4.8824 * 1000, AreaDensityUnit.PoundPerThousandSquareFeet), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerSquareFoot) => new AreaDensity(_value / (0.45359237 / 0.09290304), AreaDensityUnit.PoundPerSquareFoot), + (AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.PoundPerThousandSquareFeet) => new AreaDensity(_value / (0.45359237 / 0.09290304) * 1000, AreaDensityUnit.PoundPerThousandSquareFeet), _ => null }; diff --git a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext index f49fd52017..b74e58280f 100644 --- a/UnitsNet/GeneratedCode/Resources/AreaDensity.restext +++ b/UnitsNet/GeneratedCode/Resources/AreaDensity.restext @@ -1,5 +1,5 @@ GramsPerSquareMeter=g/m²,gsm KilogramsPerSquareMeter=kg/m² MilligramsPerSquareMeter=mg/m² -PoundPerSquareFoot=lbs/ft²,lbs/SF -PoundPerThousandSquareFeet=lbs/MSF +PoundsPerSquareFoot=lbs/ft²,lbs/SF +PoundsPerThousandSquareFeet=lbs/1000ft²,lbs/MSF