Skip to content

Commit b05f86a

Browse files
committed
Normalize line endings to CRLF across all .cs files
1 parent e5c04fe commit b05f86a

995 files changed

Lines changed: 132350 additions & 132350 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 146 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,147 @@
1-
using System.Buffers;
2-
3-
namespace UglyToad.PdfPig.Core;
4-
5-
/// <summary>
6-
/// Pooled Buffer Writer
7-
/// </summary>
8-
public sealed class ArrayPoolBufferWriter<T> : IBufferWriter<T>, IDisposable
9-
{
10-
private const int DefaultBufferSize = 256;
11-
12-
private T[] buffer;
13-
private int position;
14-
15-
/// <summary>
16-
/// PooledBufferWriter constructor
17-
/// </summary>
18-
public ArrayPoolBufferWriter()
19-
{
20-
buffer = ArrayPool<T>.Shared.Rent(DefaultBufferSize);
21-
position = 0;
22-
}
23-
24-
/// <summary>
25-
/// Constructs a PooledBufferWriter
26-
/// </summary>
27-
/// <param name="size">The size of the initial buffer</param>
28-
public ArrayPoolBufferWriter(int size)
29-
{
30-
buffer = ArrayPool<T>.Shared.Rent(size);
31-
position = 0;
32-
}
33-
34-
/// <summary>
35-
/// Advanced the current position
36-
/// </summary>
37-
/// <param name="count"></param>
38-
public void Advance(int count)
39-
{
40-
position += count;
41-
}
42-
43-
/// <summary>
44-
/// Writes the provided value
45-
/// </summary>
46-
public void Write(T value)
47-
{
48-
GetSpan(1)[0] = value;
49-
50-
position += 1;
51-
}
52-
53-
/// <summary>
54-
/// Writes the provided values
55-
/// </summary>
56-
/// <param name="values"></param>
57-
public void Write(ReadOnlySpan<T> values)
58-
{
59-
values.CopyTo(GetSpan(values.Length));
60-
61-
position += values.Length;
62-
}
63-
64-
/// <summary>
65-
/// Returns a writeable block of memory that can be written to
66-
/// </summary>
67-
public Memory<T> GetMemory(int sizeHint = 0)
68-
{
69-
EnsureCapacity(sizeHint);
70-
71-
return buffer.AsMemory(position);
72-
}
73-
74-
/// <summary>
75-
/// Returns a span that can be written to
76-
/// </summary>
77-
public Span<T> GetSpan(int sizeHint = 0)
78-
{
79-
EnsureCapacity(sizeHint);
80-
81-
return buffer.AsSpan(position);
82-
}
83-
84-
/// <summary>
85-
/// Returns the number of bytes written to the buffer
86-
/// </summary>
87-
public int WrittenCount => position;
88-
89-
/// <summary>
90-
/// Returns the committed data as Memory
91-
/// </summary>
92-
public ReadOnlyMemory<T> WrittenMemory => buffer.AsMemory(0, position);
93-
94-
/// <summary>
95-
/// Returns the committed data as a Span
96-
/// </summary>
97-
public ReadOnlySpan<T> WrittenSpan => buffer.AsSpan(0, position);
98-
99-
private void EnsureCapacity(int sizeHint)
100-
{
101-
if (sizeHint is 0)
102-
{
103-
sizeHint = 1;
104-
}
105-
106-
if (sizeHint > RemainingBytes)
107-
{
108-
var newBuffer = ArrayPool<T>.Shared.Rent(Math.Max(position + sizeHint, 512));
109-
110-
if (buffer.Length != 0)
111-
{
112-
Array.Copy(buffer, 0, newBuffer, 0, position);
113-
ArrayPool<T>.Shared.Return(buffer);
114-
}
115-
116-
buffer = newBuffer;
117-
}
118-
}
119-
120-
private int RemainingBytes => buffer.Length - position;
121-
122-
/// <summary>
123-
/// Resets the internal state so the instance can be reused before disposal
124-
/// </summary>
125-
/// <param name="clearArray"></param>
126-
public void Reset(bool clearArray = false)
127-
{
128-
position = 0;
129-
130-
if (clearArray)
131-
{
132-
buffer.AsSpan().Clear();
133-
}
134-
}
135-
136-
/// <summary>
137-
/// Disposes the buffer and returns any rented memory to the pool
138-
/// </summary>
139-
public void Dispose()
140-
{
141-
if (buffer.Length != 0)
142-
{
143-
ArrayPool<T>.Shared.Return(buffer);
144-
buffer = [];
145-
}
146-
}
1+
using System.Buffers;
2+
3+
namespace UglyToad.PdfPig.Core;
4+
5+
/// <summary>
6+
/// Pooled Buffer Writer
7+
/// </summary>
8+
public sealed class ArrayPoolBufferWriter<T> : IBufferWriter<T>, IDisposable
9+
{
10+
private const int DefaultBufferSize = 256;
11+
12+
private T[] buffer;
13+
private int position;
14+
15+
/// <summary>
16+
/// PooledBufferWriter constructor
17+
/// </summary>
18+
public ArrayPoolBufferWriter()
19+
{
20+
buffer = ArrayPool<T>.Shared.Rent(DefaultBufferSize);
21+
position = 0;
22+
}
23+
24+
/// <summary>
25+
/// Constructs a PooledBufferWriter
26+
/// </summary>
27+
/// <param name="size">The size of the initial buffer</param>
28+
public ArrayPoolBufferWriter(int size)
29+
{
30+
buffer = ArrayPool<T>.Shared.Rent(size);
31+
position = 0;
32+
}
33+
34+
/// <summary>
35+
/// Advanced the current position
36+
/// </summary>
37+
/// <param name="count"></param>
38+
public void Advance(int count)
39+
{
40+
position += count;
41+
}
42+
43+
/// <summary>
44+
/// Writes the provided value
45+
/// </summary>
46+
public void Write(T value)
47+
{
48+
GetSpan(1)[0] = value;
49+
50+
position += 1;
51+
}
52+
53+
/// <summary>
54+
/// Writes the provided values
55+
/// </summary>
56+
/// <param name="values"></param>
57+
public void Write(ReadOnlySpan<T> values)
58+
{
59+
values.CopyTo(GetSpan(values.Length));
60+
61+
position += values.Length;
62+
}
63+
64+
/// <summary>
65+
/// Returns a writeable block of memory that can be written to
66+
/// </summary>
67+
public Memory<T> GetMemory(int sizeHint = 0)
68+
{
69+
EnsureCapacity(sizeHint);
70+
71+
return buffer.AsMemory(position);
72+
}
73+
74+
/// <summary>
75+
/// Returns a span that can be written to
76+
/// </summary>
77+
public Span<T> GetSpan(int sizeHint = 0)
78+
{
79+
EnsureCapacity(sizeHint);
80+
81+
return buffer.AsSpan(position);
82+
}
83+
84+
/// <summary>
85+
/// Returns the number of bytes written to the buffer
86+
/// </summary>
87+
public int WrittenCount => position;
88+
89+
/// <summary>
90+
/// Returns the committed data as Memory
91+
/// </summary>
92+
public ReadOnlyMemory<T> WrittenMemory => buffer.AsMemory(0, position);
93+
94+
/// <summary>
95+
/// Returns the committed data as a Span
96+
/// </summary>
97+
public ReadOnlySpan<T> WrittenSpan => buffer.AsSpan(0, position);
98+
99+
private void EnsureCapacity(int sizeHint)
100+
{
101+
if (sizeHint is 0)
102+
{
103+
sizeHint = 1;
104+
}
105+
106+
if (sizeHint > RemainingBytes)
107+
{
108+
var newBuffer = ArrayPool<T>.Shared.Rent(Math.Max(position + sizeHint, 512));
109+
110+
if (buffer.Length != 0)
111+
{
112+
Array.Copy(buffer, 0, newBuffer, 0, position);
113+
ArrayPool<T>.Shared.Return(buffer);
114+
}
115+
116+
buffer = newBuffer;
117+
}
118+
}
119+
120+
private int RemainingBytes => buffer.Length - position;
121+
122+
/// <summary>
123+
/// Resets the internal state so the instance can be reused before disposal
124+
/// </summary>
125+
/// <param name="clearArray"></param>
126+
public void Reset(bool clearArray = false)
127+
{
128+
position = 0;
129+
130+
if (clearArray)
131+
{
132+
buffer.AsSpan().Clear();
133+
}
134+
}
135+
136+
/// <summary>
137+
/// Disposes the buffer and returns any rented memory to the pool
138+
/// </summary>
139+
public void Dispose()
140+
{
141+
if (buffer.Length != 0)
142+
{
143+
ArrayPool<T>.Shared.Return(buffer);
144+
buffer = [];
145+
}
146+
}
147147
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
namespace UglyToad.PdfPig.Core
2-
{
3-
/// <summary>
4-
/// Rules for determining which points lie inside/outside a path.
5-
/// </summary>
6-
public enum FillingRule : byte
7-
{
8-
/// <summary>
9-
/// No rule.
10-
/// </summary>
11-
None = 0,
12-
13-
/// <summary>
14-
/// This even-odd rule determines whether a point is inside a path by drawing a ray from that point in
15-
/// any direction and simply counting the number of path segments that cross the ray, regardless of
16-
/// direction. If this number is odd, the point is inside; if even, the point is outside. This yields
17-
/// the same results as the nonzero winding number rule for paths with simple shapes, but produces
18-
/// different results for more complex shapes.
19-
/// </summary>
20-
EvenOdd = 1,
21-
22-
/// <summary>
23-
/// The nonzero winding number rule determines whether a given point is inside a path by conceptually
24-
/// drawing a ray from that point to infinity in any direction and then examining the places where a
25-
/// segment of the path crosses the ray. Starting with a count of 0, the rule adds 1 each time a path
26-
/// segment crosses the ray from left to right and subtracts 1 each time a segment crosses from right
27-
/// to left. After counting all the crossings, if the result is 0, the point is outside the path;
28-
/// otherwise, it is inside.
29-
/// </summary>
30-
NonZeroWinding = 2
31-
}
32-
}
1+
namespace UglyToad.PdfPig.Core
2+
{
3+
/// <summary>
4+
/// Rules for determining which points lie inside/outside a path.
5+
/// </summary>
6+
public enum FillingRule : byte
7+
{
8+
/// <summary>
9+
/// No rule.
10+
/// </summary>
11+
None = 0,
12+
13+
/// <summary>
14+
/// This even-odd rule determines whether a point is inside a path by drawing a ray from that point in
15+
/// any direction and simply counting the number of path segments that cross the ray, regardless of
16+
/// direction. If this number is odd, the point is inside; if even, the point is outside. This yields
17+
/// the same results as the nonzero winding number rule for paths with simple shapes, but produces
18+
/// different results for more complex shapes.
19+
/// </summary>
20+
EvenOdd = 1,
21+
22+
/// <summary>
23+
/// The nonzero winding number rule determines whether a given point is inside a path by conceptually
24+
/// drawing a ray from that point to infinity in any direction and then examining the places where a
25+
/// segment of the path crosses the ray. Starting with a count of 0, the rule adds 1 each time a path
26+
/// segment crosses the ray from left to right and subtracts 1 each time a segment crosses from right
27+
/// to left. After counting all the crossings, if the result is 0, the point is outside the path;
28+
/// otherwise, it is inside.
29+
/// </summary>
30+
NonZeroWinding = 2
31+
}
32+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
global using System;
1+
global using System;
22
global using System.Collections.Generic;
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
namespace UglyToad.PdfPig.Core
2-
{
3-
/// <summary>
4-
/// Indicates the type may be cloned making entirely independent copies.
5-
/// </summary>
6-
public interface IDeepCloneable<out T>
7-
{
8-
/// <summary>
9-
/// Clone the type including all referenced data.
10-
/// </summary>
11-
T DeepClone();
12-
}
13-
}
1+
namespace UglyToad.PdfPig.Core
2+
{
3+
/// <summary>
4+
/// Indicates the type may be cloned making entirely independent copies.
5+
/// </summary>
6+
public interface IDeepCloneable<out T>
7+
{
8+
/// <summary>
9+
/// Clone the type including all referenced data.
10+
/// </summary>
11+
T DeepClone();
12+
}
13+
}

0 commit comments

Comments
 (0)