Skip to content

Commit f752d12

Browse files
committed
Rename Fraction units to Decimal
1 parent 6787eab commit f752d12

File tree

22 files changed

+446
-278
lines changed

22 files changed

+446
-278
lines changed

CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public static class NumberTo{_quantityName}Extensions
5252
return Writer.ToString();
5353
}
5454

55-
private string GetObsoleteAttributeOrNull(string obsoleteText) =>
55+
private static string? GetObsoleteAttributeOrNull(string obsoleteText) =>
5656
string.IsNullOrWhiteSpace(obsoleteText) ?
5757
null :
58-
$"[System.Obsolete({obsoleteText})]";
58+
$"[System.Obsolete(\"{obsoleteText}\")]";
5959
}
6060
}

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,6 @@ ulong IConvertible.ToUInt64(IFormatProvider provider)
11571157
/// </summary>
11581158
private static string GetObsoleteAttributeOrNull(string obsoleteText) => string.IsNullOrWhiteSpace(obsoleteText)
11591159
? null
1160-
: $"[System.Obsolete({obsoleteText})]";
1160+
: $"[System.Obsolete(\"{obsoleteText}\")]";
11611161
}
11621162
}

CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,17 +734,17 @@ public string ToString([CanBeNull] string cultureName, [NotNull] string format,
734734
}
735735

736736
/// <inheritdoc cref="GetObsoleteAttributeOrNull(string)"/>
737-
internal static string GetObsoleteAttributeOrNull(Quantity quantity) => GetObsoleteAttributeOrNull(quantity.ObsoleteText);
737+
internal static string? GetObsoleteAttributeOrNull(Quantity quantity) => GetObsoleteAttributeOrNull(quantity.ObsoleteText);
738738

739739
/// <inheritdoc cref="GetObsoleteAttributeOrNull(string)"/>
740-
internal static string GetObsoleteAttributeOrNull(Unit unit) => GetObsoleteAttributeOrNull(unit.ObsoleteText);
740+
internal static string? GetObsoleteAttributeOrNull(Unit unit) => GetObsoleteAttributeOrNull(unit.ObsoleteText);
741741

742742
/// <summary>
743743
/// Returns the Obsolete attribute if ObsoleteText has been defined on the JSON input - otherwise returns empty string
744744
/// It is up to the consumer to wrap any padding/new lines in order to keep to correct indentation formats
745745
/// </summary>
746-
private static string GetObsoleteAttributeOrNull(string obsoleteText) => string.IsNullOrWhiteSpace(obsoleteText)
746+
private static string? GetObsoleteAttributeOrNull(string obsoleteText) => string.IsNullOrWhiteSpace(obsoleteText)
747747
? null
748-
: $"[System.Obsolete({obsoleteText})]";
748+
: $"[System.Obsolete(\"{obsoleteText}\")]";
749749
}
750750
}

Common/UnitDefinitions/Ratio.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
{
22
"Name": "Ratio",
3-
"BaseUnit": "DecimalFraction",
3+
"BaseUnit": "Decimal",
44
"XmlDoc": "In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as \"a to b\" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).",
55
"Units": [
66
{
7+
"SingularName": "Decimal",
8+
"PluralName": "Decimal",
9+
"FromUnitToBaseFunc": "x",
10+
"FromBaseToUnitFunc": "x",
11+
"Localization": [
12+
{
13+
"Culture": "en-US",
14+
"Abbreviations": [ "" ]
15+
}
16+
]
17+
},
18+
{
19+
"ObsoleteText": "Use Decimal instead. This unit will be removed.",
720
"SingularName": "DecimalFraction",
821
"PluralName": "DecimalFractions",
922
"FromUnitToBaseFunc": "x",

Common/UnitDefinitions/RatioChangeRate.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"Name": "RatioChangeRate",
3-
"BaseUnit": "DecimalFractionPerSecond",
3+
"BaseUnit": "DecimalPerSecond",
44
"XmlDoc": "The change in ratio per unit of time.",
55
"Units": [
6+
{
7+
"SingularName": "DecimalPerSecond",
8+
"PluralName": "DecimalPerSecond",
9+
"FromUnitToBaseFunc": "x",
10+
"FromBaseToUnitFunc": "x",
11+
"Localization": [
12+
{
13+
"Culture": "en-US",
14+
"Abbreviations": [ "/s" ]
15+
}
16+
]
17+
},
618
{
719
"SingularName": "PercentPerSecond",
820
"PluralName": "PercentsPerSecond",
@@ -16,6 +28,7 @@
1628
]
1729
},
1830
{
31+
"ObsoleteText": "Use DecimalPerSecond instead. This unit will be removed.",
1932
"SingularName": "DecimalFractionPerSecond",
2033
"PluralName": "DecimalFractionsPerSecond",
2134
"FromUnitToBaseFunc": "x",

UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioChangeRateExtensionsTest.g.cs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioExtensionsTest.g.cs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)