MustContain for immutable array #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #119
This pull request introduces a new
MustContainassertion forImmutableArray<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:
MustContainextension methods forImmutableArray<T>inCheck.MustContain.cs. The first overload supports optionalparameterNameandmessagearguments and throws aMissingItemExceptionwhen the item is not found. The second overload allows users to specify a custom exception using a delegate.Unit Tests:
MustContain: Added comprehensive unit tests for the newMustContainassertion inMustContainTests.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-119-must-contain-for-immutable-array.mddetailing the context, tasks, and notes for implementing theMustContainassertion forImmutableArray<T>. This serves as a guide for contributors and users of the library.Dependency Updates:
Check.MustContain.csandMustContainTests.csto include theSystem.Collections.Immutablenamespace, enabling the use ofImmutableArray<T>. [1] [2]