feat: Add ability to override enumerable builder values #1506
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.
What does this PR do?
This PR introduces two new types to the builder API for resource configuration:
ComposableEnumerable<T>andComposableDictionary<TKey, TValue>. These types give developers the ability to override pre-configured values, something that wasn’t previously possible.In Testcontainers for .NET, builders are immutable and modules come with opinionated, pre-configured defaults. Some builder APIs only allow extending existing configurations. You couldn't override or completely remove settings that were already defined.
These two new types address that limitation by adding override support to selected APIs.
We're starting with the new
WithCommand(ComposableEnumerable<string>)API. This gives developers more flexible control over container command arguments that are pre-configured by default.For example, to remove all default command arguments:
You can also replace the default command with specific values by passing them instead of
Array.Empty<string>(), or append additional commands using regularWithCommand(string)calls.Also, you can implement your own behavior by inheriting from the base class and customizing it.
Why is it important?
-
Related issues