Skip to content

Commit 157b288

Browse files
tmilnthorpangularsen
authored andcommitted
Fixing nasty bug in GetHashCode where two quantities with the same nu… (#541)
* Fixing nasty bug in GetHashCode where two quantities with the same numerical value/unit pair returned the same hash code. Type needed in GetHashCode implementation to guarantee uniqueness. * Using cleanup
1 parent 0f4769d commit 157b288

File tree

92 files changed

+129
-91
lines changed

Some content is hidden

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

92 files changed

+129
-91
lines changed

Common/GeneratedCode/Quantities/Acceleration.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public bool Equals(Acceleration other, Acceleration maxError)
550550
/// <returns>A hash code for the current Acceleration.</returns>
551551
public override int GetHashCode()
552552
{
553-
return new { Value, Unit }.GetHashCode();
553+
return new { type = typeof(Acceleration), Value, Unit }.GetHashCode();
554554
}
555555

556556
#endregion

Common/GeneratedCode/Quantities/AmountOfSubstance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public bool Equals(AmountOfSubstance other, AmountOfSubstance maxError)
569569
/// <returns>A hash code for the current AmountOfSubstance.</returns>
570570
public override int GetHashCode()
571571
{
572-
return new { Value, Unit }.GetHashCode();
572+
return new { type = typeof(AmountOfSubstance), Value, Unit }.GetHashCode();
573573
}
574574

575575
#endregion

Common/GeneratedCode/Quantities/AmplitudeRatio.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public bool Equals(AmplitudeRatio other, AmplitudeRatio maxError)
378378
/// <returns>A hash code for the current AmplitudeRatio.</returns>
379379
public override int GetHashCode()
380380
{
381-
return new { Value, Unit }.GetHashCode();
381+
return new { type = typeof(AmplitudeRatio), Value, Unit }.GetHashCode();
382382
}
383383

384384
#endregion

Common/GeneratedCode/Quantities/Angle.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ public bool Equals(Angle other, Angle maxError)
568568
/// <returns>A hash code for the current Angle.</returns>
569569
public override int GetHashCode()
570570
{
571-
return new { Value, Unit }.GetHashCode();
571+
return new { type = typeof(Angle), Value, Unit }.GetHashCode();
572572
}
573573

574574
#endregion

Common/GeneratedCode/Quantities/ApparentEnergy.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public bool Equals(ApparentEnergy other, ApparentEnergy maxError)
360360
/// <returns>A hash code for the current ApparentEnergy.</returns>
361361
public override int GetHashCode()
362362
{
363-
return new { Value, Unit }.GetHashCode();
363+
return new { type = typeof(ApparentEnergy), Value, Unit }.GetHashCode();
364364
}
365365

366366
#endregion

Common/GeneratedCode/Quantities/ApparentPower.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public bool Equals(ApparentPower other, ApparentPower maxError)
379379
/// <returns>A hash code for the current ApparentPower.</returns>
380380
public override int GetHashCode()
381381
{
382-
return new { Value, Unit }.GetHashCode();
382+
return new { type = typeof(ApparentPower), Value, Unit }.GetHashCode();
383383
}
384384

385385
#endregion

Common/GeneratedCode/Quantities/Area.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public bool Equals(Area other, Area maxError)
550550
/// <returns>A hash code for the current Area.</returns>
551551
public override int GetHashCode()
552552
{
553-
return new { Value, Unit }.GetHashCode();
553+
return new { type = typeof(Area), Value, Unit }.GetHashCode();
554554
}
555555

556556
#endregion

Common/GeneratedCode/Quantities/AreaDensity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(AreaDensity other, AreaDensity maxError)
322322
/// <returns>A hash code for the current AreaDensity.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(AreaDensity), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/AreaMomentOfInertia.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public bool Equals(AreaMomentOfInertia other, AreaMomentOfInertia maxError)
417417
/// <returns>A hash code for the current AreaMomentOfInertia.</returns>
418418
public override int GetHashCode()
419419
{
420-
return new { Value, Unit }.GetHashCode();
420+
return new { type = typeof(AreaMomentOfInertia), Value, Unit }.GetHashCode();
421421
}
422422

423423
#endregion

Common/GeneratedCode/Quantities/BitRate.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ public bool Equals(BitRate other, BitRate maxError)
795795
/// <returns>A hash code for the current BitRate.</returns>
796796
public override int GetHashCode()
797797
{
798-
return new { Value, Unit }.GetHashCode();
798+
return new { type = typeof(BitRate), Value, Unit }.GetHashCode();
799799
}
800800

801801
#endregion

Common/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public bool Equals(BrakeSpecificFuelConsumption other, BrakeSpecificFuelConsumpt
360360
/// <returns>A hash code for the current BrakeSpecificFuelConsumption.</returns>
361361
public override int GetHashCode()
362362
{
363-
return new { Value, Unit }.GetHashCode();
363+
return new { type = typeof(BrakeSpecificFuelConsumption), Value, Unit }.GetHashCode();
364364
}
365365

366366
#endregion

Common/GeneratedCode/Quantities/Capacitance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(Capacitance other, Capacitance maxError)
322322
/// <returns>A hash code for the current Capacitance.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(Capacitance), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/Density.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ public bool Equals(Density other, Density maxError)
10251025
/// <returns>A hash code for the current Density.</returns>
10261026
public override int GetHashCode()
10271027
{
1028-
return new { Value, Unit }.GetHashCode();
1028+
return new { type = typeof(Density), Value, Unit }.GetHashCode();
10291029
}
10301030

10311031
#endregion

Common/GeneratedCode/Quantities/Duration.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public bool Equals(Duration other, Duration maxError)
535535
/// <returns>A hash code for the current Duration.</returns>
536536
public override int GetHashCode()
537537
{
538-
return new { Value, Unit }.GetHashCode();
538+
return new { type = typeof(Duration), Value, Unit }.GetHashCode();
539539
}
540540

541541
#endregion

Common/GeneratedCode/Quantities/DynamicViscosity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public bool Equals(DynamicViscosity other, DynamicViscosity maxError)
417417
/// <returns>A hash code for the current DynamicViscosity.</returns>
418418
public override int GetHashCode()
419419
{
420-
return new { Value, Unit }.GetHashCode();
420+
return new { type = typeof(DynamicViscosity), Value, Unit }.GetHashCode();
421421
}
422422

423423
#endregion

Common/GeneratedCode/Quantities/ElectricAdmittance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public bool Equals(ElectricAdmittance other, ElectricAdmittance maxError)
379379
/// <returns>A hash code for the current ElectricAdmittance.</returns>
380380
public override int GetHashCode()
381381
{
382-
return new { Value, Unit }.GetHashCode();
382+
return new { type = typeof(ElectricAdmittance), Value, Unit }.GetHashCode();
383383
}
384384

385385
#endregion

Common/GeneratedCode/Quantities/ElectricCharge.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricCharge other, ElectricCharge maxError)
322322
/// <returns>A hash code for the current ElectricCharge.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricCharge), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricChargeDensity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricChargeDensity other, ElectricChargeDensity maxError)
322322
/// <returns>A hash code for the current ElectricChargeDensity.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricChargeDensity), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricConductance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public bool Equals(ElectricConductance other, ElectricConductance maxError)
360360
/// <returns>A hash code for the current ElectricConductance.</returns>
361361
public override int GetHashCode()
362362
{
363-
return new { Value, Unit }.GetHashCode();
363+
return new { type = typeof(ElectricConductance), Value, Unit }.GetHashCode();
364364
}
365365

366366
#endregion

Common/GeneratedCode/Quantities/ElectricConductivity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricConductivity other, ElectricConductivity maxError)
322322
/// <returns>A hash code for the current ElectricConductivity.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricConductivity), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricCurrent.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public bool Equals(ElectricCurrent other, ElectricCurrent maxError)
455455
/// <returns>A hash code for the current ElectricCurrent.</returns>
456456
public override int GetHashCode()
457457
{
458-
return new { Value, Unit }.GetHashCode();
458+
return new { type = typeof(ElectricCurrent), Value, Unit }.GetHashCode();
459459
}
460460

