Skip to content

Commit 8f7dec5

Browse files
committed
Change name of UnitClass to QuantityType, make UnitClass obsolete
To follow new naming conventions #260
1 parent 3b45b96 commit 8f7dec5

File tree

4 files changed

+118
-10
lines changed

4 files changed

+118
-10
lines changed
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by \generate-code.bat.
4+
//
5+
// Changes to this file will be lost when the code is regenerated.
6+
// The build server regenerates the code before each build and a pre-build
7+
// step will regenerate the code on each local build.
8+
//
9+
// See https://github.com/anjdreas/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
10+
//
11+
// Add CustomCode\UnitClasses\MyUnit.extra.cs files to add code to generated unit classes.
12+
// Add Extensions\MyUnitExtensions.cs to decorate unit classes with new behavior.
13+
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or unit classes.
14+
//
15+
// </auto-generated>
16+
//------------------------------------------------------------------------------
17+
18+
// Copyright (c) 2007 Andreas Gullberg Larsen ([email protected]).
19+
// https://github.com/anjdreas/UnitsNet
20+
//
21+
// Permission is hereby granted, free of charge, to any person obtaining a copy
22+
// of this software and associated documentation files (the "Software"), to deal
23+
// in the Software without restriction, including without limitation the rights
24+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25+
// copies of the Software, and to permit persons to whom the Software is
26+
// furnished to do so, subject to the following conditions:
27+
//
28+
// The above copyright notice and this permission notice shall be included in
29+
// all copies or substantial portions of the Software.
30+
//
31+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37+
// THE SOFTWARE.
38+
39+
// ReSharper disable once CheckNamespace
40+
41+
namespace UnitsNet
42+
{
43+
/// <summary>
44+
/// Lists all generated quantities with the same name as the quantity struct type,
45+
/// such as Length, Mass, Force etc.
46+
/// This is useful for populating options in the UI, such as creating a generic conversion
47+
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
48+
/// </summary>
49+
public enum QuantityType
50+
{
51+
Undefined = 0,
52+
Acceleration,
53+
AmplitudeRatio,
54+
Angle,
55+
ApparentPower,
56+
Area,
57+
AreaMomentOfInertia,
58+
BrakeSpecificFuelConsumption,
59+
Density,
60+
Duration,
61+
DynamicViscosity,
62+
ElectricAdmittance,
63+
ElectricCurrent,
64+
ElectricPotential,
65+
ElectricPotentialAc,
66+
ElectricPotentialDc,
67+
ElectricResistance,
68+
Energy,
69+
Flow,
70+
Force,
71+
ForceChangeRate,
72+
ForcePerLength,
73+
Frequency,
74+
Information,
75+
KinematicViscosity,
76+
Length,
77+
Level,
78+
Mass,
79+
MassFlow,
80+
MassMomentOfInertia,
81+
Molarity,
82+
Power,
83+
PowerRatio,
84+
Pressure,
85+
PressureChangeRate,
86+
Ratio,
87+
ReactivePower,
88+
RotationalAcceleration,
89+
RotationalSpeed,
90+
SpecificEnergy,
91+
SpecificWeight,
92+
Speed,
93+
Temperature,
94+
TemperatureChangeRate,
95+
TemperatureDelta,
96+
ThermalResistance,
97+
Torque,
98+
VitaminA,
99+
Volume,
100+
}
101+
}

UnitsNet/GeneratedCode/UnitClass.g.cs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
namespace UnitsNet
4242
{
43+
[System.Obsolete("Use QuantityType instead. This type was renamed and will be removed in the future.")]
4344
public enum UnitClass
4445
{
4546
Undefined = 0,

UnitsNet/Scripts/GenerateUnits.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ function GenerateUnitSystemDefault($unitClasses, $outDir)
7272
Write-Host "(OK) "
7373
}
7474

75-
function GenerateUnitClassEnum($unitClasses, $outDir)
75+
function GenerateQuantityType($unitClasses, $outDir)
7676
{
77-
Write-Host -NoNewline "UnitClass.g.cs: "
78-
$outFileName = "$outDir/UnitClass.g.cs"
77+
Write-Host -NoNewline "QuantityType.g.cs: "
78+
$outFileName = "$outDir/QuantityType.g.cs"
7979

80-
GenerateUnitClassEnumSourceCode $unitClasses | Out-File -Encoding "UTF8" -Force $outFileName | Out-Null
80+
GenerateQuantityTypeSourceCode $unitClasses | Out-File -Encoding "UTF8" -Force $outFileName | Out-Null
8181
if (!$?) {
8282
Write-Host "(error) "
8383
exit 1
@@ -253,7 +253,7 @@ function Add-InheritedUnits($unitClass, $unitClasses) {
253253
. "$PSScriptRoot/Include-GenerateLogarithmicCode.ps1"
254254
. "$PSScriptRoot/Include-GenerateNumberExtensionsSourceCode.ps1"
255255
. "$PSScriptRoot/Include-GenerateUnitSystemDefaultSourceCode.ps1"
256-
. "$PSScriptRoot/Include-GenerateUnitClassEnumSourceCode.ps1"
256+
. "$PSScriptRoot/Include-GenerateQuantityTypeSourceCode.ps1"
257257
. "$PSScriptRoot/Include-GenerateUnitClassSourceCode.ps1"
258258
. "$PSScriptRoot/Include-GenerateUnitEnumSourceCode.ps1"
259259
. "$PSScriptRoot/Include-GenerateUnitTestBaseClassSourceCode.ps1"
@@ -294,7 +294,7 @@ foreach ($unitClass in $unitClasses) {
294294

295295
Write-Host ""
296296
GenerateUnitSystemDefault $unitClasses $unitSystemDir
297-
GenerateUnitClassEnum $unitClasses $unitSystemDir
297+
GenerateQuantityType $unitClasses $unitSystemDir
298298

299299
$unitCount = ($unitClasses | %{$_.Units.Count} | Measure -Sum).Sum
300300

UnitsNet/Scripts/Include-GenerateUnitClassEnumSourceCode.ps1 renamed to UnitsNet/Scripts/Include-GenerateQuantityTypeSourceCode.ps1

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function GenerateUnitClassEnumSourceCode($unitClasses)
1+
function GenerateQuantityTypeSourceCode($quantityNames)
22
{
33
@"
44
//------------------------------------------------------------------------------
@@ -43,12 +43,18 @@ function GenerateUnitClassEnumSourceCode($unitClasses)
4343
4444
namespace UnitsNet
4545
{
46-
public enum UnitClass
46+
/// <summary>
47+
/// Lists all generated quantities with the same name as the quantity struct type,
48+
/// such as Length, Mass, Force etc.
49+
/// This is useful for populating options in the UI, such as creating a generic conversion
50+
/// tool with inputValue, quantityName, fromUnit and toUnit selectors.
51+
/// </summary>
52+
public enum QuantityType
4753
{
4854
Undefined = 0,
49-
"@; foreach ($unitClass in $unitClasses) {
55+
"@; foreach ($quantityName in $quantityNames) {
5056
@"
51-
$($unitClass.Name),
57+
$($quantityName.Name),
5258
"@; }@"
5359
}
5460
}

0 commit comments

Comments
 (0)