From b23d976f9334f0bc2e59e4d61f047be65cc47500 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 22 Jul 2020 13:20:25 +0100 Subject: [PATCH] Code style fixes. --- ArrayIsEmpty.cs | 5 ++--- CountBits.cs | 4 ++-- DateHandlers.cs | 2 +- MarshallingPropertiesAttribute.cs | 2 +- StringHandlers.cs | 6 +++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ArrayIsEmpty.cs b/ArrayIsEmpty.cs index a51f900..d04586f 100644 --- a/ArrayIsEmpty.cs +++ b/ArrayIsEmpty.cs @@ -39,12 +39,11 @@ namespace Aaru.Helpers /// Checks if an array is null, filled with the NULL byte (0x00) or ASCII whitespace (0x20) /// Array /// True if null or whitespace - public static bool ArrayIsNullOrWhiteSpace(byte[] array) => - array == null || array.All(b => b == 0x00 || b == 0x20); + public static bool ArrayIsNullOrWhiteSpace(byte[] array) => array?.All(b => b == 0x00 || b == 0x20) != false; /// Checks if an array is null or filled with the NULL byte (0x00) /// Array /// True if null - public static bool ArrayIsNullOrEmpty(byte[] array) => array == null || array.All(b => b == 0x00); + public static bool ArrayIsNullOrEmpty(byte[] array) => array?.All(b => b == 0x00) != false; } } \ No newline at end of file diff --git a/CountBits.cs b/CountBits.cs index 60704df..54914f3 100644 --- a/CountBits.cs +++ b/CountBits.cs @@ -39,8 +39,8 @@ namespace Aaru.Helpers /// Bits set to true public static int Count(uint number) { - number = number - ((number >> 1) & 0x55555555); - number = (number & 0x33333333) + ((number >> 2) & 0x33333333); + number -= (number >> 1) & 0x55555555; + number = (number & 0x33333333) + ((number >> 2) & 0x33333333); return (int)((((number + (number >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24); } diff --git a/DateHandlers.cs b/DateHandlers.cs index 28fd153..6bca1e3 100644 --- a/DateHandlers.cs +++ b/DateHandlers.cs @@ -313,7 +313,7 @@ namespace Aaru.Helpers AddTicks(ticks).DateTime; } - /// Convers a Solaris high resolution timestamp to .NET DateTime + /// Converts a Solaris high resolution timestamp to .NET DateTime /// Solaris high resolution timestamp /// .NET DateTime public static DateTime UnixHrTimeToDateTime(ulong hrTimeStamp) => diff --git a/MarshallingPropertiesAttribute.cs b/MarshallingPropertiesAttribute.cs index 9544883..bb91ac3 100644 --- a/MarshallingPropertiesAttribute.cs +++ b/MarshallingPropertiesAttribute.cs @@ -42,7 +42,7 @@ namespace Aaru.Helpers { /// Defines properties to help marshalling structs from binary data [AttributeUsage(AttributeTargets.Struct)] - public class MarshallingPropertiesAttribute : Attribute + public sealed class MarshallingPropertiesAttribute : Attribute { /// Defines properties to help marshalling structs from binary data /// Defines properties to help marshalling structs from binary data diff --git a/StringHandlers.cs b/StringHandlers.cs index d2128cd..f99ecea 100644 --- a/StringHandlers.cs +++ b/StringHandlers.cs @@ -47,7 +47,7 @@ namespace Aaru.Helpers /// A null-terminated (aka C string) byte array in the specified encoding /// Encoding. /// Set if encoding uses 16-bit characters. - /// Start decodint at this position + /// Start decoding at this position public static string CToString(byte[] cString, Encoding encoding, bool twoBytes = false, int start = 0) { if(cString == null) @@ -92,7 +92,7 @@ namespace Aaru.Helpers /// The corresponding C# string /// A length-prefixed (aka Pascal string) ASCII byte array /// Encoding. - /// Start decodint at this position + /// Start decoding at this position public static string PascalToString(byte[] pascalString, Encoding encoding, int start = 0) { if(pascalString == null) @@ -125,7 +125,7 @@ namespace Aaru.Helpers /// The corresponding C# string /// A space (' ', 0x20, ASCII SPACE) padded ASCII byte array /// Encoding. - /// Start decodint at this position + /// Start decoding at this position public static string SpacePaddedToString(byte[] spacePaddedString, Encoding encoding, int start = 0) { if(spacePaddedString == null)