add internal method ToCollection() to Batch #3219
Closed
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.
related to #2361.
pulling a minor change out of #3198.
Changes
ToCollection
toBatch
Please provide a brief description of the changes here.
This change is to eliminate the
foreach
boilerplate code:For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changesOther options considered
do nothing
this will cause unit tests to have a lot of
foreach
statements.ToCollection(ICollection<T> someCollection)
I considered this but decided to imitate Enumerable.ToList which returns the collection.
ToList()
I don't have a strong opinion about the return type. I chose to return
ICollection
because I see this used more often in this repo.add extension method/class to OpenTelemetry.Tests.Shared
this would work, but is an extra file that would need to be imported into test projects.
having this method in the Batch class allows it to access private fields.