Skip to content

Conversation

@feO2x
Copy link
Owner

@feO2x feO2x commented Jul 20, 2025

Closes #116

This pull request introduces the MustNotContain assertion for ImmutableArray<T> in the Light.GuardClauses library. The changes include extending the Check.MustNotContain.cs file with two new overloads for the MustNotContain method, adding corresponding unit tests, and documenting the implementation details in a new issue plan file. Below is a breakdown of the most important changes.

Feature Addition: MustNotContain for ImmutableArray<T>

  • Production Code Changes:

    • Added two overloads of the MustNotContain method in Check.MustNotContain.cs to ensure ImmutableArray<T> does not contain a specified item. The first overload supports optional parameters (parameterName, message) and throws the default ExistingItemException. The second overload allows custom exceptions via a delegate.
  • Unit Tests:

    • Added multiple unit tests in MustNotContainTests.cs to validate the behavior of the new MustNotContain methods, including scenarios for items existing, items not existing, empty arrays, custom exceptions, and custom messages.

Documentation Update

  • Issue Plan:
    • Created a new issue plan file issue-116-must-not-contain-for-immutable-array.md to document the context, tasks, and notes related to implementing MustNotContain for ImmutableArray<T>. This includes avoiding boxing and adhering to existing library conventions.

Minor Updates

  • Namespace Import:
    • Added System.Collections.Immutable namespace to both Check.MustNotContain.cs and MustNotContainTests.cs to support ImmutableArray<T>. [1] [2]

@feO2x feO2x self-assigned this Jul 20, 2025
@feO2x feO2x requested a review from Copilot July 20, 2025 19:48
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 pull request implements the MustNotContain assertion for ImmutableArray<T> in the Light.GuardClauses library to avoid boxing when checking if an immutable array contains a specific item.

  • Added two MustNotContain overloads for ImmutableArray<T> - one with default exception handling and one with custom exception factory
  • Added comprehensive unit tests covering various scenarios including existing items, non-existing items, empty arrays, custom exceptions, and custom messages
  • Created documentation outlining the implementation requirements and rationale

Reviewed Changes

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

File Description
Code/Plans/issue-116-must-not-contain-for-immutable-array.md Added implementation plan documenting requirements and context for avoiding boxing with ImmutableArray
Code/Light.GuardClauses/Check.MustNotContain.cs Extended with two MustNotContain overloads for ImmutableArray and added System.Collections.Immutable import
Code/Light.GuardClauses.Tests/CollectionAssertions/MustNotContainTests.cs Added comprehensive unit tests for the new ImmutableArray assertions and System.Collections.Immutable import

@feO2x feO2x merged commit 963b628 into dev Jul 20, 2025
1 check passed
@feO2x feO2x deleted the issue-116-must-not-contain-for-immutable-array branch July 20, 2025 19:49
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.

MustNotContain for ImmutableArray

2 participants