Skip to content

Commit 4272fdf

Browse files
Copilotmattleibow
andcommitted
Migrate HarfBuzzSharp.Blob XML documentation to inline comments
Co-authored-by: mattleibow <[email protected]>
1 parent 3be8361 commit 4272fdf

File tree

3 files changed

+82
-16
lines changed

3 files changed

+82
-16
lines changed

API.Docs.Migration.Checklist.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
66
## Namespace HarfBuzzSharp
77

8-
- [ ] HarfBuzzSharp.Blob
9-
- [ ] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.Int32,HarfBuzzSharp.MemoryMode,HarfBuzzSharp.ReleaseDelegate)
10-
- [ ] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.Int32,HarfBuzzSharp.MemoryMode)
11-
- [ ] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.UInt32,HarfBuzzSharp.MemoryMode,System.Object,HarfBuzzSharp.BlobReleaseDelegate)
12-
- [ ] M:HarfBuzzSharp.Blob.AsSpan
13-
- [ ] M:HarfBuzzSharp.Blob.AsStream
14-
- [ ] M:HarfBuzzSharp.Blob.Dispose(System.Boolean)
15-
- [ ] M:HarfBuzzSharp.Blob.DisposeHandler
16-
- [ ] M:HarfBuzzSharp.Blob.FromFile(System.String)
17-
- [ ] M:HarfBuzzSharp.Blob.FromStream(System.IO.Stream)
18-
- [ ] M:HarfBuzzSharp.Blob.MakeImmutable
19-
- [ ] P:HarfBuzzSharp.Blob.Empty
20-
- [ ] P:HarfBuzzSharp.Blob.FaceCount
21-
- [ ] P:HarfBuzzSharp.Blob.IsImmutable
22-
- [ ] P:HarfBuzzSharp.Blob.Length
8+
- [x] HarfBuzzSharp.Blob
9+
- [x] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.Int32,HarfBuzzSharp.MemoryMode,HarfBuzzSharp.ReleaseDelegate)
10+
- [x] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.Int32,HarfBuzzSharp.MemoryMode)
11+
- [ ] M:HarfBuzzSharp.Blob.#ctor(System.IntPtr,System.UInt32,HarfBuzzSharp.MemoryMode,System.Object,HarfBuzzSharp.BlobReleaseDelegate) - Missing in code
12+
- [x] M:HarfBuzzSharp.Blob.AsSpan - Note: returns Span<byte> in code vs ReadOnlySpan<byte> in XML
13+
- [x] M:HarfBuzzSharp.Blob.AsStream
14+
- [x] M:HarfBuzzSharp.Blob.Dispose(System.Boolean)
15+
- [x] M:HarfBuzzSharp.Blob.DisposeHandler
16+
- [x] M:HarfBuzzSharp.Blob.FromFile(System.String)
17+
- [x] M:HarfBuzzSharp.Blob.FromStream(System.IO.Stream)
18+
- [x] M:HarfBuzzSharp.Blob.MakeImmutable
19+
- [x] P:HarfBuzzSharp.Blob.Empty
20+
- [x] P:HarfBuzzSharp.Blob.FaceCount
21+
- [x] P:HarfBuzzSharp.Blob.IsImmutable
22+
- [x] P:HarfBuzzSharp.Blob.Length
2323
- [ ] HarfBuzzSharp.BlobReleaseDelegate
2424
- [ ] HarfBuzzSharp.Buffer
2525
- [ ] F:HarfBuzzSharp.Buffer.DefaultReplacementCodepoint

binding/HarfBuzzSharp/Blob.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,120 @@
55

