Skip to content

Commit 8f35f95

Browse files
Copilotpetesramek
andauthored
fix: suppress CA1062/CA1000/RS0016/RS0017/CS1574 warnings; begin test rewrites
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/634a0417-96c9-496e-899a-de2bca4033a2 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 6e3a7c6 commit 8f35f95

11 files changed

Lines changed: 227 additions & 319 deletions

src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static class PolylineDecoderExtensions {
3030
/// <exception cref="ArgumentNullException">
3131
/// Thrown when <paramref name="decoder"/> or <paramref name="polyline"/> is <see langword="null"/>.
3232
/// </exception>
33+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
3334
public static IEnumerable<TValue> Decode<TValue>(this IPolylineDecoder<string, TValue> decoder, char[] polyline) {
3435
if (decoder is null) {
3536
ExceptionGuard.ThrowArgumentNull(nameof(decoder));
@@ -58,6 +59,7 @@ public static IEnumerable<TValue> Decode<TValue>(this IPolylineDecoder<string, T
5859
/// <exception cref="ArgumentNullException">
5960
/// Thrown when <paramref name="decoder"/> is <see langword="null"/>.
6061
/// </exception>
62+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
6163
public static IEnumerable<TValue> Decode<TValue>(this IPolylineDecoder<string, TValue> decoder, ReadOnlyMemory<char> polyline) {
6264
if (decoder is null) {
6365
ExceptionGuard.ThrowArgumentNull(nameof(decoder));
@@ -83,6 +85,7 @@ public static IEnumerable<TValue> Decode<TValue>(this IPolylineDecoder<string, T
8385
/// <exception cref="ArgumentNullException">
8486
/// Thrown when <paramref name="decoder"/> or <paramref name="polyline"/> is <see langword="null"/>.
8587
/// </exception>
88+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
8689
public static IEnumerable<TValue> Decode<TValue>(this IPolylineDecoder<ReadOnlyMemory<char>, TValue> decoder, string polyline) {
8790
if (decoder is null) {
8891
ExceptionGuard.ThrowArgumentNull(nameof(decoder));

src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static class PolylineEncoderExtensions {
3636
/// </exception>
3737
[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.")]
3838
[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.")]
39+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
3940
public static TPolyline Encode<TCoordinate, TPolyline>(this IPolylineEncoder<TCoordinate, TPolyline> encoder, List<TCoordinate> coordinates) {
4041
if (encoder is null) {
4142
ExceptionGuard.ThrowArgumentNull(nameof(encoder));
@@ -70,6 +71,7 @@ public static TPolyline Encode<TCoordinate, TPolyline>(this IPolylineEncoder<TCo
7071
/// <exception cref="ArgumentNullException">
7172
/// Thrown when <paramref name="encoder"/> or <paramref name="coordinates"/> is <see langword="null"/>.
7273
/// </exception>
74+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
7375
public static TPolyline Encode<TCoordinate, TPolyline>(this IPolylineEncoder<TCoordinate, TPolyline> encoder, TCoordinate[] coordinates) {
7476
if (encoder is null) {
7577
ExceptionGuard.ThrowArgumentNull(nameof(encoder));

src/PolylineAlgorithm/FormatterBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private FormatterBuilder() { }
4040
/// Creates a new <see cref="FormatterBuilder{TCoordinate, TPolyline}"/> instance.
4141
/// </summary>
4242
/// <returns>A fresh builder with no rules and no polyline delegates.</returns>
43+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "Factory method on a generic builder intentionally lives on the type so callers write FormatterBuilder<T, U>.Create() without needing a separate non-generic factory class.")]
4344
public static FormatterBuilder<TCoordinate, TPolyline> Create() => new();
4445

4546
/// <summary>

src/PolylineAlgorithm/Internal/FormatterRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace PolylineAlgorithm.Internal;
88
using System;
99

1010
/// <summary>
11-
/// Represents a single column rule baked into a <see cref="PolylineFormatter{T}"/>.
11+
/// Represents a single column rule baked into a <see cref="PolylineFormatter{TCoordinate, TPolyline}"/>.
1212
/// Stores the pre-calculated factor and an optional baseline alongside the user-supplied value selector.
1313
/// </summary>
1414
/// <typeparam name="T">The source object type from which the column value is extracted.</typeparam>

src/PolylineAlgorithm/PolylineDecoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class PolylineDecoder<TPolyline, TCoordinate> : IPolylineDecoder<TPolylin
3838
/// <exception cref="ArgumentNullException">
3939
/// Thrown when <paramref name="options"/> is <see langword="null"/>.
4040
/// </exception>
41+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
4142
public PolylineDecoder(PolylineOptions<TCoordinate, TPolyline> options) {
4243
if (options is null) {
4344
ExceptionGuard.ThrowArgumentNull(nameof(options));

src/PolylineAlgorithm/PolylineEncoder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class PolylineEncoder<TCoordinate, TPolyline> : IPolylineEncoder<TCoordin
4040
/// <exception cref="ArgumentNullException">
4141
/// Thrown when <paramref name="options"/> is <see langword="null"/>.
4242
/// </exception>
43+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Null is verified before use via ExceptionGuard.ThrowArgumentNull, which is annotated [DoesNotReturn]. CA1062 does not recognise custom [DoesNotReturn] helpers as null guards.")]
4344
public PolylineEncoder(PolylineOptions<TCoordinate, TPolyline> options) {
4445
if (options is null) {
4546
ExceptionGuard.ThrowArgumentNull(nameof(options));

src/PolylineAlgorithm/PolylineItemFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace PolylineAlgorithm;
1414
/// <typeparam name="T">The coordinate or item type to create.</typeparam>
1515
/// <param name="values">
1616
/// The scaled integer values accumulated from the polyline decoder. Each element corresponds to one
17-
/// column as defined by the <see cref="FormatterBuilder{T}"/> that built the associated formatter.
17+
/// column as defined by the <see cref="FormatterBuilder{TCoordinate, TPolyline}"/> that built the associated formatter.
1818
/// </param>
1919
/// <returns>A <typeparamref name="T"/> instance reconstructed from <paramref name="values"/>.</returns>
2020
public delegate T PolylineItemFactory<T>(ReadOnlySpan<long> values);

src/PolylineAlgorithm/PublicAPI.Unshipped.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,21 @@ PolylineAlgorithm.PolylineEncoder<TCoordinate, TPolyline>
3838
PolylineAlgorithm.PolylineEncoder<TCoordinate, TPolyline>.Encode(System.ReadOnlySpan<TCoordinate> coordinates, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> TPolyline
3939
PolylineAlgorithm.PolylineEncoder<TCoordinate, TPolyline>.PolylineEncoder(PolylineAlgorithm.PolylineOptions<TCoordinate, TPolyline>! options) -> void
4040
PolylineAlgorithm.Extensions.PolylineDecoderExtensions
41+
static PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode<TValue>(this PolylineAlgorithm.Abstraction.IPolylineDecoder<string!, TValue>! decoder, char[]! polyline) -> System.Collections.Generic.IEnumerable<TValue>!
42+
static PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode<TValue>(this PolylineAlgorithm.Abstraction.IPolylineDecoder<string!, TValue>! decoder, System.ReadOnlyMemory<char> polyline) -> System.Collections.Generic.IEnumerable<TValue>!
43+
static PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode<TValue>(this PolylineAlgorithm.Abstraction.IPolylineDecoder<System.ReadOnlyMemory<char>, TValue>! decoder, string! polyline) -> System.Collections.Generic.IEnumerable<TValue>!
4144
PolylineAlgorithm.Extensions.PolylineEncoderExtensions
45+
static PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode<TCoordinate, TPolyline>(this PolylineAlgorithm.Abstraction.IPolylineEncoder<TCoordinate, TPolyline>! encoder, System.Collections.Generic.List<TCoordinate>! coordinates) -> TPolyline
46+
static PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode<TCoordinate, TPolyline>(this PolylineAlgorithm.Abstraction.IPolylineEncoder<TCoordinate, TPolyline>! encoder, TCoordinate[]! coordinates) -> TPolyline
4247
PolylineAlgorithm.InvalidPolylineException
4348
PolylineAlgorithm.InvalidPolylineException.InvalidPolylineException() -> void
44-
PolylineAlgorithm.InvalidPolylineException.InvalidPolylineException(string! message) -> void
4549
PolylineAlgorithm.InvalidPolylineException.InvalidPolylineException(string! message, System.Exception! innerException) -> void
4650
PolylineAlgorithm.PolylineEncoding
51+
static PolylineAlgorithm.PolylineEncoding.Normalize(double value, uint precision = 5) -> int
52+
static PolylineAlgorithm.PolylineEncoding.Denormalize(int value, uint precision = 5) -> double
53+
static PolylineAlgorithm.PolylineEncoding.TryReadValue(ref int delta, System.ReadOnlyMemory<char> buffer, ref int position) -> bool
54+
static PolylineAlgorithm.PolylineEncoding.TryWriteValue(int delta, System.Span<char> buffer, ref int position) -> bool
55+
static PolylineAlgorithm.PolylineEncoding.GetRequiredBufferSize(int delta) -> int
56+
static PolylineAlgorithm.PolylineEncoding.ValidateFormat(System.ReadOnlySpan<char> polyline) -> void
57+
static PolylineAlgorithm.PolylineEncoding.ValidateCharRange(System.ReadOnlySpan<char> polyline) -> void
58+
static PolylineAlgorithm.PolylineEncoding.ValidateBlockLength(System.ReadOnlySpan<char> polyline) -> void

0 commit comments

Comments
 (0)