diff --git a/csharp/sbe-dll/PrimitiveType.cs b/csharp/sbe-dll/PrimitiveType.cs index d0d183eabc..3e54de6d54 100644 --- a/csharp/sbe-dll/PrimitiveType.cs +++ b/csharp/sbe-dll/PrimitiveType.cs @@ -71,7 +71,7 @@ /// /// /// - public class PrimitiveType + public sealed class PrimitiveType { /// /// Primitive type representation for SBE type CHAR diff --git a/csharp/sbe-dll/PrimitiveValue.cs b/csharp/sbe-dll/PrimitiveValue.cs index a579baa158..39be34975c 100644 --- a/csharp/sbe-dll/PrimitiveValue.cs +++ b/csharp/sbe-dll/PrimitiveValue.cs @@ -74,7 +74,7 @@ namespace Org.SbeTool.Sbe.Dll /// /// /// - public class PrimitiveValue + public sealed class PrimitiveValue { private enum Representation { @@ -485,26 +485,21 @@ public override string ToString() /// equivalence of values 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); } } diff --git a/csharp/sbe-dll/ThrowHelper.cs b/csharp/sbe-dll/ThrowHelper.cs index 30ca008c9c..9c1ffe4630 100644 --- a/csharp/sbe-dll/ThrowHelper.cs +++ b/csharp/sbe-dll/ThrowHelper.cs @@ -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 /// - public class ThrowHelper + public static class ThrowHelper { /// /// Throws a when the "count" parameter is out of range