Skip to content

Commit 87f7bc6

Browse files
committed
Code style fixes
1 parent 4a5ab03 commit 87f7bc6

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Tests/NFUnitTestTypes/UnitTestsSpanByte.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void RaisingExceptionsOfAllKindsTests()
4545
Assert.ThrowsException(typeof(IndexOutOfRangeException), () =>
4646
{
4747
Span<byte> span = new Span<byte>(array);
48-
var data = span[-1];
48+
_ = span[-1];
4949
});
5050

5151
// Copy to with too small destination
@@ -100,27 +100,32 @@ public void ConstructorsOfAllKindsTests()
100100
{
101101
// Empty span
102102
Span<byte> span = new Span<byte>();
103+
103104
Assert.AreEqual(span.Length, 0, "Empty SpanByte should have length of 0");
104105
Assert.IsTrue(span.IsEmpty, "Empty SpanByte should be IsEmpty");
105106

106107
// Empty span
107108
span = new Span<byte>(null, 0, 0);
109+
108110
Assert.AreEqual(span.Length, 0, "Empty SpanByte should have length of 0");
109111
Assert.IsTrue(span.IsEmpty, "Empty SpanByte should be IsEmpty");
110112

111113
// Empty span
112114
span = Span<byte>.Empty;
115+
113116
Assert.AreEqual(span.Length, 0, "Empty SpanByte should have length of 0");
114117
Assert.IsTrue(span.IsEmpty, "Empty SpanByte should be IsEmpty");
115118

116119
// Span<byte>from normal array
117120
byte[] array = new byte[16] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
118121
span = new Span<byte>(array);
122+
119123
Assert.AreEqual(span.Length, array.Length, $"SpanByte should have length of the array it takes: {array.Length}");
120124
Assert.IsFalse(span.IsEmpty, "SpanByte should NOT be IsEmpty");
121125

122126
// Span<byte>from normal array with different start and length
123127
span = new Span<byte>(array, 2, 8);
128+
124129
Assert.AreEqual(span.Length, 8, $"SpanByte should have length of 8");
125130
Assert.IsFalse(span.IsEmpty, "SpanByte should NOT be IsEmpty");
126131
}
@@ -131,14 +136,17 @@ public void SliceTests()
131136
// Span<byte>from normal array
132137
byte[] array = new byte[16] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
133138
Span<byte> span = new Span<byte>(array);
139+
134140
// Slice 2 elements and check
135-
var sliced = span.Slice(0, 2);
141+
Span<byte> sliced = span.Slice(0, 2);
142+
136143
Assert.AreEqual(sliced.Length, 2, "Sliced span lenght must be 2");
137144
Assert.AreEqual(sliced[0], (byte)0x00, "Sliced first element must be value 0");
138145
Assert.AreEqual(sliced[1], (byte)0x01, "Sliced first element must be value 1");
139146

140147
// Slide 4 elements starting at index 2 and check
141148
sliced = span.Slice(2, 4);
149+
142150
Assert.AreEqual(sliced.Length, 4, "Sliced span lenght must be 4");
143151
Assert.AreEqual(sliced[0], (byte)0x02, "Sliced first element must be value 2");
144152
Assert.AreEqual(sliced[1], (byte)0x03, "Sliced first element must be value 3");
@@ -147,22 +155,27 @@ public void SliceTests()
147155

148156
// Slide starting 4 at element check
149157
sliced = span.Slice(4);
158+
150159
Assert.AreEqual(sliced.Length, 12, "Sliced span lenght must be 12");
160+
151161
for (int i = 0; i < sliced.Length; i++)
152162
{
153163
Assert.AreEqual(sliced[i], span[i + 4], "SpanByte value should be the same as from the original span");
154164
}
155165

156166
// Slice of slice
157-
var secondSliced = sliced.Slice(2, 4);
167+
Span<byte> secondSliced = sliced.Slice(2, 4);
168+
158169
Assert.AreEqual(secondSliced.Length, 4, "Sliced span lenght must be 12");
170+
159171
for (int i = 0; i < secondSliced.Length; i++)
160172
{
161173
Assert.AreEqual(secondSliced[i], sliced[i + 2], "SpanByte value should be the same as from the original span");
162174
}
163175

164176
// Should be an empty one
165-
var empty = span.Slice(span.Length);
177+
Span<byte> empty = span.Slice(span.Length);
178+
166179
Assert.AreEqual(empty.Length, 0, "slicing all the span should result in an empty span");
167180
Assert.IsTrue(empty.IsEmpty, "Empty span should be empty");
168181
}
@@ -213,10 +226,12 @@ public void SetElementsTests()
213226
{
214227
// Create a span, and set the data
215228
Span<byte> span = new Span<byte>(new byte[12]);
229+
216230
// All should be 0
217231
for (int i = 0; i < span.Length; i++)
218232
{
219233
Assert.AreEqual(span[i], (byte)0, "SpanByte value should be 0");
234+
220235
// Set a value
221236
span[i] = (byte)i;
222237
}

nanoFramework.CoreLibrary/System/ReadOnlySpan.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ public ReadOnlySpan(T[]? array, int start, int length)
7777
throw new ArgumentOutOfRangeException();
7878
}
7979

80-
NativeReadOnlySpanConstructor(array, start, length);
80+
NativeReadOnlySpanConstructor(
81+
array,
82+
start,
83+
length);
8184
}
8285

8386
/// <summary>

nanoFramework.CoreLibrary/System/Span.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ public Span(
100100
throw new ArgumentOutOfRangeException();
101101
}
102102

103-
NativeSpanConstructor(array, start, length);
103+
NativeSpanConstructor(
104+
array,
105+
start,
106+
length);
104107
}
105108

106109
/// <summary>

0 commit comments

Comments
 (0)