Skip to content

Commit 355f82f

Browse files
authored
Merge pull request #529 from tmilnthorp/CodeCleanup
Cleaning up some unused code and adding ValueTuple support to make un…
2 parents 4f50c03 + 49026b2 commit 355f82f

8 files changed

+1002
-1124
lines changed

UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@
210210
<PackageReference Include="JetBrains.Annotations">
211211
<Version>11.1.0</Version>
212212
</PackageReference>
213+
<PackageReference Include="System.ValueTuple">
214+
<Version>4.5.0</Version>
215+
</PackageReference>
213216
</ItemGroup>
214217
<ItemGroup />
215218
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">

UnitsNet/CustomCode/UnitAbbreviationsCache.cs

+2-2
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

+993-997
Large diffs are not rendered by default.

UnitsNet/I18n/AbbreviationsForCulture.cs

-39
This file was deleted.

UnitsNet/I18n/CulturesForEnumValue.cs

-39
This file was deleted.

UnitsNet/I18n/UnitLocalization.cs

-40
This file was deleted.

UnitsNet/Scripts/Include-GenerateUnitSystemDefaultSourceCode.ps1

+3-7
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

+1
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)