From ee34797481fa5c073ce5e6e3a23c6b4ea86b9829 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Fri, 24 Nov 2023 11:26:59 +0000 Subject: [PATCH] Update to net 8 release, remove duplicated extensions from ReactiveMarbles.Extensions ReactiveMarbles.Extensions now contains OnErrorRetry --- .github/workflows/BuildOnly.yml | 8 +-- .github/workflows/dotnet.yml | 8 +-- Directory.Build.props | 6 +- Version.json | 2 +- src/SerialPortRx/SerialPortRx.csproj | 4 +- src/SerialPortRx/SerialPortRxMixins.cs | 92 -------------------------- 6 files changed, 8 insertions(+), 112 deletions(-) diff --git a/.github/workflows/BuildOnly.yml b/.github/workflows/BuildOnly.yml index 06ee0e6..4a6b003 100644 --- a/.github/workflows/BuildOnly.yml +++ b/.github/workflows/BuildOnly.yml @@ -17,18 +17,12 @@ jobs: with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - - name: Setup .NET 6/7 + - name: Setup .NET 6/7/8 uses: actions/setup-dotnet@v3 with: dotnet-version: | 6.0.x 7.0.x - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v3 - with: - dotnet-quality: 'preview' - dotnet-version: | 8.0.x - name: Add MSBuild to PATH diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 4a70a83..3183b9a 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -17,18 +17,12 @@ jobs: with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - - name: Setup .NET 6/7 + - name: Setup .NET 6/7/8 uses: actions/setup-dotnet@v3 with: dotnet-version: | 6.0.x 7.0.x - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v3 - with: - dotnet-quality: 'preview' - dotnet-version: | 8.0.x - name: Add MSBuild to PATH diff --git a/Directory.Build.props b/Directory.Build.props index 67b1b7e..d4c2266 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,7 +14,7 @@ $(NoWarn);CS1591;IDE0190;IDE1006;SA1010 enable logo.png - Compatability with Net 6, Net 7 and netstandard2.0 + Compatability with Net 6/ 7/ 8 and netstandard2.0 SerialPort;rx;reactive;extensions;observable;LINQ;net;netstandard True latest @@ -38,7 +38,7 @@ - + @@ -55,7 +55,7 @@ - + diff --git a/Version.json b/Version.json index 319fa1b..28a6211 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": "3.0.2", + "version": "3.0.3", "nuGetPackageVersion": { "semVer": 2.0 }, diff --git a/src/SerialPortRx/SerialPortRx.csproj b/src/SerialPortRx/SerialPortRx.csproj index 1a1f9a3..f7bbc5b 100644 --- a/src/SerialPortRx/SerialPortRx.csproj +++ b/src/SerialPortRx/SerialPortRx.csproj @@ -6,8 +6,8 @@ HasWindows - - + + diff --git a/src/SerialPortRx/SerialPortRxMixins.cs b/src/SerialPortRx/SerialPortRxMixins.cs index d795112..6137a97 100644 --- a/src/SerialPortRx/SerialPortRxMixins.cs +++ b/src/SerialPortRx/SerialPortRxMixins.cs @@ -173,98 +173,6 @@ public static IObservable BufferUntil(this IObservable @this, IObs /// Observable value. public static IObservable> ErrorReceivedObserver(this SerialPort @this) => Observable.FromEventPattern(h => @this.ErrorReceived += h, h => @this.ErrorReceived -= h); - /// - /// Repeats the source observable sequence until it successfully terminates. - /// This is same as Retry(). - /// - /// The type of the source. - /// The source. - /// Observable value. - public static IObservable OnErrorRetry(this IObservable source) => source.Retry(); - - /// - /// When caught exception, do onError action and repeat observable sequence. - /// - /// The type of the source. - /// The type of the exception. - /// The source. - /// The on error. - /// Observable value. - public static IObservable OnErrorRetry(this IObservable source, Action onError) -where TException : Exception => source.OnErrorRetry(onError, TimeSpan.Zero); - - /// - /// When caught exception, do onError action and repeat observable sequence after delay time. - /// - /// The type of the source. - /// The type of the exception. - /// The source. - /// The on error. - /// The delay. - /// Observable value. - public static IObservable OnErrorRetry(this IObservable source, Action onError, TimeSpan delay) -where TException : Exception => source.OnErrorRetry(onError, int.MaxValue, delay); - - /// - /// When caught exception, do onError action and repeat observable sequence during within retryCount. - /// - /// The type of the source. - /// The type of the exception. - /// The source. - /// The on error. - /// The retry count. - /// Observable value. - public static IObservable OnErrorRetry(this IObservable source, Action onError, int retryCount) -where TException : Exception => source.OnErrorRetry(onError, retryCount, TimeSpan.Zero); - - /// - /// When caught exception, do onError action and repeat observable sequence after delay time - /// during within retryCount. - /// - /// The type of the source. - /// The type of the exception. - /// The source. - /// The on error. - /// The retry count. - /// The delay. - /// Observable value. - public static IObservable OnErrorRetry(this IObservable source, Action onError, int retryCount, TimeSpan delay) -where TException : Exception => source.OnErrorRetry(onError, retryCount, delay, Scheduler.Default); - - /// - /// When caught exception, do onError action and repeat observable sequence after delay - /// time(work on delayScheduler) during within retryCount. - /// - /// The type of the source. - /// The type of the exception. - /// The source. - /// The on error. - /// The retry count. - /// The delay. - /// The delay scheduler. - /// Observable value. - public static IObservable OnErrorRetry( - this IObservable source, Action onError, int retryCount, TimeSpan delay, IScheduler delayScheduler) - 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); - }); - - return self; - }); - /// /// Executes while port is open at the given TimeSpan. ///