461461
#endregion

Common/GeneratedCode/Quantities/ElectricCurrentDensity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricCurrentDensity other, ElectricCurrentDensity maxError
322322
/// <returns>A hash code for the current ElectricCurrentDensity.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricCurrentDensity), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricCurrentGradient.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricCurrentGradient other, ElectricCurrentGradient maxErr
322322
/// <returns>A hash code for the current ElectricCurrentGradient.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricCurrentGradient), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricField.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricField other, ElectricField maxError)
322322
/// <returns>A hash code for the current ElectricField.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricField), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricInductance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public bool Equals(ElectricInductance other, ElectricInductance maxError)
322322
/// <returns>A hash code for the current ElectricInductance.</returns>
323323
public override int GetHashCode()
324324
{
325-
return new { Value, Unit }.GetHashCode();
325+
return new { type = typeof(ElectricInductance), Value, Unit }.GetHashCode();
326326
}
327327

328328
#endregion

Common/GeneratedCode/Quantities/ElectricPotential.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public bool Equals(ElectricPotential other, ElectricPotential maxError)
398398
/// <returns>A hash code for the current ElectricPotential.</returns>
399399
public override int GetHashCode()
400400
{
401-
return new { Value, Unit }.GetHashCode();
401+
return new { type = typeof(ElectricPotential), Value, Unit }.GetHashCode();
402402
}
403403

