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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)