Skip to content

Commit

Permalink
Update to net 8 release, remove duplicated extensions from ReactiveMa…
Browse files Browse the repository at this point in the history
…rbles.Extensions

ReactiveMarbles.Extensions now contains OnErrorRetry
  • Loading branch information
ChrisPulman committed Nov 24, 2023
1 parent c4311c2 commit ee34797
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 112 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/BuildOnly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<NoWarn>$(NoWarn);CS1591;IDE0190;IDE1006;SA1010</NoWarn>
<Nullable>enable</Nullable>
<PackageIcon>logo.png</PackageIcon>
<PackageReleaseNotes>Compatability with Net 6, Net 7 and netstandard2.0</PackageReleaseNotes>
<PackageReleaseNotes>Compatability with Net 6/ 7/ 8 and netstandard2.0</PackageReleaseNotes>
<PackageTags>SerialPort;rx;reactive;extensions;observable;LINQ;net;netstandard</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
Expand All @@ -38,7 +38,7 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand All @@ -55,7 +55,7 @@
<!--<Compile Update="**\*.cs" DependentUpon="I%(Filename).cs" />-->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.2" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.4" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Version.json
Original file line number Diff line number Diff line change
@@ -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
},
Expand Down
4 changes: 2 additions & 2 deletions src/SerialPortRx/SerialPortRx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<DefineConstants>HasWindows</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ReactiveMarbles.Extensions" Version="1.1.7" />
<PackageReference Include="System.IO.Ports" Version="8.0.0-rc.2.23479.6" />
<PackageReference Include="ReactiveMarbles.Extensions" Version="1.1.8" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
92 changes: 0 additions & 92 deletions src/SerialPortRx/SerialPortRxMixins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,98 +173,6 @@ public static IObservable<string> BufferUntil(this IObservable<char> @this, IObs
/// <returns>Observable value.</returns>
public static IObservable<EventPattern<SerialErrorReceivedEventArgs>> ErrorReceivedObserver(this SerialPort @this) => Observable.FromEventPattern<SerialErrorReceivedEventHandler, SerialErrorReceivedEventArgs>(h => @this.ErrorReceived += h, h => @this.ErrorReceived -= h);

/// <summary>
/// <para>Repeats the source observable sequence until it successfully terminates.</para>
/// <para>This is same as Retry().</para>
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <param name="source">The source.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource>(this IObservable<TSource> source) => source.Retry();

/// <summary>
/// When caught exception, do onError action and repeat observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <typeparam name="TException">The type of the exception.</typeparam>
/// <param name="source">The source.</param>
/// <param name="onError">The on error.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource, TException>(this IObservable<TSource> source, Action<TException> onError)
where TException : Exception => source.OnErrorRetry(onError, TimeSpan.Zero);

/// <summary>
/// When caught exception, do onError action and repeat observable sequence after delay time.
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <typeparam name="TException">The type of the exception.</typeparam>
/// <param name="source">The source.</param>
/// <param name="onError">The on error.</param>
/// <param name="delay">The delay.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource, TException>(this IObservable<TSource> source, Action<TException> onError, TimeSpan delay)
where TException : Exception => source.OnErrorRetry(onError, int.MaxValue, delay);

/// <summary>
/// When caught exception, do onError action and repeat observable sequence during within retryCount.
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <typeparam name="TException">The type of the exception.</typeparam>
/// <param name="source">The source.</param>
/// <param name="onError">The on error.</param>
/// <param name="retryCount">The retry count.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource, TException>(this IObservable<TSource> source, Action<TException> onError, int retryCount)
where TException : Exception => source.OnErrorRetry(onError, retryCount, TimeSpan.Zero);

/// <summary>
/// When caught exception, do onError action and repeat observable sequence after delay time
/// during within retryCount.
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <typeparam name="TException">The type of the exception.</typeparam>
/// <param name="source">The source.</param>
/// <param name="onError">The on error.</param>
/// <param name="retryCount">The retry count.</param>
/// <param name="delay">The delay.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource, TException>(this IObservable<TSource> source, Action<TException> onError, int retryCount, TimeSpan delay)
where TException : Exception => source.OnErrorRetry(onError, retryCount, delay, Scheduler.Default);

/// <summary>
/// When caught exception, do onError action and repeat observable sequence after delay
/// time(work on delayScheduler) during within retryCount.
/// </summary>
/// <typeparam name="TSource">The type of the source.</typeparam>
/// <typeparam name="TException">The type of the exception.</typeparam>
/// <param name="source">The source.</param>
/// <param name="onError">The on error.</param>
/// <param name="retryCount">The retry count.</param>
/// <param name="delay">The delay.</param>
/// <param name="delayScheduler">The delay scheduler.</param>
/// <returns>Observable value.</returns>
public static IObservable<TSource> OnErrorRetry<TSource, TException>(
this IObservable<TSource> source, Action<TException> onError, int retryCount, TimeSpan delay, IScheduler delayScheduler)
where TException : Exception => Observable.Defer(() =>
{
var dueTime = (delay.Ticks < 0) ? TimeSpan.Zero : delay;
var empty = Observable.Empty<TSource>();
var count = 0;

var self = default(IObservable<TSource>)!;
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<TSource>(ex);
});

return self;
});

/// <summary>
/// Executes while port is open at the given TimeSpan.
/// </summary>
Expand Down

0 comments on commit ee34797

Please sign in to comment.