<PackageReference Include="System.Reactive" Version="6.0.0-preview.16" />

SumInt32

sealed class SumInt32 : Producer<int, _>
using System.Runtime.CompilerServices; namespace System.Reactive.Linq.ObservableImpl { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] internal sealed class SumInt32 : Producer<int, SumInt32._> { [System.Runtime.CompilerServices.NullableContext(0)] internal sealed class _ : IdentitySink<int> { private int _sum; [System.Runtime.CompilerServices.NullableContext(1)] public _(IObserver<int> observer) : base(observer) { } public override void OnNext(int value) { checked { try { _sum += value; } catch (Exception error) { ForwardOnError(error); } } } public override void OnCompleted() { ForwardOnNext(_sum); ForwardOnCompleted(); } } private readonly IObservable<int> _source; public SumInt32(IObservable<int> source) { _source = source; } protected override _ CreateSink(IObserver<int> observer) { return new _(observer); } protected override void Run(_ sink) { sink.Run(_source); } } }