Skip to content

Conversation

@feO2x
Copy link
Owner

@feO2x feO2x commented Jul 20, 2025

Closes #118

This pull request introduces the MustHaveLengthIn assertion for ImmutableArray<T> to the Light.GuardClauses library. The changes include adding production code for the assertion, creating corresponding unit tests, and documenting the implementation details. The main goal is to provide dedicated assertions for ImmutableArray<T> to avoid boxing and ensure optimal performance.

New Assertion Implementation:

Unit Tests:

Documentation:

Minor Code Updates:

@feO2x feO2x self-assigned this Jul 20, 2025
@feO2x feO2x requested a review from Copilot July 20, 2025 20:14
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 MustHaveLengthIn assertion for ImmutableArray<T> to avoid boxing issues when using generic collection assertions. The implementation provides dedicated methods that use the Length property for optimal performance and follows the established patterns in the Light.GuardClauses library.

  • Adds two overloads of MustHaveLengthIn for ImmutableArray<T> (default exception and custom exception variants)
  • Creates a dedicated exception factory method for immutable array length validation
  • Provides comprehensive unit tests covering valid/invalid ranges, custom exceptions, and caller argument expression validation

Reviewed Changes

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

File Description
Code/Plans/issue-118-must-have-length-in-for-immutable-array.md Documentation outlining implementation requirements and tasks
Code/Light.GuardClauses/ExceptionFactory/Throw.ImmutableArrayLengthNotInRange.cs New exception factory method for immutable array length validation
Code/Light.GuardClauses/Check.MustHaveLengthIn.cs Implementation of two MustHaveLengthIn overloads for ImmutableArray<T>
Code/Light.GuardClauses.Tests/CollectionAssertions/MustHaveLengthInTests.cs Comprehensive unit tests for the new assertion methods

@feO2x feO2x merged commit 8e46099 into dev Jul 20, 2025
1 check passed
@feO2x feO2x deleted the issue-118-must-have-length-in-for-immutable-array branch July 20, 2025 20:16
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.

MustHaveLengthIn for ImmutableArray

2 participants