Skip to content

Commit

Permalink
Cosmetics
Browse files Browse the repository at this point in the history
replaced "" with string.Empty
replaced "integral value" with "numerical value"
  • Loading branch information
MrUnbelievable92 committed Dec 20, 2020
1 parent 521f67d commit d573829
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.3")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.4")]
4 changes: 2 additions & 2 deletions Assert.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if DEBUG
#if !DEBUG

#define CONDITION_CHECKS
#define NULL_CHECKS
Expand Down Expand Up @@ -282,7 +282,7 @@ public static void IsSafeBoolean(bool x)
#if COMPARE_CHECKS
if (*(byte*)&x > 1)
{
throw new InvalidDataException($"The integral value of the bool x is { *(byte*)&x } which can lead to undefined behavior.");
throw new InvalidDataException($"The numerical value of the bool { nameof(x) } is { *(byte*)&x } which can lead to undefined behavior.");
}
#endif
}
Expand Down
22 changes: 12 additions & 10 deletions Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ public static string Bits(sbyte value, bool spaces = true)

for (int i = 0; i < 8; i++)
{
result[i] = (char)((((uint)value >> 7 - i) & 1) + 48);
result[i] = (char)((((uint)value >> (7 - i)) & 1) + 48);
}

return spaces ? new string(result, 0, 8).Insert(4, " ") : new string(result, 0, 8);
}
public static string Bits(short value, bool spaces = true)
{
return Bits((sbyte)((uint)value >> 8), spaces) + (spaces ? " " : "") + Bits((sbyte)value, spaces);
return Bits((sbyte)((uint)value >> 8), spaces) + (spaces ? " " : string.Empty) + Bits((sbyte)value, spaces);
}
public static string Bits(int value, bool spaces = true)
{
return Bits((short)((uint)value >> 16), spaces) + (spaces ? " " : "") + Bits((short)value, spaces);
return Bits((short)((uint)value >> 16), spaces) + (spaces ? " " : string.Empty) + Bits((short)value, spaces);
}
public static string Bits(long value, bool spaces = true)
{
return Bits((uint)((ulong)value >> 32), spaces) + (spaces ? " " : "") + Bits((uint)value, spaces);
return Bits((uint)((ulong)value >> 32), spaces) + (spaces ? " " : string.Empty) + Bits((uint)value, spaces);
}

public static string Bits(byte value, bool spaces = true) => Bits((sbyte)value, spaces);
Expand All @@ -44,7 +44,7 @@ public static string Bits<T>(T value, bool spaces = true)

while (sizeInBytes != 0)
{
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : ""));
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : string.Empty));

address++;
sizeInBytes--;
Expand All @@ -55,13 +55,14 @@ public static string Bits<T>(T value, bool spaces = true)
public static string Bits(void* ptr, int bytes, bool spaces = true)
{
Assert.IsNotNull(ptr);
Assert.IsGreater(bytes, -1);

byte* address = (byte*)ptr;
string result = string.Empty;

while (bytes != 0)
{
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : ""));
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : string.Empty));

address++;
bytes--;
Expand All @@ -81,11 +82,11 @@ public static string Hex(short value)
}
public static string Hex(int value, bool spaces = true)
{
return Hex((ushort)((uint)value >> 16)) + (spaces ? " " : "") + Hex((ushort)(value & ushort.MaxValue));
return Hex((ushort)((uint)value >> 16)) + (spaces ? " " : string.Empty) + Hex((ushort)(value & ushort.MaxValue));
}
public static string Hex(long value, bool spaces = true)
{
return Hex((uint)((ulong)value >> 32), spaces) + (spaces ? " " : "") + Hex((uint)(value & uint.MaxValue), spaces);
return Hex((uint)((ulong)value >> 32), spaces) + (spaces ? " " : string.Empty) + Hex((uint)(value & uint.MaxValue), spaces);
}

public static string Hex(byte value) => Hex((sbyte)value);
Expand All @@ -103,7 +104,7 @@ public static string Hex<T>(T value, bool spaces = true)

while (iterations != sizeof(T))
{
result = result.Insert(0, Hex(*address) + ((spaces && (iterations != 0) && (iterations % 2 == 0)) ? " " : ""));
result = result.Insert(0, Hex(*address) + ((spaces && (iterations != 0) && (iterations % 2 == 0)) ? " " : string.Empty));

address++;
iterations++;
Expand All @@ -114,14 +115,15 @@ public static string Hex<T>(T value, bool spaces = true)
public static string Hex(void* ptr, int bytes, bool spaces = true)
{
Assert.IsNotNull(ptr);
Assert.IsGreater(bytes, -1);

byte* address = (byte*)ptr;
int iterations = 0;
string result = string.Empty;

while (iterations != bytes)
{
result = result.Insert(0, Hex(*address) + ((spaces && (iterations != 0) && (iterations % 2 == 0)) ? " " : ""));
result = result.Insert(0, Hex(*address) + ((spaces && (iterations != 0) && (iterations % 2 == 0)) ? " " : string.Empty));

address++;
iterations++;
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "devtools",
"name": "MRU.devtools",
"displayName": "DevTools",
"version": "1.0.3",
"version": "1.0.4",
"unity": "2018.4",
"description": "DevTools is a small framework for defensive programming with assertions and logging tools.",
"description": "DevTools is a small framework for defensive development with assertions and logging tools.",
"keywords": [
"Unity"
],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "devtools",
"name": "MRU.devtools",
"displayName": "DevTools",
"version": "1.0.3",
"version": "1.0.4",
"unity": "2018.4",
"description": "DevTools is a small framework for defensive programming with assertions and logging tools.",
"description": "DevTools is a small framework for defensive development with assertions and logging tools.",
"keywords": [
"Unity"
],
Expand Down

0 comments on commit d573829

Please sign in to comment.