66
namespace HarfBuzzSharp
77
{
8+
/// <summary>
9+
/// Represents a blob of data in memory.
10+
/// </summary>
11+
/// <remarks>
12+
/// </remarks>
813
public unsafe class Blob : NativeObject
914
{
1015
private static readonly Lazy<Blob> emptyBlob = new Lazy<Blob> (() => new StaticBlob (HarfBuzzApi.hb_blob_get_empty ()));
1116

17+
/// <summary>
18+
/// Gets a reference to the empty <see cref="T:HarfBuzzSharp.Blob" /> instance.
19+
/// </summary>
20+
/// <value></value>
21+
/// <remarks>
22+
/// </remarks>
1223
public static Blob Empty => emptyBlob.Value;
1324

1425
internal Blob (IntPtr handle)
1526
: base (handle)
1627
{
1728
}
1829

30+
/// <param name="data">The data to wrap.</param>
31+
/// <param name="length">The length of the data being wrapped.</param>
32+
/// <param name="mode">The memory mode to use.</param>
33+
/// <summary>Creates a new <see cref="T:HarfBuzzSharp.Blob" /> instance, wrapping the specified data.</summary>
34+
/// <remarks>If there was a problem creating the blob, or if the data length was zero, then an empty blob will be created.</remarks>
1935
public Blob (IntPtr data, int length, MemoryMode mode)
2036
: this (data, length, mode, null)
2137
{
2238
}
2339

40+
/// <param name="data">The data to wrap.</param>
41+
/// <param name="length">The length of the data being wrapped.</param>
42+
/// <param name="mode">The memory mode to use.</param>
43+
/// <param name="releaseDelegate">The delegate to invoke when the data is not needed anymore.</param>
44+
/// <summary>Creates a new <see cref="T:HarfBuzzSharp.Blob" /> instance, wrapping the specified data.</summary>
45+
/// <remarks>If there was a problem creating the blob, or if the data length was zero, then an empty blob will be created.</remarks>
2446
public Blob (IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseDelegate)
2547
: this (Create (data, length, mode, releaseDelegate))
2648
{
2749
}
2850

51+
/// <param name="disposing">
52+
/// <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
53+
/// <summary>Releases the unmanaged resources used by the <see cref="T:HarfBuzzSharp.Blob" /> and optionally releases the managed resources.</summary>
54+
/// <remarks>Always dispose the object before you release your last reference to the <see cref="T:HarfBuzzSharp.Blob" />. Otherwise, the resources it is using will not be freed until the garbage collector calls the finalizer.</remarks>
2955
protected override void Dispose (bool disposing) =>
3056
base.Dispose (disposing);
3157

58+
/// <summary>Releases the unmanaged resources used.</summary>
59+
/// <remarks>
60+
/// </remarks>
3261
protected override void DisposeHandler ()
3362
{
3463
if (Handle != IntPtr.Zero) {
3564
HarfBuzzApi.hb_blob_destroy (Handle);
3665
}
3766
}
3867

68+
/// <summary>
69+
/// Gets the length of blob data in bytes.
70+
/// </summary>
71+
/// <value></value>
72+
/// <remarks>
73+
/// </remarks>
3974
public int Length => (int)HarfBuzzApi.hb_blob_get_length (Handle);
4075

76+
/// <summary>
77+
/// Gets the number of faces in this blob.
78+
/// </summary>
79+
/// <value></value>
80+
/// <remarks>
81+
/// </remarks>
4182
public int FaceCount => (int)HarfBuzzApi.hb_face_count (Handle);
4283

84+
/// <summary>
85+
/// Gets the value indicating whether the blob is immutable.
86+
/// </summary>
87+
/// <value></value>
88+
/// <remarks>
89+
/// </remarks>
4390
public bool IsImmutable => HarfBuzzApi.hb_blob_is_immutable (Handle);
4491

92+
/// <summary>Makes the blob immutable.</summary>
93+
/// <remarks>
94+
/// </remarks>
4595
public void MakeImmutable () => HarfBuzzApi.hb_blob_make_immutable (Handle);
4696

97+
/// <summary>Returns a stream that wraps the data.</summary>
98+
/// <returns>Returns the stream that wraps the data.</returns>
99+
/// <remarks>If the data is released, then the stream becomes invalid.</remarks>
47100
public unsafe Stream AsStream ()
48101
{
49102
uint length;
50103
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
51104
return new UnmanagedMemoryStream ((byte*)dataPtr, length);
52105
}
53106

107+
/// <summary>Returns a span that wraps the data.</summary>
108+
/// <returns>Returns the span that wraps the data.</returns>
109+
/// <remarks>If the data is released, then the span becomes invalid.</remarks>
54110
public unsafe Span<byte> AsSpan ()
55111
{
56112
uint length;
57113
var dataPtr = HarfBuzzApi.hb_blob_get_data (Handle, &length);
58114
return new Span<byte> (dataPtr, (int)length);
59115
}
60116

117+
/// <param name="fileName">The path to the file to load.</param>
118+
/// <summary>Creates a new <see cref="T:HarfBuzzSharp.Blob" /> instance from the contents of the file.</summary>
119+
/// <returns>Returns the new <see cref="T:HarfBuzzSharp.Blob" /> instance.</returns>
120+
/// <remarks>
121+
/// </remarks>
61122
public static Blob FromFile (string fileName)
62123
{
63124
if (!File.Exists (fileName)) {
@@ -68,6 +129,11 @@ public static Blob FromFile (string fileName)
68129
return new Blob (blob);
69130
}
70131

132+
/// <param name="stream">The stream to use.</param>
133+
/// <summary>Creates a new <see cref="T:HarfBuzzSharp.Blob" /> instance from the contents of the stream.</summary>
134+
/// <returns>Returns the new <see cref="T:HarfBuzzSharp.Blob" /> instance.</returns>
135+
/// <remarks>
136+
/// </remarks>
71137
public static unsafe Blob FromStream (Stream stream)
72138
{
73139
// TODO: check to see if we can avoid the second copy (the ToArray)

0 commit comments

Comments
 (0)