Skip to content

Conversation

@feO2x
Copy link
Owner

@feO2x feO2x commented Jul 21, 2025

Closes #119

This pull request introduces a new MustContain assertion for ImmutableArray<T> to avoid boxing and improve performance when working with immutable arrays in the Light.GuardClauses library. It includes updates to both production code and corresponding unit tests, as well as documentation for the new feature. The most important changes are summarized below.

New Feature Implementation:

  • Production Code: Added two MustContain extension methods for ImmutableArray<T> in Check.MustContain.cs. The first overload supports optional parameterName and message arguments and throws a MissingItemException when the item is not found. The second overload allows users to specify a custom exception using a delegate.

Unit Tests:

  • Tests for MustContain: Added comprehensive unit tests for the new MustContain assertion in MustContainTests.cs. These tests cover scenarios such as the item being present or absent in the array, handling empty arrays, custom exceptions, and custom messages.

Documentation:

  • Issue Documentation: Added a new markdown file issue-119-must-contain-for-immutable-array.md detailing the context, tasks, and notes for implementing the MustContain assertion for ImmutableArray<T>. This serves as a guide for contributors and users of the library.

Dependency Updates:

  • Namespace Addition: Updated Check.MustContain.cs and MustContainTests.cs to include the System.Collections.Immutable namespace, enabling the use of ImmutableArray<T>. [1] [2]

feO2x added 2 commits July 21, 2025 06:53
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 04:55
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 introduces a new MustContain assertion for ImmutableArray<T> to avoid boxing and improve performance when working with immutable arrays in the Light.GuardClauses library.

  • Adds two MustContain extension method overloads for ImmutableArray<T> with support for both default and custom exception handling
  • Includes comprehensive unit tests covering various scenarios including empty arrays, custom exceptions, and custom messages
  • Provides documentation detailing the implementation requirements and context for the new feature

Reviewed Changes

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

File Description
issue-119-must-contain-for-immutable-array.md Documentation outlining implementation tasks and requirements for the new feature
Check.MustContain.cs Adds two MustContain extension methods for ImmutableArray<T> with default and custom exception support
MustContainTests.cs Comprehensive unit tests for the new MustContain methods covering edge cases and validation scenarios

remove duplicate bullet point in plan for issue 119

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@feO2x feO2x merged commit 540cdbb into dev Jul 21, 2025
1 check passed
@feO2x feO2x deleted the issue-119-must-contain-for-immutable-array branch July 21, 2025 04:57
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.

MustContain for ImmutableArray

2 participants