Skip to content

Commit 799bfcc

Browse files
committed
Merge remote-tracking branch 'angularsen/master' into v4
2 parents b27ab41 + 29cbadf commit 799bfcc

17 files changed

+123
-13
lines changed

Common/UnitDefinitions/Force.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"PluralName": "Newtons",
6262
"FromUnitToBaseFunc": "x",
6363
"FromBaseToUnitFunc": "x",
64-
"Prefixes": [ "Deca", "Kilo", "Mega" ],
64+
"Prefixes": [ "Micro", "Milli", "Deca", "Kilo", "Mega" ],
6565
"Localization": [
6666
{
6767
"Culture": "en-US",
@@ -70,7 +70,7 @@
7070
{
7171
"Culture": "ru-RU",
7272
"Abbreviations": [ "Н" ],
73-
"AbbreviationsWithPrefixes": [ "даН", "кН" ]
73+
"AbbreviationsWithPrefixes": [ "мкН", "мН", "даН", "кН", "МН" ]
7474
}
7575
]
7676
},
@@ -121,6 +121,18 @@
121121
"Abbreviations": [ "фунт-сила" ]
122122
}
123123
]
124+
},
125+
{
126+
"SingularName": "OunceForce",
127+
"PluralName": "OunceForce",
128+
"FromUnitToBaseFunc": "x*2.780138509537812e-1",
129+
"FromBaseToUnitFunc": "x/2.780138509537812e-1",
130+
"Localization": [
131+
{
132+
"Culture": "en-US",
133+
"Abbreviations": [ "ozf" ]
134+
}
135+
]
124136
}
125137
]
126138
}

Common/UnitDefinitions/Pressure.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"PluralName": "Bars",
4848
"FromUnitToBaseFunc": "x*1e5",
4949
"FromBaseToUnitFunc": "x/1e5",
50-
"Prefixes": [ "Milli", "Centi", "Deci", "Kilo", "Mega" ],
50+
"Prefixes": [ "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ],
5151
"Localization": [
5252
{
5353
"Culture": "en-US",
@@ -304,6 +304,30 @@
304304
"Abbreviations": [ "inHg" ]
305305
}
306306
]
307+
},
308+
{
309+
"SingularName": "DynePerSquareCentimeter",
310+
"PluralName": "DynesPerSquareCentimeter",
311+
"FromUnitToBaseFunc": "x*1.0e-1",
312+
"FromBaseToUnitFunc": "x/1.0e-1",
313+
"Localization": [
314+
{
315+
"Culture": "en-US",
316+
"Abbreviations": [ "dyn/cm²" ]
317+
}
318+
]
319+
},
320+
{
321+
"SingularName": "PoundPerInchSecondSquared",
322+
"PluralName": "PoundsPerInchSecondSquared",
323+
"FromUnitToBaseFunc": "x*1.785796732283465e1",
324+
"FromBaseToUnitFunc": "x/1.785796732283465e1",
325+
"Localization": [
326+
{
327+
"Culture": "en-US",
328+
"Abbreviations": [ "lbm/(in·s²)", "lb/(in·s²)" ]
329+
}
330+
]
307331
}
308332
]
309333
}

Common/UnitDefinitions/Torque.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
{
4949
"Culture": "ru-RU",
5050
"Abbreviations": [ "Н·м" ],
51-
"AbbreviationsWithPrefixes": [ "кН·м" ]
51+
"AbbreviationsWithPrefixes": [ "кН·м", "МН·м" ]
5252
}
5353
]
5454
},

UnitsNet.Tests/CustomCode/ForceTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public class ForceTests : ForceTestsBase
4343

4444
protected override double TonnesForceInOneNewton => 1.019716212977928e-4;
4545

