Skip to content

Commit d573829

Browse files
Cosmetics
replaced "" with string.Empty replaced "integral value" with "numerical value"
1 parent 521f67d commit d573829

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
// Build Number
2929
// Revision
3030
//
31-
[assembly: AssemblyVersion("1.0.3")]
32-
[assembly: AssemblyFileVersion("1.0.3")]
31+
[assembly: AssemblyVersion("1.0.4")]
32+
[assembly: AssemblyFileVersion("1.0.4")]

Assert.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if DEBUG
1+
#if !DEBUG
22

33
#define CONDITION_CHECKS
44
#define NULL_CHECKS
@@ -282,7 +282,7 @@ public static void IsSafeBoolean(bool x)
282282
#if COMPARE_CHECKS
283283
if (*(byte*)&x > 1)
284284
{
285-
throw new InvalidDataException($"The integral value of the bool x is { *(byte*)&x } which can lead to undefined behavior.");
285+
throw new InvalidDataException($"The numerical value of the bool { nameof(x) } is { *(byte*)&x } which can lead to undefined behavior.");
286286
}
287287
#endif
288288
}

Log.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ public static string Bits(sbyte value, bool spaces = true)
1111

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

1717
return spaces ? new string(result, 0, 8).Insert(4, " ") : new string(result, 0, 8);
1818
}
1919
public static string Bits(short value, bool spaces = true)
2020
{
21-
return Bits((sbyte)((uint)value >> 8), spaces) + (spaces ? " " : "") + Bits((sbyte)value, spaces);
21+
return Bits((sbyte)((uint)value >> 8), spaces) + (spaces ? " " : string.Empty) + Bits((sbyte)value, spaces);
2222
}
2323
public static string Bits(int value, bool spaces = true)
2424
{
25-
return Bits((short)((uint)value >> 16), spaces) + (spaces ? " " : "") + Bits((short)value, spaces);
25+
return Bits((short)((uint)value >> 16), spaces) + (spaces ? " " : string.Empty) + Bits((short)value, spaces);
2626
}
2727
public static string Bits(long value, bool spaces = true)
2828
{
29-
return Bits((uint)((ulong)value >> 32), spaces) + (spaces ? " " : "") + Bits((uint)value, spaces);
29+
return Bits((uint)((ulong)value >> 32), spaces) + (spaces ? " " : string.Empty) + Bits((uint)value, spaces);
3030
}
3131

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

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

4949
address++;
5050
sizeInBytes--;
@@ -55,13 +55,14 @@ public static string Bits<T>(T value, bool spaces = true)
5555
public static string Bits(void* ptr, int bytes, bool spaces = true)
5656
{
5757
Assert.IsNotNull(ptr);
58+
Assert.IsGreater(bytes, -1);
5859

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

6263
while (bytes != 0)
6364
{
64-
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : ""));
65+
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : string.Empty));
6566

6667
address++;
6768
bytes--;
@@ -81,11 +82,11 @@ public static string Hex(short value)
8182
}
8283
public static string Hex(int value, bool spaces = true)
8384
{
84-
return Hex((ushort)((uint)value >> 16)) + (spaces ? " " : "") + Hex((ushort)(value & ushort.MaxValue));
85+
return Hex((ushort)((uint)value >> 16)) + (spaces ? " " : string.Empty) + Hex((ushort)(value & ushort.MaxValue));
8586
}
8687
public static string Hex(long value, bool spaces = true)
8788
{
88-
return Hex((uint)((ulong)value >> 32), spaces) + (spaces ? " " : "") + Hex((uint)(value & uint.MaxValue), spaces);
89+
return Hex((uint)((ulong)value >> 32), spaces) + (spaces ? " " : string.Empty) + Hex((uint)(value & uint.MaxValue), spaces);
8990
}
9091

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

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

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

118120
byte* address = (byte*)ptr;
119121
int iterations = 0;
120122
string result = string.Empty;
121123

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

126128
address++;
127129
iterations++;

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "devtools",
2+
"name": "MRU.devtools",
33
"displayName": "DevTools",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"unity": "2018.4",
6-
"description": "DevTools is a small framework for defensive programming with assertions and logging tools.",
6+
"description": "DevTools is a small framework for defensive development with assertions and logging tools.",
77
"keywords": [
88
"Unity"
99
],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "devtools",
2+
"name": "MRU.devtools",
33
"displayName": "DevTools",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"unity": "2018.4",
6-
"description": "DevTools is a small framework for defensive programming with assertions and logging tools.",
6+
"description": "DevTools is a small framework for defensive development with assertions and logging tools.",
77
"keywords": [
88
"Unity"
99
],

0 commit comments

Comments
 (0)