Skip to content

Commit c174503

Browse files
committed
UnitSystem/MapUnitToAbbreviation: Append abbreviations to any existing
So GetDefaultAbbreviation() is not affected if an abbreviation is already defined.
1 parent dd9412c commit c174503

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

UnitsNet/CustomCode/UnitSystem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ public void MapUnitToAbbreviation(Type unitType, int unitValue, [NotNull] params
184184
existingAbbreviations = unitValueToAbbrev[unitValue] = new List<string>();
185185
}
186186

187-
// Update any existing abbreviations so that the latest abbreviations
188-
// take precedence in GetDefaultAbbreviation().
189-
unitValueToAbbrev[unitValue] = abbreviations.Concat(existingAbbreviations).Distinct().ToList();
187+
// Append new abbreviations to any existing abbreviations so that we don't
188+
// change the result of GetDefaultAbbreviation() if already defined.
189+
unitValueToAbbrev[unitValue] = existingAbbreviations.Concat(abbreviations).Distinct().ToList();
190190
foreach (string abbreviation in abbreviations)
191191
{
192192
Dictionary<string, int> abbrevToUnitValue;

0 commit comments

Comments
 (0)