From 58f640185e1005c62570429d12f8d5e8e50ac487 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Sat, 18 Feb 2023 09:50:48 +0000 Subject: [PATCH] Correct package description add readme to package --- Directory.Build.props | 6 ++- Version.json | 2 +- src/SerialPortRx/SerialPortRxMixins.cs | 54 ++++++++++---------------- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0e92069..ca9a431 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,10 +3,11 @@ true Chris Pulman - A Reactive Property for use in cross platform applications based on ReactiveUI + A Reactive Serial Port for use in cross platform applications Copyright © https://github.com/ChrisPulman $([System.DateTime]::Now.ToString(yyyy)) $(MSBuildProjectName.Contains('Tests')) true + readme.md preview $(TargetFramework) ChrisPulman @@ -15,7 +16,7 @@ logo.png Debug;Release;PreRelease Compatability with Net 6, Net 7 and netstandard2.0 - SerialPort;reactiveui;rx;reactive;extensions;observable;LINQ;net;netstandard + SerialPort;rx;reactive;extensions;observable;LINQ;net;netstandard True latest @@ -44,6 +45,7 @@ + diff --git a/Version.json b/Version.json index de813de..7592cb8 100644 --- a/Version.json +++ b/Version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.3.2", + "version": "2.3.3", "nuGetPackageVersion": { "semVer": 2.0 }, diff --git a/src/SerialPortRx/SerialPortRxMixins.cs b/src/SerialPortRx/SerialPortRxMixins.cs index f243337..6fe4236 100644 --- a/src/SerialPortRx/SerialPortRxMixins.cs +++ b/src/SerialPortRx/SerialPortRxMixins.cs @@ -79,10 +79,7 @@ public static IObservable BufferUntil(this IObservable @this, IObs } }).AddTo(dis); - if (scheduler == null) - { - scheduler = new EventLoopScheduler(); - } + scheduler ??= new EventLoopScheduler(); Observable.Interval(TimeSpan.FromMilliseconds(1), scheduler).Subscribe(_ => { @@ -145,10 +142,7 @@ public static IObservable BufferUntil(this IObservable @this, IObs } }).AddTo(dis); - if (scheduler == null) - { - scheduler = new EventLoopScheduler(); - } + scheduler ??= new EventLoopScheduler(); Observable.Interval(TimeSpan.FromMilliseconds(1), scheduler).Subscribe(_ => { @@ -186,9 +180,7 @@ public static IObservable BufferUntil(this IObservable @this, IObs /// The this. /// Observable value. public static IObservable ForEach(this IObservable @this) => - Observable.Create(obs => - { - return @this.Subscribe( + Observable.Create(obs => @this.Subscribe( list => { foreach (var item in list) @@ -200,8 +192,7 @@ public static IObservable ForEach(this IObservable @this) => } }, obs.OnError, - obs.OnCompleted); - }); + obs.OnCompleted)); /// /// Repeats the source observable sequence until it successfully terminates. @@ -275,28 +266,25 @@ public static IObservable OnErrorRetry(this IObser /// Observable value. public static IObservable OnErrorRetry( this IObservable source, Action onError, int retryCount, TimeSpan delay, IScheduler delayScheduler) - where TException : Exception - { - return Observable.Defer(() => - { - var dueTime = (delay.Ticks < 0) ? TimeSpan.Zero : delay; - var empty = Observable.Empty(); - var count = 0; + where TException : Exception => Observable.Defer(() => + { + var dueTime = (delay.Ticks < 0) ? TimeSpan.Zero : delay; + var empty = Observable.Empty(); + var count = 0; - var self = default(IObservable)!; - self = source.Catch((TException ex) => - { - onError(ex); - return (++count < retryCount) - ? (dueTime == TimeSpan.Zero) - ? self.SubscribeOn(Scheduler.CurrentThread) - : empty.Delay(dueTime, delayScheduler).Concat(self).SubscribeOn(Scheduler.CurrentThread) - : Observable.Throw(ex); - }); + var self = default(IObservable)!; + self = source.Catch((TException ex) => + { + onError(ex); + return (++count < retryCount) + ? (dueTime == TimeSpan.Zero) + ? self.SubscribeOn(Scheduler.CurrentThread) + : empty.Delay(dueTime, delayScheduler).Concat(self).SubscribeOn(Scheduler.CurrentThread) + : Observable.Throw(ex); + }); - return self; - }); - } + return self; + }); /// /// Executes while port is open at the given TimeSpan.