44//
55
66using Microsoft . Extensions . Logging ;
7- using PolylineAlgorithm ;
87using PolylineAlgorithm . Diagnostics ;
98using PolylineAlgorithm . Internal ;
109using PolylineAlgorithm . Internal . Diagnostics ;
1110using PolylineAlgorithm . Internal . Logging ;
12- using System ;
1311using System . Runtime . CompilerServices ;
14- using System . Threading ;
1512
1613namespace PolylineAlgorithm . Abstraction {
1714 /// <summary>
@@ -33,14 +30,14 @@ protected AbstractPolylineDecoder()
3330 /// <summary>
3431 /// Initializes a new instance of the <see cref="AbstractPolylineDecoder{TPolyline, TCoordinate}"/> class with the specified encoding options.
3532 /// </summary>
36- /// <param name="encodingOptions ">
33+ /// <param name="options ">
3734 /// The <see cref="PolylineEncodingOptions"/> to use for encoding operations.
3835 /// </param>
3936 /// <exception cref="ArgumentNullException">
40- /// Thrown when <paramref name="encodingOptions "/> is <see langword="null" />
37+ /// Thrown when <paramref name="options "/> is <see langword="null" />
4138 /// </exception>
4239 protected AbstractPolylineDecoder ( PolylineEncodingOptions options ) {
43- if ( options is null ) {
40+ if ( options is null ) {
4441 ExceptionGuard . ThrowArgumentNull ( nameof ( options ) ) ;
4542 }
4643
@@ -110,7 +107,6 @@ public IEnumerable<TCoordinate> Decode(TPolyline polyline, CancellationToken can
110107 _logger ? . LogOperationFailedDebug ( OperationName ) ;
111108 _logger ? . LogInvalidPolylineWarning ( position ) ;
112109
113- OnInvalidPolyline ( position , sequence ) ;
114110 ExceptionGuard . ThrowInvalidPolylineFormat ( position ) ;
115111 }
116112
@@ -126,6 +122,16 @@ public IEnumerable<TCoordinate> Decode(TPolyline polyline, CancellationToken can
126122 }
127123 }
128124
125+ /// <summary>
126+ /// 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.
129+ /// </summary>
130+ /// <param name="polyline">The polyline instance to validate.</param>
131+ /// <param name="logger">Optional logger for diagnostic messages.</param>
132+ /// <exception cref="ArgumentNullException">
133+ /// Thrown when <paramref name="polyline"/> is <see langword="null"/>.
134+ /// </exception>
129135 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
130136 private static void ValidateNullPolyline ( TPolyline polyline , ILogger ? logger ) {
131137 if ( polyline is null ) {
@@ -134,6 +140,16 @@ private static void ValidateNullPolyline(TPolyline polyline, ILogger? logger) {
134140 }
135141 }
136142
143+ /// <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.
147+ /// </summary>
148+ /// <param name="polylineSequence">The polyline character sequence to validate.</param>
149+ /// <param name="logger">Optional logger for diagnostic messages.</param>
150+ /// <exception cref="InvalidPolylineException">
151+ /// Thrown when <paramref name="polylineSequence"/> is shorter than the minimum allowed length.
152+ /// </exception>
137153 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
138154 private static void ValidateSequence ( ReadOnlyMemory < char > polylineSequence , ILogger ? logger ) {
139155 if ( polylineSequence . Length < Defaults . Polyline . Block . Length . Min ) {
@@ -158,13 +174,6 @@ protected virtual void ValidateFormat(ReadOnlyMemory<char> sequence, ILogger? lo
158174 }
159175 }
160176
161- /// <summary>
162- /// Hook for subclasses to handle invalid polyline cases.
163- /// </summary>
164- protected virtual void OnInvalidPolyline ( int position , ReadOnlyMemory < char > polylineSequence ) {
165- // Subclasses can override for custom error handling/logging.
166- }
167-
168177 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
169178 protected abstract ReadOnlyMemory < char > GetReadOnlyMemory ( in TPolyline polyline ) ;
170179
0 commit comments