46+
protected override double MillinewtonsInOneNewton => 1.0e3;
47+
48+
protected override double MicronewtonsInOneNewton => 1.0e6;
49+
50+
protected override double OunceForceInOneNewton => 3.596943089595368;
51+
4652
[Fact]
4753
public void ForceDividedByAreaEqualsPressure()
4854
{

UnitsNet.Tests/CustomCode/PressureTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,16 @@ public class PressureTests : PressureTestsBase
9494

9595
protected override double MillibarsInOnePascal => 1e-2;
9696

97+
protected override double MicrobarsInOnePascal => 1.0e1;
98+
9799
protected override double MillimetersOfMercuryInOnePascal => 7.50061561302643e-3;
98100

99101
protected override double InchesOfMercuryInOnePascal => 2.95299830714159e-4;
100102

103+
protected override double DynesPerSquareCentimeterInOnePascal => 1.0e1;
104+
105+
protected override double PoundsPerInchSecondSquaredInOnePascal => 5.599741459495891e-2;
106+
101107
[Fact]
102108
public void AreaTimesPressureEqualsForce()
103109
{

UnitsNet.Tests/QuantityTests.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
2+
// https://github.com/angularsen/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
using UnitsNet.Units;
23+
using Xunit;
24+
25+
namespace UnitsNet.Tests
26+
{
27+
public partial class QuantityTests
28+
{
29+
[Fact]
30+
public void GetHashCodeForDifferentQuantitiesWithSameValuesAreNotEqual()
31+
{
32+
var length = new Length( 1.0, (LengthUnit)2 );
33+
var area = new Area( 1.0, (AreaUnit)2 );
34+
35+
Assert.NotEqual( length.GetHashCode(), area.GetHashCode() );
36+
}
37+
}
38+
}

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.WindowsRuntimeComponent.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public bool Equals(Information other, double tolerance, ComparisonType compariso
817817
/// <returns>A hash code for the current Information.</returns>
818818
public override int GetHashCode()
819819
{
820-
return new { Value, Unit }.GetHashCode();
820+
return new { QuantityType, Value, Unit }.GetHashCode();
821821
}
822822

823823
#endregion

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.WindowsRuntimeComponent.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ public bool Equals(Length other, double tolerance, ComparisonType comparisonType
757757
/// <returns>A hash code for the current Length.</returns>
758758
public override int GetHashCode()
759759
{
760-
return new { Value, Unit }.GetHashCode();
760+
return new { QuantityType, Value, Unit }.GetHashCode();
761761
}
762762

763763
#endregion

UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.WindowsRuntimeComponent.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public bool Equals(Level other, double tolerance, ComparisonType comparisonType)
457457
/// <returns>A hash code for the current Level.</returns>
458458
public override int GetHashCode()
459459
{
460-
return new { Value, Unit }.GetHashCode();
460+
return new { QuantityType, Value, Unit }.GetHashCode();
461461
}
462462

463463
#endregion

UnitsNet/GeneratedCode/Quantities/Information.NetFramework.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ public bool Equals(Information other, double tolerance, ComparisonType compariso
829829
/// <returns>A hash code for the current Information.</returns>
830830
public override int GetHashCode()
831831
{
832-
return new { Value, Unit }.GetHashCode();
832+
return new { QuantityType, Value, Unit }.GetHashCode();
833833
}
834834

835835
#endregion

UnitsNet/GeneratedCode/Quantities/Length.NetFramework.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public bool Equals(Length other, double tolerance, ComparisonType comparisonType
773773
/// <returns>A hash code for the current Length.</returns>
774774
public override int GetHashCode()
775775
{
776-
return new { Value, Unit }.GetHashCode();
776+
return new { QuantityType, Value, Unit }.GetHashCode();
777777
}
778778

779779
#endregion

UnitsNet/GeneratedCode/Quantities/Level.NetFramework.g.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public bool Equals(Level other, double tolerance, ComparisonType comparisonType)
501501
/// <returns>A hash code for the current Level.</returns>
502502
public override int GetHashCode()
503503
{
504-
return new { Value, Unit }.GetHashCode();
504+
return new { QuantityType, Value, Unit }.GetHashCode();
505505
}
506506

507507
#endregion

UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,14 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
339339
("en-US", typeof(ForceUnit), (int)ForceUnit.KiloPond, new string[]{"kp"}),
340340
("ru-RU", typeof(ForceUnit), (int)ForceUnit.KiloPond, new string[]{"кгс"}),
341341
("en-US", typeof(ForceUnit), (int)ForceUnit.Meganewton, new string[]{"MN"}),
342-
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Meganewton, new string[]{""}),
342+
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Meganewton, new string[]{"МН"}),
343+
("en-US", typeof(ForceUnit), (int)ForceUnit.Micronewton, new string[]{"µN"}),
344+
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Micronewton, new string[]{"мкН"}),
345+
("en-US", typeof(ForceUnit), (int)ForceUnit.Millinewton, new string[]{"mN"}),
346+
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Millinewton, new string[]{"мН"}),
343347
("en-US", typeof(ForceUnit), (int)ForceUnit.Newton, new string[]{"N"}),
344348
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Newton, new string[]{"Н"}),
349+
("en-US", typeof(ForceUnit), (int)ForceUnit.OunceForce, new string[]{"ozf"}),
345350
("en-US", typeof(ForceUnit), (int)ForceUnit.Poundal, new string[]{"pdl"}),
346351
("ru-RU", typeof(ForceUnit), (int)ForceUnit.Poundal, new string[]{"паундаль"}),
347352
("en-US", typeof(ForceUnit), (int)ForceUnit.PoundForce, new string[]{"lbf"}),
@@ -694,6 +699,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
694699
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Decapascal, new string[]{"даПа"}),
695700
("en-US", typeof(PressureUnit), (int)PressureUnit.Decibar, new string[]{"dbar"}),
696701
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Decibar, new string[]{"dбар"}),
702+
("en-US", typeof(PressureUnit), (int)PressureUnit.DynePerSquareCentimeter, new string[]{"dyn/cm²"}),
697703
("en-US", typeof(PressureUnit), (int)PressureUnit.FootOfHead, new string[]{"ft of head"}),
698704
("en-US", typeof(PressureUnit), (int)PressureUnit.Gigapascal, new string[]{"GPa"}),
699705
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Gigapascal, new string[]{"ГПа"}),
@@ -725,6 +731,8 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
725731
("en-US", typeof(PressureUnit), (int)PressureUnit.Megapascal, new string[]{"MPa"}),
726732
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Megapascal, new string[]{"МПа"}),
727733
("en-US", typeof(PressureUnit), (int)PressureUnit.MeterOfHead, new string[]{"m of head"}),
734+
("en-US", typeof(PressureUnit), (int)PressureUnit.Microbar, new string[]{"µbar"}),
735+
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Microbar, new string[]{"µбар"}),
728736
("en-US", typeof(PressureUnit), (int)PressureUnit.Micropascal, new string[]{"µPa"}),
729737
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Micropascal, new string[]{"мкПа"}),
730738
("en-US", typeof(PressureUnit), (int)PressureUnit.Millibar, new string[]{"mbar"}),
@@ -740,6 +748,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
740748
("ru-RU", typeof(PressureUnit), (int)PressureUnit.Pascal, new string[]{"Па"}),
741749
("en-US", typeof(PressureUnit), (int)PressureUnit.PoundForcePerSquareFoot, new string[]{"lb/ft²"}),
742750
("en-US", typeof(PressureUnit), (int)PressureUnit.PoundForcePerSquareInch, new string[]{"psi", "lb/in²"}),
751+
("en-US", typeof(PressureUnit), (int)PressureUnit.PoundPerInchSecondSquared, new string[]{"lbm/(in·s²)", "lb/(in·s²)"}),
743752
("en-US", typeof(PressureUnit), (int)PressureUnit.TechnicalAtmosphere, new string[]{"at"}),
744753
("ru-RU", typeof(PressureUnit), (int)PressureUnit.TechnicalAtmosphere, new string[]{"ат"}),
745754
("en-US", typeof(PressureUnit), (int)PressureUnit.TonneForcePerSquareCentimeter, new string[]{"tf/cm²"}),
@@ -914,7 +923,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin
914923
("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilopoundForceInch, new string[]{"kipf·in"}),
915924
("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonCentimeter, new string[]{"MN·cm"}),
916925
("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMeter, new string[]{"MN·m"}),
917-
("ru-RU", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMeter, new string[]{""}),
926+
("ru-RU", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMeter, new string[]{"МН·м"}),
918927
("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMillimeter, new string[]{"MN·mm"}),
919928
("en-US", typeof(TorqueUnit), (int)TorqueUnit.MegapoundForceFoot, new string[]{"Mlbf·ft"}),
920929
("en-US", typeof(TorqueUnit), (int)TorqueUnit.MegapoundForceInch, new string[]{"Mlbf·in"}),

UnitsNet/GeneratedCode/Units/ForceUnit.g.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public enum ForceUnit
5050
Kilonewton,
5151
KiloPond,
5252
Meganewton,
53+
Micronewton,
54+
Millinewton,
5355
Newton,
56+
OunceForce,
5457
Poundal,
5558
PoundForce,
5659
TonneForce,

UnitsNet/GeneratedCode/Units/PressureUnit.g.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public enum PressureUnit
4949
Centibar,
5050
Decapascal,
5151
Decibar,
52+
DynePerSquareCentimeter,
5253
FootOfHead,
5354
Gigapascal,
5455
Hectopascal,
@@ -67,6 +68,7 @@ public enum PressureUnit
6768
MeganewtonPerSquareMeter,
6869
Megapascal,
6970
MeterOfHead,
71+
Microbar,
7072
Micropascal,
7173
Millibar,
7274
MillimeterOfMercury,
@@ -76,6 +78,7 @@ public enum PressureUnit
7678
Pascal,
7779
PoundForcePerSquareFoot,
7880
PoundForcePerSquareInch,
81+
PoundPerInchSecondSquared,
7982
TechnicalAtmosphere,
8083
TonneForcePerSquareCentimeter,
8184
TonneForcePerSquareMeter,

UnitsNet/Scripts/GenerateUnits.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ function Add-PrefixUnits {
129129

130130
foreach ($unit in $quantity.Units)
131131
{
132+
foreach ($localization in $unit.Localization){
133+
if($localization.AbbreviationsWithPrefixes.Count -gt 0){
134+
if($unit.Prefixes.Count -ne $localization.AbbreviationsWithPrefixes.Count){
135+
Write-Error "The prefix count ($($unit.Prefixes.Count)) does not match the abbreviations with prefixes count ($($localization.AbbreviationsWithPrefixes.Count)) for $($quantity.Name).$($unit.SingularName)" -ErrorAction Stop
136+
}
137+
}
138+
}
139+
132140
$prefixIndex = 0
133141
foreach ($prefix in $unit.Prefixes)
134142
{
@@ -175,6 +183,7 @@ function Add-PrefixUnits {
175183
PluralName=$prefix + $(ToCamelCase $unit.PluralName)
176184
FromUnitToBaseFunc="("+$unit.FromUnitToBaseFunc+") * $prefixFactor"
177185
FromBaseToUnitFunc="("+$unit.FromBaseToUnitFunc+") / $prefixFactor"
186+
178187
Localization=$unit.Localization | % {
179188
$abbrev = $prefixAbbreviation + $_.Abbreviations[0]
180189
if ($_.AbbreviationsWithPrefixes) {

UnitsNet/Scripts/Include-GenerateQuantitySourceCodeNetFramework.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ $accessModifier = if ($wrc) { "internal" } else { "public" } @"
899899
/// <returns>A hash code for the current $quantityName.</returns>
900900
public override int GetHashCode()
901901
{
902-
return new { Value, Unit }.GetHashCode();
902+
return new { QuantityType, Value, Unit }.GetHashCode();
903903
}
904904
905905
#endregion

0 commit comments

Comments
 (0)