Skip to content

Commit 7ed243d

Browse files
authored
Whitespace consistency to match library arithmetic / generated prefixes (#1044)
1 parent 4d6083d commit 7ed243d

File tree

293 files changed

+6292
-6292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+6292
-6292
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ For a fairly complete summary of the unit definition JSON schema, see [Meter of
2727
### Conversion functions
2828
Converting from unit A to B is achieved by first converting from unit A to the base unit, then from the base unit to unit B. To achieve this, each unit defines two conversion functions.
2929

30-
* Prefer multiplication for `FromUnitToBaseFunc` (`{x}*2.54e-2` for `Inch` to `Meter`)
31-
* Prefer division for `FromBaseToUnitFunc` (`{x}/2.54e-2` for `Meter` to `Inch`)
30+
* Prefer multiplication for `FromUnitToBaseFunc` (`{x} * 2.54e-2` for `Inch` to `Meter`)
31+
* Prefer division for `FromBaseToUnitFunc` (`{x} / 2.54e-2` for `Meter` to `Inch`)
3232
* Prefer scientific notation `1e3` and `1e-5` instead of `1000` and `0.00001`
33-
* Prefer a constant if the conversion factor is finite (`{x}*2.54e-2` for `Inch`)
34-
* Prefer a calculation if the conversion factor is infinite (`({x}/72.27)*2.54e-2` for `PrinterPoint`)
33+
* Prefer a constant if the conversion factor is finite (`{x} * 2.54e-2` for `Inch`)
34+
* Prefer a calculation if the conversion factor is infinite (`({x} / 72.27)*2.54e-2` for `PrinterPoint`)
3535

3636
### Units
3737
Generally we try to name the units as what is the most widely used.

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,16 @@ private void GenerateLogarithmicArithmeticOperators()
711711
public static {_quantity.Name} operator +({_quantity.Name} left, {_quantity.Name} right)
712712
{{
713713
// Logarithmic addition
714-
// Formula: {x}*log10(10^(x/{x}) + 10^(y/{x}))
715-
return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit);
714+
// Formula: {x} * log10(10^(x/{x}) + 10^(y/{x}))
715+
return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit);
716716
}}
717717
718718
/// <summary>Get <see cref=""{_quantity.Name}""/> from logarithmic subtraction of two <see cref=""{_quantity.Name}""/>.</summary>
719719
public static {_quantity.Name} operator -({_quantity.Name} left, {_quantity.Name} right)
720720
{{
721721
// Logarithmic subtraction
722-
// Formula: {x}*log10(10^(x/{x}) - 10^(y/{x}))
723-
return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit);
722+
// Formula: {x} * log10(10^(x/{x}) - 10^(y/{x}))
723+
return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit);
724724
}}
725725
726726
/// <summary>Get <see cref=""{_quantity.Name}""/> from logarithmic multiplication of value and <see cref=""{_quantity.Name}""/>.</summary>

