Skip to content

Commit 28f0989

Browse files
tmilnthorpangularsen
authored andcommitted
Fix for explicit AbbreviationsWithPrefixes not lining up with the pre… (#542)
* Fix for explicit AbbreviationsWithPrefixes not lining up with the prefixes. * Abort build when AbbreviationsWithPrefixes mismatches prefixes count. Will remove incorrect json after testing failure on AppVeyor. * Build fails properly. Putting missing abbreviation back. * Fix for count output
1 parent 157b288 commit 28f0989

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

Common/UnitDefinitions/Force.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
{
7171
"Culture": "ru-RU",
7272
"Abbreviations": [ "Н" ],
73-
"AbbreviationsWithPrefixes": [ "даН", "кН" ]
73+
"AbbreviationsWithPrefixes": [ "мкН", "мН", "даН", "кН", "МН" ]
7474
}
7575
]
7676
},

Common/UnitDefinitions/Torque.json

+1-1
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/GeneratedCode/UnitSystem.Default.g.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
15261526
new[]
15271527
{
15281528
new AbbreviationsForCulture("en-US", "daN"),
1529-
new AbbreviationsForCulture("ru-RU", ""),
1529+
new AbbreviationsForCulture("ru-RU", "даН"),
15301530
}),
15311531
new CulturesForEnumValue((int) ForceUnit.Dyn,
15321532
new[]
@@ -1544,7 +1544,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
15441544
new[]
15451545
{
15461546
new AbbreviationsForCulture("en-US", "kN"),
1547-
new AbbreviationsForCulture("ru-RU", ""),
1547+
new AbbreviationsForCulture("ru-RU", "кН"),
15481548
}),
15491549
new CulturesForEnumValue((int) ForceUnit.KiloPond,
15501550
new[]
@@ -1556,19 +1556,19 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
15561556
new[]
15571557
{
15581558
new AbbreviationsForCulture("en-US", "MN"),
1559-
new AbbreviationsForCulture("ru-RU", ""),
1559+
new AbbreviationsForCulture("ru-RU", "МН"),
15601560
}),
15611561
new CulturesForEnumValue((int) ForceUnit.Micronewton,
15621562
new[]
15631563
{
15641564
new AbbreviationsForCulture("en-US", "µN"),
1565-
new AbbreviationsForCulture("ru-RU", "даН"),
1565+
new AbbreviationsForCulture("ru-RU", "мкН"),
15661566
}),
15671567
new CulturesForEnumValue((int) ForceUnit.Millinewton,
15681568
new[]
15691569
{
15701570
new AbbreviationsForCulture("en-US", "mN"),
1571-
new AbbreviationsForCulture("ru-RU", "кН"),
1571+
new AbbreviationsForCulture("ru-RU", "мН"),
15721572
}),
15731573
new CulturesForEnumValue((int) ForceUnit.Newton,
15741574
new[]
@@ -4318,7 +4318,7 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
43184318
new[]
43194319
{
43204320
new AbbreviationsForCulture("en-US", "MN·m"),
4321-
new AbbreviationsForCulture("ru-RU", ""),
4321+
new AbbreviationsForCulture("ru-RU", "МН·м"),
43224322
}),
43234323
new CulturesForEnumValue((int) TorqueUnit.MeganewtonMillimeter,
43244324
new[]

UnitsNet/Scripts/GenerateUnits.ps1

+9
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ function Add-PrefixUnits {
169169

170170
foreach ($unit in $quantity.Units)
171171
{
172+
foreach ($localization in $unit.Localization){
173+
if($localization.AbbreviationsWithPrefixes.Count -gt 0){
174+
if($unit.Prefixes.Count -ne $localization.AbbreviationsWithPrefixes.Count){
175+
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
176+
}
177+
}
178+
}
179+
172180
$prefixIndex = 0
173181
foreach ($prefix in $unit.Prefixes)
174182
{
@@ -215,6 +223,7 @@ function Add-PrefixUnits {
215223
PluralName=$prefix + $(ToCamelCase $unit.PluralName)
216224
FromUnitToBaseFunc="("+$unit.FromUnitToBaseFunc+") * $prefixFactor"
217225
FromBaseToUnitFunc="("+$unit.FromBaseToUnitFunc+") / $prefixFactor"
226+
218227
Localization=$unit.Localization | % {
219228
$abbrev = $prefixAbbreviation + $_.Abbreviations[0]
220229
if ($_.AbbreviationsWithPrefixes) {

0 commit comments

Comments
 (0)