Class PassThroughTransformer<T>
- Namespace
- Wolfgang.Etl.Transformers
- Assembly
- Wolfgang.Etl.Transformers.dll
A transformer that yields each item from the input sequence unchanged.
public sealed class PassThroughTransformer<T> : ITransformWithCancellationAsync<T, T>, ITransformAsync<T, T> where T : notnull
Type Parameters
TThe type of items flowing through the transformer. Must be non-null.
- Inheritance
-
PassThroughTransformer<T>
- Implements
-
ITransformWithCancellationAsync<T, T>ITransformAsync<T, T>
- Inherited Members
- Extension Methods
Examples
var transformer = new PassThroughTransformer<Customer>();
await foreach (var customer in transformer.TransformAsync(source))
{
// items are yielded unchanged
}
Remarks
PassThroughTransformer<T> is useful as:
- A placeholder in an ETL pipeline when a transformer is required by the pipeline shape but no transformation is needed.
- A default implementation in dependency injection, letting consumers swap in a real transformer later without restructuring the pipeline.
- A test seam for verifying extractor/loader behaviour without a real transformer in the way.
This class deliberately does not inherit from Wolfgang.Etl.Abstractions.TransformerBase<TSource, TDestination, TProgress>. Because it performs no work, it does not need progress reporting, skip/max item counts, or a reporting timer, and implementing the interface directly keeps the type minimal and allocation-free.
Formerly known internally as NoOpTransformer.
Constructors
PassThroughTransformer()
Initializes a new instance of the PassThroughTransformer<T> class.
public PassThroughTransformer()
Methods
TransformAsync(IAsyncEnumerable<T>)
Asynchronously yields each item from items unchanged.
public IAsyncEnumerable<T> TransformAsync(IAsyncEnumerable<T> items)
Parameters
itemsIAsyncEnumerable<T>The asynchronous source sequence.
Returns
- IAsyncEnumerable<T>
An asynchronous sequence containing the same items as
items, in the same order.
Remarks
Because no transformation is applied, this overload returns the source sequence directly
without allocating a wrapping iterator. Any cancellation must be supplied by the caller
via .WithCancellation(token) on the returned sequence, or by using the
TransformAsync(IAsyncEnumerable<T>, CancellationToken) overload.
Exceptions
- ArgumentNullException
itemsis null.
TransformAsync(IAsyncEnumerable<T>, CancellationToken)
Asynchronously yields each item from items unchanged, observing the supplied
token for cancellation.
public IAsyncEnumerable<T> TransformAsync(IAsyncEnumerable<T> items, CancellationToken token)
Parameters
itemsIAsyncEnumerable<T>The asynchronous source sequence.
tokenCancellationTokenA token to observe while enumerating the source sequence.
Returns
- IAsyncEnumerable<T>
An asynchronous sequence containing the same items as
items, in the same order.
Exceptions
- ArgumentNullException
itemsis null.- OperationCanceledException
tokenwas cancelled before or during enumeration.