Skip to content

Commit 8a23719

Browse files
authored
Code fixes from Sonarcloud analysis (#17)
1 parent 1d93ec7 commit 8a23719

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

System.IO.Streams/MemoryStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ public class MemoryStream : Stream
1616
// Either allocated internally or externally.
1717
private byte[] _buffer;
1818
// For user-provided arrays, start at this origin
19-
private int _origin;
19+
private readonly int _origin;
2020
// read/write head.
2121
private int _position;
2222
// Number of bytes within the memory stream
2323
private int _length;
2424
// length of usable portion of buffer for stream
2525
private int _capacity;
2626
// User-provided buffers aren't expandable.
27-
private bool _expandable;
27+
private readonly bool _expandable;
2828
// Is this stream open or closed?
2929
private bool _isOpen;
3030

System.IO.Streams/StreamReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public override int Peek()
205205
/// </remarks>
206206
public override int Read()
207207
{
208-
int byteUsed, charUsed;
208+
int byteUsed;
209209

210210
while (true)
211211
{
@@ -218,7 +218,7 @@ public override int Read()
218218
1,
219219
false,
220220
out byteUsed,
221-
out charUsed,
221+
out System.Int32 charUsed,
222222
out _);
223223

224224
_curBufPos += byteUsed;

System.IO.Streams/StreamWriter.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,19 @@ protected override void Dispose(bool disposing)
9090
Flush();
9191
}
9292
}
93-
catch { }
93+
catch
94+
{
95+
// empty on purpose to catch any exceptions during call to Flush
96+
}
9497

9598
try
9699
{
97100
BaseStream.Close();
98101
}
99-
catch { }
102+
catch
103+
{
104+
// empty on purpose to catch any exceptions during call to Close
105+
}
100106
}
101107

102108
BaseStream = null;

System.IO.Streams/TextReader.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public virtual int ReadBlock(char[] buffer, int index, int count)
127127

128128
do
129129
{
130-
n += (i = Read(buffer, index + n, count - n));
130+
i = Read(buffer, index + n, count - n);
131+
n += i;
131132
} while (i > 0 && n < count);
132133

133134
return n;

System.IO.Streams/TextWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public virtual void Write(char[] buffer, int index, int count)
150150
/// <param name="value">The <see cref="bool"/> value to write.</param>
151151
public virtual void Write(bool value)
152152
{
153-
Write(value);
153+
Write(value.ToString());
154154
}
155155

156156
/// <summary>

0 commit comments

Comments
 (0)