404404
#endregion

Common/GeneratedCode/Quantities/ElectricPotentialAc.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public bool Equals(ElectricPotentialAc other, ElectricPotentialAc maxError)
397397
/// <returns>A hash code for the current ElectricPotentialAc.</returns>
398398
public override int GetHashCode()
399399
{
400-
return new { Value, Unit }.GetHashCode();
400+
return new { type = typeof(ElectricPotentialAc), Value, Unit }.GetHashCode();
401401
}
402402

403403
#endregion

Common/GeneratedCode/Quantities/ElectricPotentialDc.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public bool Equals(ElectricPotentialDc other, ElectricPotentialDc maxError)
397397
/// <returns>A hash code for the current ElectricPotentialDc.</returns>
398398
public override int GetHashCode()
399399
{
400-
return new { Value, Unit }.GetHashCode();
400+
return new { type = typeof(ElectricPotentialDc), Value, Unit }.GetHashCode();
401401
}
402402

403403
#endregion

Common/GeneratedCode/Quantities/ElectricResistance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public bool Equals(ElectricResistance other, ElectricResistance maxError)
379379
/// <returns>A hash code for the current ElectricResistance.</returns>
380380
public override int GetHashCode()
381381
{
382-
return new { Value, Unit }.GetHashCode();
382+
return new { type = typeof(ElectricResistance), Value, Unit }.GetHashCode();
383383
}
384384

385385
#endregion

Common/GeneratedCode/Quantities/ElectricResistivity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public bool Equals(ElectricResistivity other, ElectricResistivity maxError)
379379
/// <returns>A hash code for the current ElectricResistivity.</returns>
380380
public override int GetHashCode()
381381
{
382-
return new { Value, Unit }.GetHashCode();
382+
return new { type = typeof(ElectricResistivity), Value, Unit }.GetHashCode();
383383
}
384384

385385
#endregion

Common/GeneratedCode/Quantities/Energy.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public bool Equals(Energy other, Energy maxError)
721721
/// <returns>A hash code for the current Energy.</returns>
722722
public override int GetHashCode()
723723
{
724-
return new { Value, Unit }.GetHashCode();
724+
return new { type = typeof(Energy), Value, Unit }.GetHashCode();
725725
}
726726

727727
#endregion

Common/GeneratedCode/Quantities/Entropy.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public bool Equals(Entropy other, Entropy maxError)
436436
/// <returns>A hash code for the current Entropy.</returns>
437437
public override int GetHashCode()
438438
{
439-
return new { Value, Unit }.GetHashCode();
439+
return new { type = typeof(Entropy), Value, Unit }.GetHashCode();
440440
}
441441

442442
#endregion

Common/GeneratedCode/Quantities/Flow.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ public bool Equals(Flow other, Flow maxError)
796796
/// <returns>A hash code for the current Flow.</returns>
797797
public override int GetHashCode()
798798
{
799-
return new { Value, Unit }.GetHashCode();
799+
return new { type = typeof(Flow), Value, Unit }.GetHashCode();
800800
}
801801

802802
#endregion

Common/GeneratedCode/Quantities/Force.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ public bool Equals(Force other, Force maxError)
550550
/// <returns>A hash code for the current Force.</returns>
551551
public override int GetHashCode()
552552
{
553-
return new { Value, Unit }.GetHashCode();
553+
return new { type = typeof(Force), Value, Unit }.GetHashCode();
554554
}
555555

556556
#endregion

