Skip to content

Commit efb2ec1

Browse files
committed
Move unused code to Unused internal namespace
1 parent 3db69d6 commit efb2ec1

File tree

8 files changed

+50
-41
lines changed

8 files changed

+50
-41
lines changed

src/Imageflow/Fluent/BufferedStreamSource.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Imageflow.Fluent;
66

77
public sealed class BufferedStreamSource : IAsyncMemorySource, IMemorySource
88
{
9-
private BufferedStreamSource(Stream stream, bool disposeUnderlying, bool seekToStart = true)
9+
private BufferedStreamSource(Stream stream, bool disposeUnderlying, bool seekToStart)
1010
{
1111
if (stream.Position != 0 && !stream.CanSeek && seekToStart)
1212
{
@@ -129,7 +129,7 @@ public static IAsyncMemorySource BorrowEntireStream(Stream stream)
129129
}
130130
/// <summary>
131131
/// <strong>You remain responsible for disposing and cleaning up the stream after the job is disposed.</strong>
132-
/// Only reads from the current position to the end of the image file.
132+
/// Only reads from the current position to the end of the image file.
133133
/// You swear not to close, dispose, or reuse the stream or its underlying memory/stream until after this wrapper and the job are disposed.
134134
/// </summary>
135135
/// <param name="stream"></param>
@@ -154,8 +154,8 @@ public static IAsyncMemorySource UseEntireStreamAndDisposeWithSource(Stream stre
154154

155155
/// <summary>
156156
/// The stream will be closed and disposed with the BufferedStreamSource.
157-
/// <strong>You must not close, dispose, or reuse the stream or its underlying streams/buffers until after the job and the owning objects are disposed.</strong>
158-
/// strong>The BufferedStreamSource will still need to be disposed after the job, either with a using declaration or by transferring ownership of it to the job (which should be in a using declaration).</strong>
157+
/// <remarks>You must not close, dispose, or reuse the stream or its underlying streams/buffers until after the job and the owning objects are disposed.
158+
/// The BufferedStreamSource will still need to be disposed after the job, either with a using declaration or by transferring ownership of it to the job (which should be in a using declaration).</remarks>
159159
/// </summary>
160160
/// <param name="stream"></param>
161161
/// <returns></returns>

src/Imageflow/Fluent/ImageJob.cs

+1-34
Original file line numberDiff line numberDiff line change
@@ -300,40 +300,6 @@ internal async Task<BuildJobResult> FinishAsync(JobExecutionOptions executionOpt
300300
}
301301
}
302302

303-
#pragma warning disable CS0618 // Type or member is obsolete
304-
private class StreamJsonSpanProvider : IJsonResponseProvider, IJsonResponseSpanProvider, IJsonResponse
305-
#pragma warning restore CS0618 // Type or member is obsolete
306-
{
307-
private readonly MemoryStream _ms;
308-
309-
public StreamJsonSpanProvider(int statusCode, MemoryStream ms)
310-
{
311-
ImageflowErrorCode = statusCode;
312-
_ms = ms;
313-
}
314-
public void Dispose() => _ms.Dispose();
315-
public Stream GetStream() => _ms;
316-
public ReadOnlySpan<byte> BorrowBytes()
317-
{
318-
return _ms.TryGetBufferSliceAllWrittenData(out var slice) ? slice : _ms.ToArray();
319-
}
320-
321-
public int ImageflowErrorCode { get; }
322-
public string CopyString()
323-
{
324-
return BorrowBytes().Utf8ToString();
325-
}
326-
327-
public JsonNode? Parse()
328-
{
329-
return BorrowBytes().ParseJsonNode();
330-
}
331-
332-
public byte[] CopyBytes()
333-
{
334-
return BorrowBytes().ToArray();
335-
}
336-
}
337303

338304
// private object BuildJsonWithPlaceholders()
339305
// {
@@ -803,3 +769,4 @@ public static bool CanDecodeBytes(byte[] first12Bytes)
803769
return MagicBytes.GetImageContentType(first12Bytes);
804770
}
805771
}
772+

src/Imageflow/Internal.Helpers/StreamMemoryExtensionsPolyfills.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#if !NETSTANDARD2_1_OR_GREATER
12
using System.Buffers;
23
using System.Runtime.InteropServices;
4+
#endif
35

46
namespace Imageflow.Internal.Helpers;
57

src/Imageflow/Internal.Helpers/PinBox.cs renamed to src/Imageflow/Internal.Helpers/Unused/PinBox.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Runtime.ConstrainedExecution;
22
using System.Runtime.InteropServices;
33

4-
namespace Imageflow.Internal.Helpers;
4+
namespace Imageflow.Internal.Helpers.Unused;
55

66
internal class PinBox : CriticalFinalizerObject, IDisposable
77
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Text.Json.Nodes;
2+
using Imageflow.Bindings;
3+
4+
namespace Imageflow.Internal.Helpers.Unused;
5+
6+
#pragma warning disable CS0618
7+
internal class StreamJsonSpanProvider : IJsonResponseProvider, IJsonResponseSpanProvider, IJsonResponse
8+
#pragma warning restore CS0618 // Type or member is obsolete
9+
{
10+
private readonly MemoryStream _ms;
11+
12+
public StreamJsonSpanProvider(int statusCode, MemoryStream ms)
13+
{
14+
ImageflowErrorCode = statusCode;
15+
_ms = ms;
16+
}
17+
public void Dispose() => _ms.Dispose();
18+
public Stream GetStream() => _ms;
19+
public ReadOnlySpan<byte> BorrowBytes()
20+
{
21+
return _ms.TryGetBufferSliceAllWrittenData(out var slice) ? slice : _ms.ToArray();
22+
}
23+
24+
public int ImageflowErrorCode { get; }
25+
public string CopyString()
26+
{
27+
return BorrowBytes().Utf8ToString();
28+
}
29+
30+
public JsonNode? Parse()
31+
{
32+
return BorrowBytes().ParseJsonNode();
33+
}
34+
35+
public byte[] CopyBytes()
36+
{
37+
return BorrowBytes().ToArray();
38+
}
39+
}

src/Imageflow/Internal.Helpers/UnmanagedMemoryManager.cs renamed to src/Imageflow/Internal.Helpers/Unused/UnmanagedMemoryManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Buffers;
22
using System.Runtime.CompilerServices;
33

4-
namespace Imageflow.Internal.Helpers;
4+
namespace Imageflow.Internal.Helpers.Unused;
55

66
internal unsafe class UnmanagedMemoryManager : MemoryManager<byte>
77
{

tests/Imageflow.Test/TestJobContext.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
using Xunit;
1010
using Xunit.Abstractions;
11-
11+
#if NET8_0_OR_GREATER
1212
using JsonNamingPolicy = System.Text.Json.JsonNamingPolicy;
13+
#endif
1314
using JsonSerializerOptions = System.Text.Json.JsonSerializerOptions;
1415
#pragma warning disable CS0618 // Type or member is obsolete
1516

0 commit comments

Comments
 (0)