Skip to content

Commit ebd3275

Browse files
committed
Fix consistent whitespace of if expressions
1 parent 38405dc commit ebd3275

File tree

471 files changed

+3803
-4141
lines changed

Some content is hidden

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

471 files changed

+3803
-4141
lines changed

CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override string Generate()
4242
<dependencies>
4343
<dependency id=""nanoFramework.CoreLibrary"" version=""{_mscorlibNuGetVersion}"" />");
4444

45-
if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
45+
if (NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
4646
{
4747
Writer.WL($@"
4848
<dependency id=""nanoFramework.System.Math"" version=""{_mathNuGetVersion}"" />");

CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public override string Generate()
4848
<SpecificVersion>True</SpecificVersion>
4949
</Reference>");
5050

51-
if(NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
51+
if (NanoFrameworkGenerator.ProjectsRequiringMath.Contains(_quantity.Name))
5252
{
5353
Writer.WL($@"
5454
<Reference Include=""System.Math, Version={_versions.MathVersion}, Culture=neutral, PublicKeyToken=c07d481e9758c731"">

CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class QuantityGenerator : GeneratorBase
1414
public QuantityGenerator(Quantity quantity)
1515
{
1616
_quantity = quantity ?? throw new ArgumentNullException(nameof(quantity));
17-
_unitEnumName = $"{quantity.Name}Unit";
17+
_unitEnumName = $"{quantity.Name}Unit";
1818
}
1919

2020
public override string Generate()
@@ -124,7 +124,7 @@ private void GenerateConversionProperties()
124124
");
125125
foreach (var unit in _quantity.Units)
126126
{
127-
if(unit.SkipConversionGeneration)
127+
if (unit.SkipConversionGeneration)
128128
continue;
129129

130130
Writer.WL($@"
@@ -149,7 +149,7 @@ private void GenerateStaticFactoryMethods()
149149
");
150150
foreach (var unit in _quantity.Units)
151151
{
152-
if(unit.SkipConversionGeneration)
152+
if (unit.SkipConversionGeneration)
153153
continue;
154154

155155
var valueParamName = unit.PluralName.ToLowerInvariant();
@@ -189,20 +189,18 @@ private void GenerateConversionMethods()
189189
/// Convert to the unit representation <paramref name=""unit"" />.
190190
/// </summary>
191191
/// <returns>Value converted to the specified unit.</returns>
192-
public {_quantity.BaseType} As({_unitEnumName} unit) => GetValueAs(unit);
192+
public {_quantity.BaseType} As({_unitEnumName} unit) => GetValueAs(unit);
193193
194194
/// <summary>
195195
/// Converts this Duration to another Duration with the unit representation <paramref name=""unit"" />.
196196
/// </summary>
197197
/// <returns>A Duration with the specified unit.</returns>
198198
public {_quantity.Name} ToUnit({_unitEnumName} unit)
199199
{{
200-
201200
var convertedValue = GetValueAs(unit);
202201
return new {_quantity.Name}(convertedValue, unit);
203202
}}
204203
205-
206204
/// <summary>
207205
/// Converts the current value + unit to the base unit.
208206
/// This is typically the first step in converting from one unit to another.
@@ -227,7 +225,7 @@ private void GenerateConversionMethods()
227225
228226
private {_quantity.BaseType} GetValueAs({_unitEnumName} unit)
229227
{{
230-
if(Unit == unit)
228+
if (Unit == unit)
231229
return _value;
232230
233231
var baseUnitValue = GetValueInBaseUnit();

CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static class NumberTo{_quantityName}Extensions
3737

3838
foreach (var unit in _units)
3939
{
40-
if(unit.SkipConversionGeneration)
40+
if (unit.SkipConversionGeneration)
4141
continue;
4242

4343
Writer.WL(2, $@"

CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class NumberTo{_quantityName}ExtensionsTests
3333

3434
foreach (var unit in _units)
3535
{
36-
if(unit.SkipConversionGeneration)
36+
if (unit.SkipConversionGeneration)
3737
continue;
3838

3939
Writer.WL(2, $@"

CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs

+27-27
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private void GenerateInstanceConstructors()
183183
/// <exception cref=""ArgumentException"">If value is NaN or Infinity.</exception>
184184
public {_quantity.Name}({_quantity.BaseType} value, {_unitEnumName} unit)
185185
{{
186-
if(unit == {_unitEnumName}.Undefined)
186+
if (unit == {_unitEnumName}.Undefined)
187187
throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit));
188188
");
189189

@@ -206,7 +206,7 @@ private void GenerateInstanceConstructors()
206206
/// <exception cref=""ArgumentException"">No unit was found for the given <see cref=""UnitSystem""/>.</exception>
207207
public {_quantity.Name}({_valueType} value, UnitSystem unitSystem)
208208
{{
209-
if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
209+
if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
210210
211211
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
212212
var firstUnitInfo = unitInfos.FirstOrDefault();
@@ -334,7 +334,7 @@ private void GenerateConversionProperties()
334334
");
335335
foreach (var unit in _quantity.Units)
336336
{
337-
if(unit.SkipConversionGeneration)
337+
if (unit.SkipConversionGeneration)
338338
continue;
339339

340340
Writer.WL($@"
@@ -369,7 +369,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
369369

370370
foreach(var unit in _quantity.Units)
371371
{
372-
if(unit.SingularName == _quantity.BaseUnit)
372+
if (unit.SingularName == _quantity.BaseUnit)
373373
continue;
374374

375375
var func = unit.FromBaseToUnitFunc.Replace("{x}", "quantity.Value");
@@ -378,15 +378,15 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter)
378378
}
379379

380380
Writer.WL($@"
381-
381+
382382
// Register in unit converter: BaseUnit <-> BaseUnit
383383
unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{_quantity.BaseUnit}, quantity => quantity);
384384
385385
// Register in unit converter: {_quantity.Name}Unit -> BaseUnit");
386386

387387
foreach(var unit in _quantity.Units)
388388
{
389-
if(unit.SingularName == _quantity.BaseUnit)
389+
if (unit.SingularName == _quantity.BaseUnit)
390390
continue;
391391

392392
var func = unit.FromUnitToBaseFunc.Replace("{x}", "quantity.Value");
@@ -448,7 +448,7 @@ private void GenerateStaticFactoryMethods()
448448
");
449449
foreach (var unit in _quantity.Units)
450450
{
451-
if(unit.SkipConversionGeneration)
451+
if (unit.SkipConversionGeneration)
452452
continue;
453453

454454
var valueParamName = unit.PluralName.ToLowerInvariant();
@@ -801,8 +801,8 @@ private void GenerateEqualityAndComparison()
801801
/// <inheritdoc />
802802
public int CompareTo(object obj)
803803
{{
804-
if(obj is null) throw new ArgumentNullException(nameof(obj));
805-
if(!(obj is {_quantity.Name} obj{_quantity.Name})) throw new ArgumentException(""Expected type {_quantity.Name}."", nameof(obj));
804+
if (obj is null) throw new ArgumentNullException(nameof(obj));
805+
if (!(obj is {_quantity.Name} obj{_quantity.Name})) throw new ArgumentException(""Expected type {_quantity.Name}."", nameof(obj));
806806
807807
return CompareTo(obj{_quantity.Name});
808808
}}
@@ -817,7 +817,7 @@ public int CompareTo({_quantity.Name} other)
817817
/// <remarks>Consider using <see cref=""Equals({_quantity.Name}, double, ComparisonType)""/> for safely comparing floating point values.</remarks>
818818
public override bool Equals(object obj)
819819
{{
820-
if(obj is null || !(obj is {_quantity.Name} obj{_quantity.Name}))
820+
if (obj is null || !(obj is {_quantity.Name} obj{_quantity.Name}))
821821
return false;
822822
823823
return Equals(obj{_quantity.Name});
@@ -872,7 +872,7 @@ public bool Equals({_quantity.Name} other)
872872
/// <returns>True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.</returns>
873873
public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType)
874874
{{
875-
if(tolerance < 0)
875+
if (tolerance < 0)
876876
throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0."");
877877
878878
double thisValue = (double)this.Value;
@@ -905,7 +905,7 @@ private void GenerateConversionMethods()
905905
/// <returns>Value converted to the specified unit.</returns>
906906
public double As({_unitEnumName} unit)
907907
{{
908-
if(Unit == unit)
908+
if (Unit == unit)
909909
return Convert.ToDouble(Value);
910910
911911
var converted = GetValueAs(unit);
@@ -915,13 +915,13 @@ public double As({_unitEnumName} unit)
915915
/// <inheritdoc cref=""IQuantity.As(UnitSystem)""/>
916916
public double As(UnitSystem unitSystem)
917917
{{
918-
if(unitSystem is null)
918+
if (unitSystem is null)
919919
throw new ArgumentNullException(nameof(unitSystem));
920920
921921
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
922922
923923
var firstUnitInfo = unitInfos.FirstOrDefault();
924-
if(firstUnitInfo == null)
924+
if (firstUnitInfo == null)
925925
throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem));
926926
927927
return As(firstUnitInfo.Value);
@@ -930,7 +930,7 @@ public double As(UnitSystem unitSystem)
930930
/// <inheritdoc />
931931
double IQuantity.As(Enum unit)
932932
{{
933-
if(!(unit is {_unitEnumName} unitAs{_unitEnumName}))
933+
if (!(unit is {_unitEnumName} unitAs{_unitEnumName}))
934934
throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit));
935935
936936
return As(unitAs{_unitEnumName});
@@ -954,18 +954,18 @@ double IQuantity.As(Enum unit)
954954
/// <returns>A {_quantity.Name} with the specified unit.</returns>
955955
public {_quantity.Name} ToUnit({_unitEnumName} unit, UnitConverter unitConverter)
956956
{{
957-
if(Unit == unit)
957+
if (Unit == unit)
958958
{{
959959
// Already in requested units.
960960
return this;
961961
}}
962-
else if(unitConverter.TryGetConversionFunction((typeof({_quantity.Name}), Unit, typeof({_quantity.Name}), unit), out var conversionFunction))
962+
else if (unitConverter.TryGetConversionFunction((typeof({_quantity.Name}), Unit, typeof({_quantity.Name}), unit), out var conversionFunction))
963963
{{
964964
// Direct conversion to requested unit found. Return the converted quantity.
965965
var converted = conversionFunction(this);
966966
return ({_quantity.Name})converted;
967967
}}
968-
else if(Unit != BaseUnit)
968+
else if (Unit != BaseUnit)
969969
{{
970970
// Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit.
971971
var inBaseUnits = ToUnit(BaseUnit);
@@ -980,7 +980,7 @@ double IQuantity.As(Enum unit)
980980
/// <inheritdoc />
981981
IQuantity IQuantity.ToUnit(Enum unit)
982982
{{
983-
if(!(unit is {_unitEnumName} unitAs{_unitEnumName}))
983+
if (!(unit is {_unitEnumName} unitAs{_unitEnumName}))
984984
throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit));
985985
986986
return ToUnit(unitAs{_unitEnumName}, DefaultConversionFunctions);
@@ -989,7 +989,7 @@ IQuantity IQuantity.ToUnit(Enum unit)
989989
/// <inheritdoc />
990990
IQuantity IQuantity.ToUnit(Enum unit, UnitConverter unitConverter)
991991
{{
992-
if(!(unit is {_unitEnumName} unitAs{_unitEnumName}))
992+
if (!(unit is {_unitEnumName} unitAs{_unitEnumName}))
993993
throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit));
994994
995995
return ToUnit(unitAs{_unitEnumName}, unitConverter);
@@ -998,13 +998,13 @@ IQuantity IQuantity.ToUnit(Enum unit, UnitConverter unitConverter)
998998
/// <inheritdoc cref=""IQuantity.ToUnit(UnitSystem)""/>
999999
public {_quantity.Name} ToUnit(UnitSystem unitSystem)
10001000
{{
1001-
if(unitSystem is null)
1001+
if (unitSystem is null)
10021002
throw new ArgumentNullException(nameof(unitSystem));
10031003
10041004
var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits);
10051005
10061006
var firstUnitInfo = unitInfos.FirstOrDefault();
1007-
if(firstUnitInfo == null)
1007+
if (firstUnitInfo == null)
10081008
throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem));
10091009
10101010
return ToUnit(firstUnitInfo.Value);
@@ -1189,15 +1189,15 @@ string IConvertible.ToString(IFormatProvider provider)
11891189
11901190
object IConvertible.ToType(Type conversionType, IFormatProvider provider)
11911191
{{
1192-
if(conversionType == typeof({_quantity.Name}))
1192+
if (conversionType == typeof({_quantity.Name}))
11931193
return this;
1194-
else if(conversionType == typeof({_unitEnumName}))
1194+
else if (conversionType == typeof({_unitEnumName}))
11951195
return Unit;
1196-
else if(conversionType == typeof(QuantityType))
1196+
else if (conversionType == typeof(QuantityType))
11971197
return {_quantity.Name}.QuantityType;
1198-
else if(conversionType == typeof(QuantityInfo))
1198+
else if (conversionType == typeof(QuantityInfo))
11991199
return {_quantity.Name}.Info;
1200-
else if(conversionType == typeof(BaseDimensions))
1200+
else if (conversionType == typeof(BaseDimensions))
12011201
return {_quantity.Name}.BaseDimensions;
12021202
else
12031203
throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to {{conversionType}} is not supported."");

CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase
9898
{{");
9999
foreach (var unit in _quantity.Units)
100100
{
101-
if(unit.SkipConversionGeneration)
101+
if (unit.SkipConversionGeneration)
102102
continue;
103103

104104
Writer.WL($@"
@@ -110,7 +110,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase
110110
// ReSharper disable VirtualMemberNeverOverriden.Global");
111111
foreach (var unit in _quantity.Units)
112112
{
113-
if(unit.SkipConversionGeneration)
113+
if (unit.SkipConversionGeneration)
114114
continue;
115115

116116
Writer.WL($@"
@@ -151,14 +151,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
151151
{{
152152
var quantity = new {_quantity.Name}();
153153
Assert.Equal(0, quantity.Value);");
154-
if(_quantity.BaseType == "decimal") Writer.WL($@"
154+
if (_quantity.BaseType == "decimal") Writer.WL($@"
155155
Assert.Equal(0m, ((IDecimalQuantity)quantity).Value);");
156156
Writer.WL($@"
157157
Assert.Equal({_baseUnitFullName}, quantity.Unit);
158158
}}
159159
160160
");
161-
if(_quantity.BaseType == "double") Writer.WL($@"
161+
if (_quantity.BaseType == "double") Writer.WL($@"
162162
[Fact]
163163
public void Ctor_WithInfinityValue_ThrowsArgumentException()
164164
{{
@@ -240,7 +240,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
240240
Writer.WL($@"
241241
}}
242242
");
243-
if(_quantity.BaseType == "double") Writer.WL($@"
243+
if (_quantity.BaseType == "double") Writer.WL($@"
244244
[Fact]
245245
public void From{_baseUnit.PluralName}_WithInfinityValue_ThrowsArgumentException()
246246
{{
@@ -310,7 +310,7 @@ public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName}
310310
var fromUnit = {_quantity.Name}.Units.FirstOrDefault(u => u != {_quantity.Name}.BaseUnit && u != {_unitEnumName}.Undefined);
311311
312312
// If there is only one unit for the quantity, we must use the base unit.
313-
if(fromUnit == {_unitEnumName}.Undefined)
313+
if (fromUnit == {_unitEnumName}.Undefined)
314314
fromUnit = {_quantity.Name}.BaseUnit;
315315
316316
var quantity = {_quantity.Name}.From(3.0, fromUnit);
@@ -496,7 +496,7 @@ public void HasAtLeastOneAbbreviationSpecified()
496496
var units = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>();
497497
foreach(var unit in units)
498498
{{
499-
if(unit == {_unitEnumName}.Undefined)
499+
if (unit == {_unitEnumName}.Undefined)
500500
continue;
501501
502502
var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
@@ -748,7 +748,7 @@ public void GetHashCode_Equals()
748748
}}
749749
");
750750

751-
if(_quantity.GenerateArithmetic)
751+
if (_quantity.GenerateArithmetic)
752752
{
753753
Writer.WL($@"
754754
[Theory]

0 commit comments

Comments
 (0)