Skip to content

Commit 7d7ab01

Browse files
Copilotpetesramek
andauthored
Rewrite XML doc comments for consistency across the solution (#150)
XML comments were inconsistent: abbreviated inline param/exception docs mixed with full expanded blocks, missing `<typeparam>` on generic types, empty `<exception>` tags, broken `<see cref>` and `<paramref>` references, a missing copyright header, and a typo. ## Changes - **`AbstractPolylineDecoder`** — Added `<typeparam>` docs; expanded the abbreviated `Decode(polyline, CancellationToken)` overload to full form including `OperationCanceledException`; added `<param>`/`<exception>` to `ValidateFormat`; added full docs to abstract `GetReadOnlyMemory` and `CreateCoordinate`; simplified private helper summaries to single sentences - **`AbstractPolylineEncoder`** — Added `<typeparam>` docs; removed incorrect `<exception cref="InternalBufferOverflowException"/>` (wrong type); added description to empty `<exception cref="InvalidOperationException"/>` - **`PolylineEncodingOptionsBuilder`** — Standardized all three builder `<returns>` to `"The current PolylineEncodingOptionsBuilder instance for method chaining."`; simplified `WithPrecision` summary - **`PolylineEncoding`** — Removed stale `<paramref name="rounding"/>` (no such parameter on `Normalize`); fixed `<see cref="GetCharCount"/>` → `<see cref="GetRequiredBufferSize"/>` - **`PolylineEncoderExtensions`** — Added missing copyright header; added `<typeparam>` docs; updated method summaries/returns to reference `TCoordinate`/`TPolyline` rather than concrete types; added `<exception>` for null `coordinates` - **`PolylineDecoderExtensions`** — Added `<exception cref="ArgumentNullException">` for null `polyline` on `string` and `char[]` overloads - **`CoordinateDelta`** — Removed blank lines between closing doc tags and method declarations; moved second `<summary>` sentence to `<remarks>` - **`Defaults`** — Added missing `<summary>` on `Coordinate` nested class; fixed typo `"vakues"` → `"values"`; added missing trailing period Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent a303e67 commit 7d7ab01

8 files changed

Lines changed: 107 additions & 48 deletions

File tree

src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212

1313
namespace PolylineAlgorithm.Abstraction {
1414
/// <summary>
15-
/// Decodes encoded polyline strings into sequences of geographic coordinates.
16-
/// Implements the <see cref="IPolylineDecoder{TPolyline, TCoordinate}"/> interface.
15+
/// Provides a base implementation for decoding encoded polyline strings into sequences of geographic coordinates.
1716
/// </summary>
1817
/// <remarks>
19-
/// This abstract class provides a base implementation for decoding polylines, allowing subclasses to define how to handle specific polyline formats.
18+
/// Derive from this class to implement a decoder for a specific polyline type. Override <see cref="GetReadOnlyMemory"/>
19+
/// and <see cref="CreateCoordinate"/> to provide type-specific behavior.
2020
/// </remarks>
21+
/// <typeparam name="TPolyline">The type that represents the encoded polyline input.</typeparam>
22+
/// <typeparam name="TCoordinate">The type that represents a decoded geographic coordinate.</typeparam>
2123
public abstract class AbstractPolylineDecoder<TPolyline, TCoordinate> : IPolylineDecoder<TPolyline, TCoordinate> {
2224
private readonly ILogger<AbstractPolylineDecoder<TPolyline, TCoordinate>> _logger;
2325

@@ -34,7 +36,7 @@ protected AbstractPolylineDecoder()
3436
/// The <see cref="PolylineEncodingOptions"/> to use for encoding operations.
3537
/// </param>
3638
/// <exception cref="ArgumentNullException">
37-
/// Thrown when <paramref name="options"/> is <see langword="null" />
39+
/// Thrown when <paramref name="options"/> is <see langword="null"/>.
3840
/// </exception>
3941
protected AbstractPolylineDecoder(PolylineEncodingOptions options) {
4042
if (options is null) {
@@ -74,14 +76,30 @@ public IEnumerable<TCoordinate> Decode(TPolyline polyline)
7476
=> Decode(polyline, CancellationToken.None);
7577

7678
/// <summary>
77-
/// Decodes an encoded polyline with cancellation support.
79+
/// Decodes an encoded <typeparamref name="TPolyline"/> into a sequence of <typeparamref name="TCoordinate"/> instances,
80+
/// with support for cancellation.
7881
/// </summary>
79-
/// <param name="polyline">The encoded polyline.</param>
80-
/// <param name="cancellationToken">Cancellation token.</param>
81-
/// <returns>Decoded coordinates.</returns>
82-
/// <exception cref="ArgumentNullException"/>
83-
/// <exception cref="ArgumentException"/>
84-
/// <exception cref="InvalidPolylineException"/>
82+
/// <param name="polyline">
83+
/// The <typeparamref name="TPolyline"/> instance containing the encoded polyline string to decode.
84+
/// </param>
85+
/// <param name="cancellationToken">
86+
/// A <see cref="CancellationToken"/> that can be used to cancel the decoding operation.
87+
/// </param>
88+
/// <returns>
89+
/// An <see cref="IEnumerable{T}"/> of <typeparamref name="TCoordinate"/> representing the decoded latitude and longitude pairs.
90+
/// </returns>
91+
/// <exception cref="ArgumentNullException">
92+
/// Thrown when <paramref name="polyline"/> is <see langword="null"/>.
93+
/// </exception>
94+
/// <exception cref="ArgumentException">
95+
/// Thrown when <paramref name="polyline"/> is empty.
96+
/// </exception>
97+
/// <exception cref="InvalidPolylineException">
98+
/// Thrown when the polyline format is invalid or malformed at a specific position.
99+
/// </exception>
100+
/// <exception cref="OperationCanceledException">
101+
/// Thrown when <paramref name="cancellationToken"/> is canceled during decoding.
102+
/// </exception>
85103
public IEnumerable<TCoordinate> Decode(TPolyline polyline, CancellationToken cancellationToken) {
86104
const string OperationName = nameof(Decode);
87105

@@ -124,11 +142,9 @@ public IEnumerable<TCoordinate> Decode(TPolyline polyline, CancellationToken can
124142

125143
/// <summary>
126144
/// Validates that the provided polyline is not <see langword="null"/>.
127-
/// Throws an <see cref="ArgumentNullException"/> if the polyline is <see langword="null"/>.
128-
/// Optionally logs a warning if a logger is provided.
129145
/// </summary>
130146
/// <param name="polyline">The polyline instance to validate.</param>
131-
/// <param name="logger">Optional logger for diagnostic messages.</param>
147+
/// <param name="logger">An optional <see cref="ILogger"/> used to log a warning when validation fails.</param>
132148
/// <exception cref="ArgumentNullException">
133149
/// Thrown when <paramref name="polyline"/> is <see langword="null"/>.
134150
/// </exception>
@@ -141,12 +157,10 @@ private static void ValidateNullPolyline(TPolyline polyline, ILogger? logger) {
141157
}
142158

143159
/// <summary>
144-
/// Validates that the polyline sequence meets the minimum required length.
145-
/// Throws an <see cref="InvalidPolylineException"/> if the sequence is too short.
146-
/// Optionally logs diagnostic messages if a logger is provided.
160+
/// Validates that the polyline character sequence meets the minimum required length.
147161
/// </summary>
148162
/// <param name="polylineSequence">The polyline character sequence to validate.</param>
149-
/// <param name="logger">Optional logger for diagnostic messages.</param>
163+
/// <param name="logger">An optional <see cref="ILogger"/> used to log diagnostic messages when validation fails.</param>
150164
/// <exception cref="InvalidPolylineException">
151165
/// Thrown when <paramref name="polylineSequence"/> is shorter than the minimum allowed length.
152166
/// </exception>
@@ -161,8 +175,17 @@ private static void ValidateSequence(ReadOnlyMemory<char> polylineSequence, ILog
161175
}
162176

163177
/// <summary>
164-
/// Validates the polyline format for allowed characters.
178+
/// Validates the format of the polyline character sequence, ensuring all characters are within the allowed range.
165179
/// </summary>
180+
/// <param name="sequence">
181+
/// The read-only memory region of characters representing the polyline to validate.
182+
/// </param>
183+
/// <param name="logger">
184+
/// An optional <see cref="ILogger"/> used to log a warning when format validation fails.
185+
/// </param>
186+
/// <exception cref="ArgumentException">
187+
/// Thrown when the polyline contains characters outside the valid encoding range or has an invalid block structure.
188+
/// </exception>
166189
[MethodImpl(MethodImplOptions.AggressiveInlining)]
167190
protected virtual void ValidateFormat(ReadOnlyMemory<char> sequence, ILogger? logger) {
168191
try {
@@ -174,9 +197,30 @@ protected virtual void ValidateFormat(ReadOnlyMemory<char> sequence, ILogger? lo
174197
}
175198
}
176199

200+
/// <summary>
201+
/// Extracts the underlying read-only memory region of characters from the specified polyline instance.
202+
/// </summary>
203+
/// <param name="polyline">
204+
/// The <typeparamref name="TPolyline"/> instance from which to extract the character sequence.
205+
/// </param>
206+
/// <returns>
207+
/// A <see cref="ReadOnlyMemory{T}"/> of <see cref="char"/> representing the encoded polyline characters.
208+
/// </returns>
177209
[MethodImpl(MethodImplOptions.AggressiveInlining)]
178210
protected abstract ReadOnlyMemory<char> GetReadOnlyMemory(in TPolyline polyline);
179211

212+
/// <summary>
213+
/// Creates a <typeparamref name="TCoordinate"/> instance from the specified latitude and longitude values.
214+
/// </summary>
215+
/// <param name="latitude">
216+
/// The latitude component of the coordinate, in degrees.
217+
/// </param>
218+
/// <param name="longitude">
219+
/// The longitude component of the coordinate, in degrees.
220+
/// </param>
221+
/// <returns>
222+
/// A <typeparamref name="TCoordinate"/> instance representing the specified geographic coordinate.
223+
/// </returns>
180224
[MethodImpl(MethodImplOptions.AggressiveInlining)]
181225
protected abstract TCoordinate CreateCoordinate(double latitude, double longitude);
182226
}

src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ namespace PolylineAlgorithm.Abstraction;
1616
using System.Runtime.CompilerServices;
1717

1818
/// <summary>
19-
/// Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
20-
/// Implements the <see cref="IPolylineEncoder{TCoordinate, TPolyline}"/> interface.
19+
/// Provides a base implementation for encoding sequences of geographic coordinates into encoded polyline strings.
2120
/// </summary>
2221
/// <remarks>
23-
/// This abstract class serves as a base for specific polyline encoders, allowing customization of the encoding process.
22+
/// Derive from this class to implement an encoder for a specific coordinate and polyline type. Override
23+
/// <see cref="GetLatitude"/>, <see cref="GetLongitude"/>, and <see cref="CreatePolyline"/> to provide type-specific behavior.
2424
/// </remarks>
25+
/// <typeparam name="TCoordinate">The type that represents a geographic coordinate to encode.</typeparam>
26+
/// <typeparam name="TPolyline">The type that represents the encoded polyline output.</typeparam>
2527
public abstract class AbstractPolylineEncoder<TCoordinate, TPolyline> : IPolylineEncoder<TCoordinate, TPolyline> {
2628
private readonly ILogger<AbstractPolylineEncoder<TCoordinate, TPolyline>> _logger;
2729
/// <summary>
@@ -68,8 +70,9 @@ protected AbstractPolylineEncoder(PolylineEncodingOptions options) {
6870
/// <exception cref="ArgumentException">
6971
/// Thrown when <paramref name="coordinates"/> is an empty enumeration.
7072
/// </exception>
71-
/// <exception cref="InternalBufferOverflowException"></exception>
72-
/// <exception cref="InvalidOperationException"></exception>
73+
/// <exception cref="InvalidOperationException">
74+
/// Thrown when the internal encoding buffer cannot accommodate the encoded value.
75+
/// </exception>
7376
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MA0051:Method is too long", Justification = "Method contains local methods. Actual method only 55 lines.")]
7477
public TPolyline Encode(ReadOnlySpan<TCoordinate> coordinates) {
7578
const string OperationName = nameof(Encode);

src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class PolylineDecoderExtensions {
2828
/// An <see cref="IEnumerable{Coordinate}"/> containing the decoded latitude and longitude pairs.
2929
/// </returns>
3030
/// <exception cref="ArgumentNullException">
31-
/// Thrown when <paramref name="decoder"/> is <see langword="null"/>.
31+
/// Thrown when <paramref name="decoder"/> or <paramref name="polyline"/> is <see langword="null"/>.
3232
/// </exception>
3333
public static IEnumerable<Coordinate> Decode(this IPolylineDecoder<Polyline, Coordinate> decoder, string polyline) {
3434
if (decoder is null) {
@@ -51,7 +51,7 @@ public static IEnumerable<Coordinate> Decode(this IPolylineDecoder<Polyline, Coo
5151
/// An <see cref="IEnumerable{Coordinate}"/> containing the decoded latitude and longitude pairs.
5252
/// </returns>
5353
/// <exception cref="ArgumentNullException">
54-
/// Thrown when <paramref name="decoder"/> is <see langword="null"/>.
54+
/// Thrown when <paramref name="decoder"/> or <paramref name="polyline"/> is <see langword="null"/>.
5555
/// </exception>
5656
public static IEnumerable<Coordinate> Decode(this IPolylineDecoder<Polyline, Coordinate> decoder, char[] polyline) {
5757
if (decoder is null) {

src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-

1+
//
2+
// Copyright © Pete Sramek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
25

36
namespace PolylineAlgorithm.Extensions;
47

@@ -15,19 +18,21 @@ namespace PolylineAlgorithm.Extensions;
1518
/// </summary>
1619
public static class PolylineEncoderExtensions {
1720
/// <summary>
18-
/// Encodes a collection of <see cref="PolylineAlgorithm.Coordinate"/> instances into an encoded polyline.
21+
/// Encodes a <see cref="List{T}"/> of <typeparamref name="TCoordinate"/> instances into an encoded polyline.
1922
/// </summary>
23+
/// <typeparam name="TCoordinate">The type that represents a geographic coordinate to encode.</typeparam>
24+
/// <typeparam name="TPolyline">The type that represents the encoded polyline output.</typeparam>
2025
/// <param name="encoder">
2126
/// The <see cref="IPolylineEncoder{TCoordinate, TPolyline}"/> instance used to perform the encoding operation.
2227
/// </param>
2328
/// <param name="coordinates">
24-
/// The sequence of <see cref="PolylineAlgorithm.Coordinate"/> objects to encode.
29+
/// The list of <typeparamref name="TCoordinate"/> objects to encode.
2530
/// </param>
2631
/// <returns>
27-
/// A <see cref="PolylineAlgorithm.Polyline"/> representing the encoded polyline string for the provided coordinates.
32+
/// A <typeparamref name="TPolyline"/> instance representing the encoded polyline for the provided coordinates.
2833
/// </returns>
2934
/// <exception cref="ArgumentNullException">
30-
/// Thrown when <paramref name="encoder"/> is <see langword="null"/>.
35+
/// Thrown when <paramref name="encoder"/> or <paramref name="coordinates"/> is <see langword="null"/>.
3136
/// </exception>
3237
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1002:Do not expose generic lists", Justification = "We need a list as we do need to marshal it as span.")]
3338
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MA0016:Prefer using collection abstraction instead of implementation", Justification = "We need a list as we do need to marshal it as span.")]
@@ -49,19 +54,21 @@ public static TPolyline Encode<TCoordinate, TPolyline>(this IPolylineEncoder<TCo
4954

5055

5156
/// <summary>
52-
/// Encodes an array of <see cref="PolylineAlgorithm.Coordinate"/> instances into an encoded polyline.
57+
/// Encodes an array of <typeparamref name="TCoordinate"/> instances into an encoded polyline.
5358
/// </summary>
59+
/// <typeparam name="TCoordinate">The type that represents a geographic coordinate to encode.</typeparam>
60+
/// <typeparam name="TPolyline">The type that represents the encoded polyline output.</typeparam>
5461
/// <param name="encoder">
5562
/// The <see cref="IPolylineEncoder{TCoordinate, TPolyline}"/> instance used to perform the encoding operation.
5663
/// </param>
5764
/// <param name="coordinates">
58-
/// The array of <see cref="PolylineAlgorithm.Coordinate"/> objects to encode.
65+
/// The array of <typeparamref name="TCoordinate"/> objects to encode.
5966
/// </param>
6067
/// <returns>
61-
/// A <see cref="PolylineAlgorithm.Polyline"/> representing the encoded polyline string for the provided coordinates.
68+
/// A <typeparamref name="TPolyline"/> instance representing the encoded polyline for the provided coordinates.
6269
/// </returns>
6370
/// <exception cref="ArgumentNullException">
64-
/// Thrown when <paramref name="encoder"/> is <see langword="null"/>.
71+
/// Thrown when <paramref name="encoder"/> or <paramref name="coordinates"/> is <see langword="null"/>.
6572
/// </exception>
6673
public static TPolyline Encode<TCoordinate, TPolyline>(this IPolylineEncoder<TCoordinate, TPolyline> encoder, TCoordinate[] coordinates) {
6774
if (encoder is null) {

src/PolylineAlgorithm/Internal/CoordinateDelta.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace PolylineAlgorithm.Internal;
1010

1111
/// <summary>
1212
/// Represents the difference (delta) in latitude and longitude between consecutive geographic coordinates.
13-
/// This struct is used to compute and store the change in coordinate values as integer deltas.
1413
/// </summary>
14+
/// <remarks>
15+
/// This struct computes and stores the change in coordinate values as integer deltas between successive coordinates.
16+
/// </remarks>
1517
[DebuggerDisplay("{ToString(),nq}")]
1618
[StructLayout(LayoutKind.Auto)]
1719
internal struct CoordinateDelta {
@@ -39,7 +41,6 @@ public CoordinateDelta() {
3941
/// </summary>
4042
/// <param name="latitude">The next latitude value.</param>
4143
/// <param name="longitude">The next longitude value.</param>
42-
4344
public void Next(int latitude, int longitude) {
4445
Latitude = Delta(_current.Latitude, latitude);
4546
Longitude = Delta(_current.Longitude, longitude);
@@ -57,7 +58,6 @@ public void Next(int latitude, int longitude) {
5758
/// <param name="initial">The previous coordinate value.</param>
5859
/// <param name="next">The next coordinate value.</param>
5960
/// <returns>The computed delta between <paramref name="initial"/> and <paramref name="next"/>.</returns>
60-
6161
private static int Delta(int initial, int next) => next - initial;
6262

6363
/// <summary>

src/PolylineAlgorithm/Internal/Defaults.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ namespace PolylineAlgorithm.Internal;
99

1010
/// <summary>
1111
/// Provides default values and constants used throughout the Polyline Algorithm.
12-
/// Organizes defaults for algorithm parameters, polyline encoding, and geographic coordinates into nested static classes.
1312
/// </summary>
13+
/// <remarks>
14+
/// Organizes defaults for algorithm parameters, polyline encoding, and geographic coordinates into nested static classes.
15+
/// </remarks>
1416
[ExcludeFromCodeCoverage]
1517
internal static class Defaults {
1618
/// <summary>
1719
/// Contains default values and constants specific to the polyline encoding logging.
1820
/// </summary>
1921
internal static class Logging {
2022
/// <summary>
21-
/// Log level multiplier used to distinguish event identification for each log level
23+
/// Log level multiplier used to distinguish event identification for each log level.
2224
/// </summary>
2325
internal const int LogLevelMultiplier = 100;
2426
}
@@ -48,6 +50,9 @@ internal static class Algorithm {
4850
internal const byte UnitSeparator = 31;
4951
}
5052

53+
/// <summary>
54+
/// Contains default values and constants for geographic coordinate validation.
55+
/// </summary>
5156
internal static class Coordinate {
5257
/// <summary>
5358
/// Provides constants representing latitude values, including the default, minimum, and maximum valid values.
@@ -95,7 +100,7 @@ internal static class Polyline {
95100
/// </summary>
96101
internal static class Block {
97102
/// <summary>
98-
/// Contains constants related to the length of encoded vakues in polyline encoding.
103+
/// Contains constants related to the length of encoded values in polyline encoding.
99104
/// </summary>
100105
internal static class Length {
101106
/// <summary>

src/PolylineAlgorithm/PolylineEncoding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class PolylineEncoding {
2727
/// <remarks>
2828
/// <para>
2929
/// This method converts a floating-point coordinate value into a normalized integer by multiplying it by 10 raised
30-
/// to the power of the specified precision, then rounding the result using the specified <paramref name="rounding"/> strategy.
30+
/// to the power of the specified precision, then truncating the result to an integer.
3131
/// </para>
3232
/// <para>
3333
/// For example, with the default precision of 5:
@@ -211,7 +211,7 @@ public static bool TryReadValue(ref int delta, ReadOnlyMemory<char> buffer, ref
211211
/// more characters follow. The position is advanced as characters are written.
212212
/// </para>
213213
/// <para>
214-
/// Before writing, the method validates that sufficient space is available in the buffer by calling <see cref="GetCharCount"/>.
214+
/// Before writing, the method validates that sufficient space is available in the buffer by calling <see cref="GetRequiredBufferSize"/>.
215215
/// If the buffer does not have enough remaining capacity, the method returns <see langword="false"/> without modifying the buffer or position.
216216
/// </para>
217217
/// <para>

0 commit comments

Comments
 (0)