Skip to content

Commit a3d0435

Browse files
committed
Cleaning up some unused code and adding ValueTuple support to make unit abbreviations a bit clearer
1 parent 876f31f commit a3d0435

7 files changed

+999
-1124
lines changed

UnitsNet/CustomCode/UnitAbbreviationsCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ private void LoadGeneratedAbbreviations()
6565
{
6666
foreach(var localization in GeneratedLocalizations)
6767
{
68-
var culture = new CultureInfo(localization.Item1);
69-
MapUnitToAbbreviation(localization.Item2, localization.Item3, culture, localization.Item4);
68+
var culture = new CultureInfo(localization.CultureName);
69+
MapUnitToAbbreviation(localization.UnitType, localization.UnitValue, culture, localization.UnitAbbreviations);
7070
}
7171
}
7272

UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs

Lines changed: 993 additions & 997 deletions
Large diffs are not rendered by default.

UnitsNet/I18n/AbbreviationsForCulture.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

UnitsNet/I18n/CulturesForEnumValue.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

UnitsNet/I18n/UnitLocalization.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

UnitsNet/Scripts/Include-GenerateUnitSystemDefaultSourceCode.ps1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
// THE SOFTWARE.
4040
4141
using System;
42-
using System.Globalization;
43-
using System.Collections.Generic;
44-
using System.Collections.ObjectModel;
45-
using UnitsNet.I18n;
4642
using UnitsNet.Units;
4743
4844
// ReSharper disable RedundantCommaInArrayInitializer
@@ -52,8 +48,8 @@ namespace UnitsNet
5248
{
5349
public partial class UnitAbbreviationsCache
5450
{
55-
private static readonly Tuple<string, Type, int, string[]>[] GeneratedLocalizations
56-
= new Tuple<string, Type, int, string[]>[]
51+
private static readonly (string CultureName, Type UnitType, int UnitValue, string[] UnitAbbreviations)[] GeneratedLocalizations
52+
= new []
5753
{
5854
"@;
5955
foreach ($quantity in $quantities)
@@ -70,7 +66,7 @@ namespace UnitsNet
7066
$cultureName = $localization.Culture;
7167
$abbreviationParams = $localization.Abbreviations -join '", "'
7268
@"
73-
Tuple.Create(`"$cultureName`", typeof($unitEnumName), (int)$unitEnumName.$enumValue, new string[]{`"$abbreviationParams`"}),
69+
(`"$cultureName`", typeof($unitEnumName), (int)$unitEnumName.$enumValue, new string[]{`"$abbreviationParams`"}),
7470
"@;
7571
}
7672
}

UnitsNet/UnitsNet.Common.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<!-- NuGet references that work for both signed and unsigned -->
2929
<ItemGroup>
3030
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" PrivateAssets="All" />
31+
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
3132
</ItemGroup>
3233

3334
<!-- Exclude obj folder from default inclusion pattern -->

0 commit comments

Comments
 (0)