Common/GeneratedCode/Quantities/ForceChangeRate.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ public bool Equals(ForceChangeRate other, ForceChangeRate maxError)
512512
/// <returns>A hash code for the current ForceChangeRate.</returns>
513513
public override int GetHashCode()
514514
{
515-
return new { Value, Unit }.GetHashCode();
515+
return new { type = typeof(ForceChangeRate), Value, Unit }.GetHashCode();
516516
}
517517

518518
#endregion

Common/GeneratedCode/Quantities/ForcePerLength.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public bool Equals(ForcePerLength other, ForcePerLength maxError)
474474
/// <returns>A hash code for the current ForcePerLength.</returns>
475475
public override int GetHashCode()
476476
{
477-
return new { Value, Unit }.GetHashCode();
477+
return new { type = typeof(ForcePerLength), Value, Unit }.GetHashCode();
478478
}
479479

480480
#endregion

Common/GeneratedCode/Quantities/Frequency.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public bool Equals(Frequency other, Frequency maxError)
455455
/// <returns>A hash code for the current Frequency.</returns>
456456
public override int GetHashCode()
457457
{
458-
return new { Value, Unit }.GetHashCode();
458+
return new { type = typeof(Frequency), Value, Unit }.GetHashCode();
459459
}
460460

461461
#endregion

Common/GeneratedCode/Quantities/HeatFlux.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public bool Equals(HeatFlux other, HeatFlux maxError)
607607
/// <returns>A hash code for the current HeatFlux.</returns>
608608
public override int GetHashCode()
609609
{
610-
return new { Value, Unit }.GetHashCode();
610+
return new { type = typeof(HeatFlux), Value, Unit }.GetHashCode();
611611
}
612612

613613
#endregion

Common/GeneratedCode/Quantities/HeatTransferCoefficient.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public bool Equals(HeatTransferCoefficient other, HeatTransferCoefficient maxErr
341341
/// <returns>A hash code for the current HeatTransferCoefficient.</returns>
342342
public override int GetHashCode()
343343
{
344-
return new { Value, Unit }.GetHashCode();
344+
return new { type = typeof(HeatTransferCoefficient), Value, Unit }.GetHashCode();
345345
}
346346

347347
#endregion

Common/GeneratedCode/Quantities/Illuminance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public bool Equals(Illuminance other, Illuminance maxError)
379379
/// <returns>A hash code for the current Illuminance.</returns>
380380
public override int GetHashCode()
381381
{
382-
return new { Value, Unit }.GetHashCode();
382+
return new { type = typeof(Illuminance), Value, Unit }.GetHashCode();
383383
}
384384

385385
#endregion

Common/GeneratedCode/Quantities/Information.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ public bool Equals(Information other, Information maxError)
795795
/// <returns>A hash code for the current Information.</returns>
796796
public override int GetHashCode()
797797
{
798-
return new { Value, Unit }.GetHashCode();
798+
return new { type = typeof(Information), Value, Unit }.GetHashCode();
799799
}
800800

801801
#endregion

Common/GeneratedCode/Quantities/Irradiance.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public bool Equals(Irradiance other, Irradiance maxError)
341341
/// <returns>A hash code for the current Irradiance.</returns>
342342
public override int GetHashCode()
343343
{
344-
return new { Value, Unit }.GetHashCode();
344+
return new { type = typeof(Irradiance), Value, Unit }.GetHashCode();
345345
}
346346

347347
#endregion

Common/GeneratedCode/Quantities/Irradiation.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public bool Equals(Irradiation other, Irradiation maxError)
360360
/// <returns>A hash code for the current Irradiation.</returns>
361361
public override int GetHashCode()
362362
{
363-
return new { Value, Unit }.GetHashCode();
363+
return new { type = typeof(Irradiation), Value, Unit }.GetHashCode();
364364
}
365365

366366
#endregion

Common/GeneratedCode/Quantities/KinematicViscosity.Common.g.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public bool Equals(KinematicViscosity other, KinematicViscosity maxError)
455455
/// <returns>A hash code for the current KinematicViscosity.</returns>
456456
public override int GetHashCode()
457457
{
458-
return new { Value, Unit }.GetHashCode();
458+
return new { type = typeof(KinematicViscosity), Value, Unit }.GetHashCode();
459459
}
460460

461461
#endregion

0 commit comments

Comments
 (0)