Skip to content

Commit 9ad4388

Browse files
author
Petr Sramek
committed
added Polyline struct documentation
1 parent 45dd02c commit 9ad4388

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

src/PolylineAlgorithm/Polyline.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,72 @@ namespace PolylineAlgorithm;
1010
using System.Diagnostics.CodeAnalysis;
1111
using System.Runtime.InteropServices;
1212

13+
/// <summary>
14+
/// Represents a readonly encoded polyline string.
15+
/// </summary>
1316
[StructLayout(LayoutKind.Auto)]
1417
[DebuggerDisplay("Value: {ToString()}, IsEmpty: {IsEmpty}, Length: {Length}")]
1518
public readonly struct Polyline : IEquatable<Polyline> {
1619
private readonly ReadOnlyMemory<char> _value;
1720

21+
/// <summary>
22+
/// Creates a new <see cref="Polyline"/> structure that is empty.
23+
/// </summary>
1824
public Polyline() {
1925
_value = ReadOnlyMemory<char>.Empty;
2026
}
2127

28+
/// <summary>
29+
/// Creates a new <see cref="Polyline"/> structure that contains the specified string value.
30+
/// </summary>
2231
public Polyline(string value) {
2332
_value = value?.AsMemory() ?? throw new ArgumentNullException(nameof(value));
2433
}
2534

35+
36+
/// <summary>
37+
/// Creates a new <see cref="Polyline"/> structure that contains the specified Unicode character array.
38+
/// </summary>
2639
public Polyline(char[] value) {
2740
_value = value?.AsMemory() ?? throw new ArgumentNullException(nameof(value));
2841
}
2942

43+
44+
/// <summary>
45+
/// Creates a new <see cref="Polyline"/> structure that contains the specified readonly memory region.
46+
/// </summary>
3047
public Polyline(ReadOnlyMemory<char> value) {
3148
_value = value;
3249
}
3350

3451
internal readonly ReadOnlySpan<char> Span => _value.Span;
3552

53+
/// <summary>
54+
/// Gets a value indicating whether this <see cref="Polyline" /> is empty.
55+
/// </summary>
3656
public readonly bool IsEmpty => _value.IsEmpty;
3757

58+
/// <summary>
59+
/// Gets the number of characters in the current <see cref="Polyline" /> object.
60+
/// </summary>
3861
public readonly int Length => _value.Length;
3962

63+
/// <summary>
64+
/// Copies the characters in this instance to a Unicode character array.
65+
/// </summary>
66+
/// <returns>A Unicode character array.</returns>
4067
public char[] ToCharArray() => _value.ToArray();
4168

69+
/// <summary>
70+
/// Returns underlying <see cref="ReadOnlyMemory{T}" /> this instance represents.
71+
/// </summary>
72+
/// <returns></returns>
4273
public ReadOnlyMemory<char> AsMemory() => _value;
4374

44-
/// <inheritdoc />
75+
/// <summary>
76+
/// Returns a string representation of the value of this instance.
77+
/// </summary>
78+
/// <returns>The string value of this <see cref="Polyline"/> object.</returns>
4579
public override string ToString() => _value.ToString();
4680

4781
#region Overrides
@@ -64,35 +98,76 @@ public Polyline(ReadOnlyMemory<char> value) {
6498
#endregion
6599

66100
#region Equality operators
67-
101+
/// <summary>
102+
/// Indicates whether the values of two specified <see cref="Polyline" /> objects are equal.
103+
/// </summary>
104+
/// <param name="left">The first object to compare.</param>
105+
/// <param name="right">The second object to compare.</param>
106+
/// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are equal; otherwise, <see langword="false"/>.</returns>
68107
[ExcludeFromCodeCoverage]
69108
public static bool operator ==(Polyline left, Polyline right) => left.Equals(right);
70109

110+
/// <summary>
111+
/// Indicates whether the values of two specified <see cref="Polyline" /> objects are not equal.
112+
/// </summary>
113+
/// <param name="left">The first object to compare.</param>
114+
/// <param name="right">The second object to compare.</param>
115+
/// <returns><see langword="true"/> if <paramref name="left"/> and <paramref name="right"/> are not equal; otherwise, <see langword="false"/>.</returns>
71116
[ExcludeFromCodeCoverage]
72117
public static bool operator !=(Polyline left, Polyline right) => !(left == right);
73118

74119
#endregion
75120

76121
#region Factory methods
77122

123+
/// <summary>
124+
/// Creates an instance of the current type from a Unicode character array.
125+
/// </summary>
126+
/// <param name="polyline">A Unicode character array representing an encoded polyline.</param>
127+
/// <returns>The <see cref="Polyline"/> value that corresponds to the specified Unicide character array.</returns>
78128
public static Polyline FromCharArray(char[] polyline) => new(polyline);
79129

130+
/// <summary>
131+
/// Creates an instance of the current type from a readonly memory region.
132+
/// </summary>
133+
/// <param name="polyline">A readonly memory region representing an encoded polyline.</param>
134+
/// <returns>The <see cref="Polyline"/> value that corresponds to the specified readonly memory region.</returns>
80135
public static Polyline FromMemory(ReadOnlyMemory<char> polyline) => new(polyline);
81136

137+
/// <summary>
138+
/// Creates an instance of the current type from a string.
139+
/// </summary>
140+
/// <param name="polyline">A string representing an encoded polyline.</param>
141+
/// <returns>The <see cref="Polyline"/> value that corresponds to the specified string value.</returns>
82142
public static Polyline FromString(string polyline) => new(polyline);
83143

84144

85145
#endregion
86146

87147
#region Explicit conversions
88148

149+
/// <summary>
150+
/// Defines an explicit conversion of a Unicode character array to a <see cref="Polyline"/>.
151+
/// </summary>
152+
/// <param name="polyline">The Unicode character array to convert.</param>
153+
/// <returns>The converted Unicode character array.</returns>
89154
[ExcludeFromCodeCoverage]
90155
public static explicit operator Polyline(char[] polyline) => FromCharArray(polyline);
91156

157+
/// <summary>
158+
/// Defines an explicit conversion of a readonly memory region to a <see cref="Polyline"/>.
159+
/// </summary>
160+
/// <param name="polyline">The readonly memory region to convert.</param>
161+
/// <returns>The converted readonly memory region.</returns>
92162
[SuppressMessage("Usage", "CA2225:Operator overloads have named alternates", Justification = $"Provided alternative {nameof(Polyline)}.{nameof(FromMemory)} to follow {nameof(String)}.{nameof(AsMemory)} naming pattern.")]
93163
[ExcludeFromCodeCoverage]
94164
public static explicit operator Polyline(ReadOnlyMemory<char> polyline) => FromMemory(polyline);
95165

166+
/// <summary>
167+
/// Defines an explicit conversion of a string to a <see cref="Polyline"/>.
168+
/// </summary>
169+
/// <param name="polyline">The string to convert.</param>
170+
/// <returns>The converted string.</returns>
96171
[ExcludeFromCodeCoverage]
97172
public static explicit operator Polyline(string polyline) => FromString(polyline);
98173

0 commit comments

Comments
 (0)