Common/UnitDefinitions/Acceleration.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"L": "Inch",
3636
"T": "Second"
3737
},
38-
"FromUnitToBaseFunc": "{x}*0.0254",
39-
"FromBaseToUnitFunc": "{x}/0.0254",
38+
"FromUnitToBaseFunc": "{x} * 0.0254",
39+
"FromBaseToUnitFunc": "{x} / 0.0254",
4040
"Localization": [
4141
{
4242
"Culture": "en-US",
@@ -55,8 +55,8 @@
5555
"L": "Foot",
5656
"T": "Second"
5757
},
58-
"FromUnitToBaseFunc": "{x}*0.304800",
59-
"FromBaseToUnitFunc": "{x}/0.304800",
58+
"FromUnitToBaseFunc": "{x} * 0.304800",
59+
"FromBaseToUnitFunc": "{x} / 0.304800",
6060
"Localization": [
6161
{
6262
"Culture": "en-US",
@@ -75,8 +75,8 @@
7575
"L": "NauticalMile",
7676
"T": "Second"
7777
},
78-
"FromUnitToBaseFunc": "{x}*0.5144444444444",
79-
"FromBaseToUnitFunc": "{x}/0.5144444444444",
78+
"FromUnitToBaseFunc": "{x} * 0.5144444444444",
79+
"FromBaseToUnitFunc": "{x} / 0.5144444444444",
8080
"Localization": [
8181
{
8282
"Culture": "en-US",
@@ -95,8 +95,8 @@
9595
"L": "NauticalMile",
9696
"T": "Minute"
9797
},
98-
"FromUnitToBaseFunc": "{x}*0.5144444444444/60",
99-
"FromBaseToUnitFunc": "{x}/0.5144444444444*60",
98+
"FromUnitToBaseFunc": "{x} * 0.5144444444444 / 60",
99+
"FromBaseToUnitFunc": "{x} / 0.5144444444444 * 60",
100100
"Localization": [
101101
{
102102
"Culture": "en-US",
@@ -115,8 +115,8 @@
115115
"L": "NauticalMile",
116116
"T": "Hour"
117117
},
118-
"FromUnitToBaseFunc": "{x}*0.5144444444444/3600",
119-
"FromBaseToUnitFunc": "{x}/0.5144444444444*3600",
118+
"FromUnitToBaseFunc": "{x} * 0.5144444444444 / 3600",
119+
"FromBaseToUnitFunc": "{x} / 0.5144444444444 * 3600",
120120
"Localization": [
121121
{
122122
"Culture": "en-US",
@@ -135,8 +135,8 @@
135135
"L": "Meter",
136136
"T": "Second"
137137
},
138-
"FromUnitToBaseFunc": "{x}*9.80665",
139-
"FromBaseToUnitFunc": "{x}/9.80665",
138+
"FromUnitToBaseFunc": "{x} * 9.80665",
139+
"FromBaseToUnitFunc": "{x} / 9.80665",
140140
"Prefixes": [ "Milli"],
141141
"Localization": [
142142
{

Common/UnitDefinitions/AmountOfSubstance.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"BaseUnits": {
2929
"N": "PoundMole"
3030
},
31-
"FromUnitToBaseFunc": "{x}*453.59237",
32-
"FromBaseToUnitFunc": "{x}/453.59237",
31+
"FromUnitToBaseFunc": "{x} * 453.59237",
32+
"FromBaseToUnitFunc": "{x} / 453.59237",
3333
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
3434
"Localization": [
3535
{

Common/UnitDefinitions/Angle.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
{
77
"SingularName": "Radian",
88
"PluralName": "Radians",
9-
"FromUnitToBaseFunc": "{x}*180/Math.PI",
10-
"FromBaseToUnitFunc": "{x}/180*Math.PI",
9+
"FromUnitToBaseFunc": "{x} * 180 / Math.PI",
10+
"FromBaseToUnitFunc": "{x} / 180 * Math.PI",
1111
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci" ],
1212
"Localization": [
1313
{
@@ -40,8 +40,8 @@
4040
{
4141
"SingularName": "Arcminute",
4242
"PluralName": "Arcminutes",
43-
"FromUnitToBaseFunc": "{x}/60",
44-
"FromBaseToUnitFunc": "{x}*60",
43+
"FromUnitToBaseFunc": "{x} / 60",
44+
"FromBaseToUnitFunc": "{x} * 60",
4545
"Localization": [
4646
{
4747
"Culture": "en-US",
@@ -52,8 +52,8 @@
5252
{
5353
"SingularName": "Arcsecond",
5454
"PluralName": "Arcseconds",
55-
"FromUnitToBaseFunc": "{x}/3600",
56-
"FromBaseToUnitFunc": "{x}*3600",
55+
"FromUnitToBaseFunc": "{x} / 3600",
56+
"FromBaseToUnitFunc": "{x} * 3600",
5757
"Localization": [
5858
{
5959
"Culture": "en-US",
@@ -64,8 +64,8 @@
6464
{
6565
"SingularName": "Gradian",
6666
"PluralName": "Gradians",
67-
"FromUnitToBaseFunc": "{x}*0.9",
68-
"FromBaseToUnitFunc": "{x}/0.9",
67+
"FromUnitToBaseFunc": "{x} * 0.9",
68+
"FromBaseToUnitFunc": "{x} / 0.9",
6969
"Localization": [
7070
{
7171
"Culture": "en-US",
@@ -80,8 +80,8 @@
8080
{
8181
"SingularName": "NatoMil",
8282
"PluralName": "NatoMils",
83-
"FromUnitToBaseFunc": "{x}*9/160",
84-
"FromBaseToUnitFunc": "{x}*160/9",
83+
"FromUnitToBaseFunc": "{x} * 9 / 160",
84+
"FromBaseToUnitFunc": "{x} * 160 / 9",
8585
"Localization": [
8686
{
8787
"Culture": "en-US",
@@ -92,8 +92,8 @@
9292
{
9393
"SingularName": "Revolution",
9494
"PluralName": "Revolutions",
95-
"FromUnitToBaseFunc": "{x}*360",
96-
"FromBaseToUnitFunc": "{x}/360",
95+
"FromUnitToBaseFunc": "{x} * 360",
96+
"FromBaseToUnitFunc": "{x} / 360",
9797
"Localization": [
9898
{
9999
"Culture": "en-US",
@@ -108,8 +108,8 @@
108108
{
109109
"SingularName": "Tilt",
110110
"PluralName": "Tilt",
111-
"FromUnitToBaseFunc": "Math.Asin({x})*180/Math.PI",
112-
"FromBaseToUnitFunc": "Math.Sin({x}/180*Math.PI)",
111+
"FromUnitToBaseFunc": "Math.Asin({x}) * 180 / Math.PI",
112+
"FromBaseToUnitFunc": "Math.Sin({x} / 180 * Math.PI)",
113113
"Localization": [
114114
{
115115
"Culture": "en-US",

Common/UnitDefinitions/Area.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"BaseUnits": {
1313
"L": "Kilometer"
1414
},
15-
"FromUnitToBaseFunc": "{x}*1e6",
16-
"FromBaseToUnitFunc": "{x}/1e6",
15+
"FromUnitToBaseFunc": "{x} * 1e6",
16+
"FromBaseToUnitFunc": "{x} / 1e6",
1717
"Localization": [
1818
{
1919
"Culture": "en-US",
@@ -58,8 +58,8 @@
5858
"BaseUnits": {
5959
"L": "Decimeter"
6060
},
61-
"FromUnitToBaseFunc": "{x}*1e-2",
62-
"FromBaseToUnitFunc": "{x}/1e-2",
61+
"FromUnitToBaseFunc": "{x} * 1e-2",
62+
"FromBaseToUnitFunc": "{x} / 1e-2",
6363
"Localization": [
6464
{
6565
"Culture": "en-US",
@@ -81,8 +81,8 @@
8181
"BaseUnits": {
8282
"L": "Centimeter"
8383
},
84-
"FromUnitToBaseFunc": "{x}*1e-4",
85-
"FromBaseToUnitFunc": "{x}/1e-4",
84+
"FromUnitToBaseFunc": "{x} * 1e-4",
85+
"FromBaseToUnitFunc": "{x} / 1e-4",
8686
"Localization": [
8787
{
8888
"Culture": "en-US",
@@ -104,8 +104,8 @@
104104
"BaseUnits": {
105105
"L": "Millimeter"
106106
},
107-
"FromUnitToBaseFunc": "{x}*1e-6",
108-
"FromBaseToUnitFunc": "{x}/1e-6",
107+
"FromUnitToBaseFunc": "{x} * 1e-6",
108+
"FromBaseToUnitFunc": "{x} / 1e-6",
109109
"Localization": [
110110
{
111111
"Culture": "en-US",
@@ -127,8 +127,8 @@
127127
"BaseUnits": {
128128
"L": "Micrometer"
129129
},
130-
"FromUnitToBaseFunc": "{x}*1e-12",
131-
"FromBaseToUnitFunc": "{x}/1e-12",
130+
"FromUnitToBaseFunc": "{x} * 1e-12",
131+
"FromBaseToUnitFunc": "{x} / 1e-12",
132132
"Localization": [
133133
{
134134
"Culture": "en-US",
@@ -150,8 +150,8 @@
150150
"BaseUnits": {
151151
"L": "Mile"
152152
},
153-
"FromUnitToBaseFunc": "{x}*2.59e6",
154-
"FromBaseToUnitFunc": "{x}/2.59e6",
153+
"FromUnitToBaseFunc": "{x} * 2.59e6",
154+
"FromBaseToUnitFunc": "{x} / 2.59e6",
155155
"Localization": [
156156
{
157157
"Culture": "en-US",
@@ -173,8 +173,8 @@
173173
"BaseUnits": {
174174
"L": "Yard"
175175
},
176-
"FromUnitToBaseFunc": "{x}*0.836127",
177-
"FromBaseToUnitFunc": "{x}/0.836127",
176+
"FromUnitToBaseFunc": "{x} * 0.836127",
177+
"FromBaseToUnitFunc": "{x} / 0.836127",
178178
"Localization": [
179179
{
180180
"Culture": "en-US",
@@ -219,8 +219,8 @@
219219
"BaseUnits": {
220220
"L": "UsSurveyFoot"
221221
},
222-
"FromUnitToBaseFunc": "{x}*0.09290341161",
223-
"FromBaseToUnitFunc": "{x}/0.09290341161",
222+
"FromUnitToBaseFunc": "{x} * 0.09290341161",
223+
"FromBaseToUnitFunc": "{x} / 0.09290341161",
224224
"Localization": [
225225
{
226226
"Culture": "en-US",
@@ -238,8 +238,8 @@
238238
"BaseUnits": {
239239
"L": "Inch"
240240
},
241-
"FromUnitToBaseFunc": "{x}*0.00064516",
242-
"FromBaseToUnitFunc": "{x}/0.00064516",
241+
"FromUnitToBaseFunc": "{x} * 0.00064516",
242+
"FromBaseToUnitFunc": "{x} / 0.00064516",
243243
"Localization": [
244244
{
245245
"Culture": "en-US",
@@ -258,8 +258,8 @@
258258
{
259259
"SingularName": "Acre",
260260
"PluralName": "Acres",
261-
"FromUnitToBaseFunc": "{x}*4046.85642",
262-
"FromBaseToUnitFunc": "{x}/4046.85642",
261+
"FromUnitToBaseFunc": "{x} * 4046.85642",
262+
"FromBaseToUnitFunc": "{x} / 4046.85642",
263263
"Localization": [
264264
{
265265
"Culture": "en-US",
@@ -278,8 +278,8 @@
278278
{
279279
"SingularName": "Hectare",
280280
"PluralName": "Hectares",
281-
"FromUnitToBaseFunc": "{x}*1e4",
282-
"FromBaseToUnitFunc": "{x}/1e4",
281+
"FromUnitToBaseFunc": "{x} * 1e4",
282+
"FromBaseToUnitFunc": "{x} / 1e4",
283283
"Localization": [
284284
{
285285
"Culture": "en-US",
@@ -298,8 +298,8 @@
298298
{
299299
"SingularName": "SquareNauticalMile",
300300
"PluralName": "SquareNauticalMiles",
301-
"FromUnitToBaseFunc": "{x}*3429904",
302-
"FromBaseToUnitFunc": "{x}/3429904",
301+
"FromUnitToBaseFunc": "{x} * 3429904",
302+
"FromBaseToUnitFunc": "{x} / 3429904",
303303
"Localization": [
304304
{
305305
"Culture": "en-US",

Common/UnitDefinitions/AreaMomentOfInertia.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"BaseUnits": {
2828
"L": "Decimeter"
2929
},
30-
"FromUnitToBaseFunc": "{x}/1e4",
31-
"FromBaseToUnitFunc": "{x}*1e4",
30+
"FromUnitToBaseFunc": "{x} / 1e4",
31+
"FromBaseToUnitFunc": "{x} * 1e4",
3232
"Localization": [
3333
{
3434
"Culture": "en-US",
@@ -42,8 +42,8 @@
4242
"BaseUnits": {
4343
"L": "Centimeter"
4444
},
45-
"FromUnitToBaseFunc": "{x}/1e8",
46-
"FromBaseToUnitFunc": "{x}*1e8",
45+
"FromUnitToBaseFunc": "{x} / 1e8",
46+
"FromBaseToUnitFunc": "{x} * 1e8",
4747
"Localization": [
4848
{
4949
"Culture": "en-US",
@@ -57,8 +57,8 @@
5757
"BaseUnits": {
5858
"L": "Millimeter"
5959
},
60-
"FromUnitToBaseFunc": "{x}/1e12",
61-
"FromBaseToUnitFunc": "{x}*1e12",
60+
"FromUnitToBaseFunc": "{x} / 1e12",
61+
"FromBaseToUnitFunc": "{x} * 1e12",
6262
"Localization": [
6363
{
6464
"Culture": "en-US",
@@ -72,8 +72,8 @@
7272
"BaseUnits": {
7373
"L": "Foot"
7474
},
75-
"FromUnitToBaseFunc": "{x}*Math.Pow(0.3048, 4)",
76-
"FromBaseToUnitFunc": "{x}/Math.Pow(0.3048, 4)",
75+
"FromUnitToBaseFunc": "{x} * Math.Pow(0.3048, 4)",
76+
"FromBaseToUnitFunc": "{x} / Math.Pow(0.3048, 4)",
7777
"Localization": [
7878
{
7979
"Culture": "en-US",
@@ -87,8 +87,8 @@
8787
"BaseUnits": {
8888
"L": "Inch"
8989
},
90-
"FromUnitToBaseFunc": "{x}*Math.Pow(2.54e-2, 4)",
91-
"FromBaseToUnitFunc": "{x}/Math.Pow(2.54e-2, 4)",
90+
"FromUnitToBaseFunc": "{x} * Math.Pow(2.54e-2, 4)",
91+
"FromBaseToUnitFunc": "{x} / Math.Pow(2.54e-2, 4)",
9292
"Localization": [
9393
{
9494
"Culture": "en-US",

Common/UnitDefinitions/BitRate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
{
2323
"SingularName": "BytePerSecond",
2424
"PluralName": "BytesPerSecond",
25-
"FromUnitToBaseFunc": "{x}*8m",
26-
"FromBaseToUnitFunc": "{x}/8m",
25+
"FromUnitToBaseFunc": "{x} * 8m",
26+
"FromBaseToUnitFunc": "{x} / 8m",
2727
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
2828
"Localization": [
2929
{

0 commit comments

Comments
 (0)