Skip to content

Conversation

@feO2x
Copy link
Owner

@feO2x feO2x commented Jul 21, 2025

Closes #121

Production Code

Throw.InvalidMinimumImmutableArrayLength.cs
Exception factory method that creates appropriate error messages for minimum length violations, handling both regular and default ImmutableArray instances.

Check.MustHaveMinimumLength.cs

Two extension method overloads:

  • First overload: Takes parameterName and message parameters, throws InvalidCollectionCountException
  • Second overload: Takes custom exception factory delegate for custom exceptions

Both methods use parameter.IsDefault check to safely handle default instances (treats as length 0).

feO2x added 3 commits July 21, 2025 08:36
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
@feO2x feO2x self-assigned this Jul 21, 2025
@feO2x feO2x requested a review from Copilot July 21, 2025 06:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the MustHaveMinimumLength assertion for ImmutableArray<T> to avoid boxing that would occur with generic IEnumerable<T> extensions. The implementation includes proper handling of default immutable array instances and follows the existing library patterns.

  • Adds exception factory method for minimum length violations with appropriate error messages
  • Implements two extension method overloads following the library's standard pattern (default exception and custom exception factory)
  • Includes comprehensive test coverage for all scenarios including edge cases with default instances

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
issue-121-must-have-minimum-length-for-immutable-array.md Planning document outlining implementation requirements
Throw.InvalidMinimumImmutableArrayLength.cs Exception factory method for minimum length validation errors
Check.MustHaveMinimumLength.cs Extension methods implementing the minimum length assertion
MustHaveMinimumLengthTests.cs Comprehensive test suite covering all scenarios and edge cases

@feO2x feO2x merged commit 638da53 into dev Jul 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MustHaveMinimumLength for ImmutableArray

2 participants