Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csharp/sbe-dll/PrimitiveType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
/// </tbody>
/// </table>
/// </summary>
public class PrimitiveType
public sealed class PrimitiveType
{
/// <summary>
/// Primitive type representation for SBE type CHAR
Expand Down
27 changes: 11 additions & 16 deletions csharp/sbe-dll/PrimitiveValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Org.SbeTool.Sbe.Dll
/// </tbody>
/// </table>
/// </summary>
public class PrimitiveValue
public sealed class PrimitiveValue
{
private enum Representation
{
Expand Down Expand Up @@ -485,26 +485,21 @@ public override string ToString()
/// <returns> equivalence of values </returns>
public override bool Equals(object value)
{
if (null != value && this.GetType().Equals(value.GetType()))
if (value is PrimitiveValue rhs && _representation == rhs._representation)
{
var rhs = (PrimitiveValue) value;

if (_representation == rhs._representation)
switch (_representation)
{
switch (_representation)
{
case Representation.Long:
return _longValue == rhs._longValue;
case Representation.Long:
return _longValue == rhs._longValue;

case Representation.ULong:
return _unsignedLongValue == rhs._unsignedLongValue;
case Representation.ULong:
return _unsignedLongValue == rhs._unsignedLongValue;

case Representation.Double:
return BitConverter.DoubleToInt64Bits(_doubleValue) == BitConverter.DoubleToInt64Bits(rhs._doubleValue);
case Representation.Double:
return BitConverter.DoubleToInt64Bits(_doubleValue) == BitConverter.DoubleToInt64Bits(rhs._doubleValue);

case Representation.ByteArray:
return _byteArrayValue.SequenceEqual(rhs._byteArrayValue);
}
case Representation.ByteArray:
return _byteArrayValue.SequenceEqual(rhs._byteArrayValue);
}
}

Expand Down
2 changes: 1 addition & 1 deletion csharp/sbe-dll/ThrowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Org.SbeTool.Sbe.Dll
/// Helper class that provides non-returning methods that throw common exception
/// from the generated C# code
/// </summary>
public class ThrowHelper
public static class ThrowHelper
{
/// <summary>
/// Throws a <see cref="ArgumentOutOfRangeException"/> when the "count" parameter is out of range
Expand Down
Loading