• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JaCraig / Mecha / 18535468418

15 Oct 2025 04:16PM UTC coverage: 81.963% (-0.2%) from 82.119%
18535468418

push

github

web-flow
Merge pull request #358 from JaCraig/dependabot/nuget/Mecha.Core/dependencies-598abd322d

fix: Bump the dependencies group with 2 updates

755 of 1060 branches covered (71.23%)

Branch coverage included in aggregate %.

1349 of 1507 relevant lines covered (89.52%)

7880769.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/Mecha.Core/Generator/Helpers/EmptyStream.cs
1
using System;
2
using System.IO;
3
using System.Threading;
4
using System.Threading.Tasks;
5

6
namespace Mecha.Core.Generator.Helpers
7
{
8
    /// <summary>
9
    /// Empty stream (does nothing)
10
    /// </summary>
11
    /// <seealso cref="Stream"/>
12
    public class EmptyStream : Stream
13
    {
14
        /// <summary>
15
        /// Initializes a new instance of the <see cref="EmptyStream"/> class.
16
        /// </summary>
17
        public EmptyStream()
7✔
18
        {
19
        }
7✔
20

21
        /// <summary>
22
        /// When overridden in a derived class, gets a value indicating whether the current stream
23
        /// supports reading.
24
        /// </summary>
25
        public override bool CanRead => true;
1,316✔
26

27
        /// <summary>
28
        /// When overridden in a derived class, gets a value indicating whether the current stream
29
        /// supports seeking.
30
        /// </summary>
31
        public override bool CanSeek => true;
1,316✔
32

33
        /// <summary>
34
        /// Gets a value that determines whether the current stream can time out.
35
        /// </summary>
36
        public override bool CanTimeout => true;
1,316✔
37

38
        /// <summary>
39
        /// When overridden in a derived class, gets a value indicating whether the current stream
40
        /// supports writing.
41
        /// </summary>
42
        public override bool CanWrite => true;
1,316✔
43

44
        /// <summary>
45
        /// When overridden in a derived class, gets the length in bytes of the stream.
46
        /// </summary>
47
        public override long Length => 10000;
1,316✔
48

49
        /// <summary>
50
        /// When overridden in a derived class, gets or sets the position within the current stream.
51
        /// </summary>
52
        public override long Position { get; set; }
1,318✔
53

54
        /// <summary>
55
        /// Gets or sets a value, in milliseconds, that determines how long the stream will attempt
56
        /// to read before timing out.
57
        /// </summary>
58
        public override int ReadTimeout { get; set; }
1,318✔
59

60
        /// <summary>
61
        /// Gets or sets a value, in milliseconds, that determines how long the stream will attempt
62
        /// to write before timing out.
63
        /// </summary>
64
        public override int WriteTimeout { get; set; }
1,318✔
65

66
        /// <summary>
67
        /// Begins an asynchronous read operation. (Consider using <see
68
        /// cref="M:System.IO.Stream.ReadAsync(System.Byte[],System.Int32,System.Int32)"/> instead.)
69
        /// </summary>
70
        /// <param name="buffer">The buffer to read the data into.</param>
71
        /// <param name="offset">
72
        /// The byte offset in <paramref name="buffer"/> at which to begin writing data read from
73
        /// the stream.
74
        /// </param>
75
        /// <param name="count">The maximum number of bytes to read.</param>
76
        /// <param name="callback">
77
        /// An optional asynchronous callback, to be called when the read is complete.
78
        /// </param>
79
        /// <param name="state">
80
        /// A user-provided object that distinguishes this particular asynchronous read request from
81
        /// other requests.
82
        /// </param>
83
        /// <returns>
84
        /// An <see cref="T:System.IAsyncResult"/> that represents the asynchronous read, which
85
        /// could still be pending.
86
        /// </returns>
87
        public override IAsyncResult? BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => null;
2✔
88

89
        /// <summary>
90
        /// Begins an asynchronous write operation. (Consider using <see
91
        /// cref="M:System.IO.Stream.WriteAsync(System.Byte[],System.Int32,System.Int32)"/> instead.)
92
        /// </summary>
93
        /// <param name="buffer">The buffer to write data from.</param>
94
        /// <param name="offset">
95
        /// The byte offset in <paramref name="buffer"/> from which to begin writing.
96
        /// </param>
97
        /// <param name="count">The maximum number of bytes to write.</param>
98
        /// <param name="callback">
99
        /// An optional asynchronous callback, to be called when the write is complete.
100
        /// </param>
101
        /// <param name="state">
102
        /// A user-provided object that distinguishes this particular asynchronous write request
103
        /// from other requests.
104
        /// </param>
105
        /// <returns>
106
        /// An <see langword="IAsyncResult"/> that represents the asynchronous write, which could
107
        /// still be pending.
108
        /// </returns>
109
        public override IAsyncResult? BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => null;
2✔
110

111
        /// <summary>
112
        /// Closes the current stream and releases any resources (such as sockets and file handles)
113
        /// associated with the current stream. Instead of calling this method, ensure that the
114
        /// stream is properly disposed.
115
        /// </summary>
116
        public override void Close()
117
        {
118
        }
2✔
119

120
        /// <summary>
121
        /// Reads the bytes from the current stream and writes them to another stream, using a
122
        /// specified buffer size.
123
        /// </summary>
124
        /// <param name="destination">
125
        /// The stream to which the contents of the current stream will be copied.
126
        /// </param>
127
        /// <param name="bufferSize">
128
        /// The size of the buffer. This value must be greater than zero. The default size is 81920.
129
        /// </param>
130
        public override void CopyTo(Stream destination, int bufferSize)
131
        {
132
        }
2✔
133

134
        /// <summary>
135
        /// Asynchronously reads the bytes from the current stream and writes them to another
136
        /// stream, using a specified buffer size and cancellation token.
137
        /// </summary>
138
        /// <param name="destination">
139
        /// The stream to which the contents of the current stream will be copied.
140
        /// </param>
141
        /// <param name="bufferSize">
142
        /// The size, in bytes, of the buffer. This value must be greater than zero. The default
143
        /// size is 81920.
144
        /// </param>
145
        /// <param name="cancellationToken">
146
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
147
        /// </param>
148
        /// <returns>A task that represents the asynchronous copy operation.</returns>
149
        public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) => Task.CompletedTask;
220✔
150

151
        /// <summary>
152
        /// Waits for the pending asynchronous read to complete. (Consider using <see
153
        /// cref="M:System.IO.Stream.ReadAsync(System.Byte[],System.Int32,System.Int32)"/> instead.)
154
        /// </summary>
155
        /// <param name="asyncResult">The reference to the pending asynchronous request to finish.</param>
156
        /// <returns>
157
        /// The number of bytes read from the stream, between zero (0) and the number of bytes you
158
        /// requested. Streams return zero (0) only at the end of the stream, otherwise, they should
159
        /// block until at least one byte is available.
160
        /// </returns>
161
        public override int EndRead(IAsyncResult asyncResult) => 0;
2✔
162

163
        /// <summary>
164
        /// Ends an asynchronous write operation. (Consider using <see
165
        /// cref="M:System.IO.Stream.WriteAsync(System.Byte[],System.Int32,System.Int32)"/> instead.)
166
        /// </summary>
167
        /// <param name="asyncResult">A reference to the outstanding asynchronous I/O request.</param>
168
        public override void EndWrite(IAsyncResult asyncResult)
169
        {
170
        }
2✔
171

172
        /// <summary>
173
        /// When overridden in a derived class, clears all buffers for this stream and causes any
174
        /// buffered data to be written to the underlying device.
175
        /// </summary>
176
        public override void Flush()
177
        {
178
        }
2✔
179

180
        /// <summary>
181
        /// Asynchronously clears all buffers for this stream, causes any buffered data to be
182
        /// written to the underlying device, and monitors cancellation requests.
183
        /// </summary>
184
        /// <param name="cancellationToken">
185
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
186
        /// </param>
187
        /// <returns>A task that represents the asynchronous flush operation.</returns>
188
        public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
220✔
189

190
        /// <summary>
191
        /// Obtains a lifetime service object to control the lifetime policy for this instance.
192
        /// </summary>
193
        /// <returns>
194
        /// An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease"/> used to
195
        /// control the lifetime policy for this instance. This is the current lifetime service
196
        /// object for this instance if one exists; otherwise, a new lifetime service object
197
        /// initialized to the value of the <see
198
        /// cref="P:System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime"/> property.
199
        /// </returns>
200
        [Obsolete("This Remoting API is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0010", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
201
        public override object? InitializeLifetimeService() => null;
2✔
202

203
        /// <summary>
204
        /// When overridden in a derived class, reads a sequence of bytes from the current stream
205
        /// and advances the position within the stream by the number of bytes read.
206
        /// </summary>
207
        /// <param name="buffer">
208
        /// An array of bytes. When this method returns, the buffer contains the specified byte
209
        /// array with the values between <paramref name="offset"/> and ( <paramref name="offset"/>
210
        /// + <paramref name="count"/> - 1) replaced by the bytes read from the current source.
211
        /// </param>
212
        /// <param name="offset">
213
        /// The zero-based byte offset in <paramref name="buffer"/> at which to begin storing the
214
        /// data read from the current stream.
215
        /// </param>
216
        /// <param name="count">The maximum number of bytes to be read from the current stream.</param>
217
        /// <returns>
218
        /// The total number of bytes read into the buffer. This can be less than the number of
219
        /// bytes requested if that many bytes are not currently available, or zero (0) if the end
220
        /// of the stream has been reached.
221
        /// </returns>
222
        /// <exception cref="EndOfStreamException"></exception>
223
        public override int Read(byte[] buffer, int offset, int count)
224
        {
225
            if (offset < 0)
2!
226
                offset = 0;
×
227
            if (count < 0)
2!
228
                count = 0;
×
229
            if (buffer is null || buffer.Length < offset + count || offset > buffer.Length)
2!
230
                return 0;
2✔
231
            Array.Fill<byte>(buffer, 0, offset, count);
×
232
            return count;
×
233
        }
234

235
        /// <summary>
236
        /// When overridden in a derived class, reads a sequence of bytes from the current stream
237
        /// and advances the position within the stream by the number of bytes read.
238
        /// </summary>
239
        /// <param name="buffer">
240
        /// A region of memory. When this method returns, the contents of this region are replaced
241
        /// by the bytes read from the current source.
242
        /// </param>
243
        /// <returns>
244
        /// The total number of bytes read into the buffer. This can be less than the number of
245
        /// bytes allocated in the buffer if that many bytes are not currently available, or zero
246
        /// (0) if the end of the stream has been reached.
247
        /// </returns>
248
        public override int Read(Span<byte> buffer) => 0;
2✔
249

250
        /// <summary>
251
        /// Asynchronously reads a sequence of bytes from the current stream, advances the position
252
        /// within the stream by the number of bytes read, and monitors cancellation requests.
253
        /// </summary>
254
        /// <param name="buffer">The region of memory to write the data into.</param>
255
        /// <param name="cancellationToken">
256
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
257
        /// </param>
258
        /// <returns>
259
        /// A task that represents the asynchronous read operation. The value of its <see
260
        /// cref="P:System.Threading.Tasks.ValueTask`1.Result"/> property contains the total number
261
        /// of bytes read into the buffer. The result value can be less than the number of bytes
262
        /// allocated in the buffer if that many bytes are not currently available, or it can be 0
263
        /// (zero) if the end of the stream has been reached.
264
        /// </returns>
265
        public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default) => new(0);
220✔
266

267
        /// <summary>
268
        /// Asynchronously reads a sequence of bytes from the current stream, advances the position
269
        /// within the stream by the number of bytes read, and monitors cancellation requests.
270
        /// </summary>
271
        /// <param name="buffer">The buffer to write the data into.</param>
272
        /// <param name="offset">
273
        /// The byte offset in <paramref name="buffer"/> at which to begin writing data from the stream.
274
        /// </param>
275
        /// <param name="count">The maximum number of bytes to read.</param>
276
        /// <param name="cancellationToken">
277
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
278
        /// </param>
279
        /// <returns>
280
        /// A task that represents the asynchronous read operation. The value of the parameter
281
        /// contains the total number of bytes read into the buffer. The result value can be less
282
        /// than the number of bytes requested if the number of bytes currently available is less
283
        /// than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
284
        /// </returns>
285
        public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => Task.FromResult(0);
220✔
286

287
        /// <summary>
288
        /// Reads a byte from the stream and advances the position within the stream by one byte, or
289
        /// returns -1 if at the end of the stream.
290
        /// </summary>
291
        /// <returns>
292
        /// The unsigned byte cast to an <see langword="Int32"/>, or -1 if at the end of the stream.
293
        /// </returns>
294
        public override int ReadByte() => 0;
2✔
295

296
        /// <summary>
297
        /// When overridden in a derived class, sets the position within the current stream.
298
        /// </summary>
299
        /// <param name="offset">A byte offset relative to the <paramref name="origin"/> parameter.</param>
300
        /// <param name="origin">
301
        /// A value of type <see cref="T:System.IO.SeekOrigin"/> indicating the reference point used
302
        /// to obtain the new position.
303
        /// </param>
304
        /// <returns>The new position within the current stream.</returns>
305
        /// <exception cref="EndOfStreamException"></exception>
306
        public override long Seek(long offset, SeekOrigin origin) => offset;
2✔
307

308
        /// <summary>
309
        /// When overridden in a derived class, sets the length of the current stream.
310
        /// </summary>
311
        /// <param name="value">The desired length of the current stream in bytes.</param>
312
        public override void SetLength(long value)
313
        {
314
        }
2✔
315

316
        /// <summary>
317
        /// When overridden in a derived class, writes a sequence of bytes to the current stream and
318
        /// advances the current position within this stream by the number of bytes written.
319
        /// </summary>
320
        /// <param name="buffer">
321
        /// An array of bytes. This method copies <paramref name="count"/> bytes from <paramref
322
        /// name="buffer"/> to the current stream.
323
        /// </param>
324
        /// <param name="offset">
325
        /// The zero-based byte offset in <paramref name="buffer"/> at which to begin copying bytes
326
        /// to the current stream.
327
        /// </param>
328
        /// <param name="count">The number of bytes to be written to the current stream.</param>
329
        public override void Write(byte[] buffer, int offset, int count)
330
        {
331
        }
2✔
332

333
        /// <summary>
334
        /// When overridden in a derived class, writes a sequence of bytes to the current stream and
335
        /// advances the current position within this stream by the number of bytes written.
336
        /// </summary>
337
        /// <param name="buffer">
338
        /// A region of memory. This method copies the contents of this region to the current stream.
339
        /// </param>
340
        public override void Write(ReadOnlySpan<byte> buffer)
341
        {
342
        }
2✔
343

344
        /// <summary>
345
        /// Asynchronously writes a sequence of bytes to the current stream, advances the current
346
        /// position within this stream by the number of bytes written, and monitors cancellation requests.
347
        /// </summary>
348
        /// <param name="buffer">The region of memory to write data from.</param>
349
        /// <param name="cancellationToken">
350
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
351
        /// </param>
352
        /// <returns>A task that represents the asynchronous write operation.</returns>
353
        public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) => new();
220✔
354

355
        /// <summary>
356
        /// Asynchronously writes a sequence of bytes to the current stream, advances the current
357
        /// position within this stream by the number of bytes written, and monitors cancellation requests.
358
        /// </summary>
359
        /// <param name="buffer">The buffer to write data from.</param>
360
        /// <param name="offset">
361
        /// The zero-based byte offset in <paramref name="buffer"/> from which to begin copying
362
        /// bytes to the stream.
363
        /// </param>
364
        /// <param name="count">The maximum number of bytes to write.</param>
365
        /// <param name="cancellationToken">
366
        /// The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None"/>.
367
        /// </param>
368
        /// <returns>A task that represents the asynchronous write operation.</returns>
369
        public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => Task.CompletedTask;
220✔
370

371
        /// <summary>
372
        /// Writes a byte to the current position in the stream and advances the position within the
373
        /// stream by one byte.
374
        /// </summary>
375
        /// <param name="value">The byte to write to the stream.</param>
376
        public override void WriteByte(byte value)
377
        {
378
        }
2✔
379

380
        /// <summary>
381
        /// Allocates a <see cref="T:System.Threading.WaitHandle"/> object.
382
        /// </summary>
383
        /// <returns>A reference to the allocated <see langword="WaitHandle"/>.</returns>
384
        [Obsolete("Reasons")]
385
        protected override WaitHandle? CreateWaitHandle() => null;
×
386
    }
387
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc