From bbf72f1a445c21a8d361e641683d59097a016b63 Mon Sep 17 00:00:00 2001 From: Chris Pulman Date: Wed, 17 Oct 2018 11:16:18 +0100 Subject: [PATCH] Updated to Rx4.1.1, fixed memory leak with the IsOpen ReadOnlyReactiveProperty, Seperated into two Elements, IsOpen as a bool and IsOpenObservable as a IObservable bool --- SerialPortRx/ISerialPortRx.cs | 8 +++++++- SerialPortRx/Properties/AssemblyInfo.cs | 6 +++--- SerialPortRx/SerialPortRx.cs | 10 ++++++++-- SerialPortRx/SerialPortRx.csproj | 7 +++++-- SerialPortRx/SerialPortRx.nuspec | 4 ++-- SerialPortRx/SerialPortRxMixins.cs | 2 +- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/SerialPortRx/ISerialPortRx.cs b/SerialPortRx/ISerialPortRx.cs index 41dcaac..1df3e76 100644 --- a/SerialPortRx/ISerialPortRx.cs +++ b/SerialPortRx/ISerialPortRx.cs @@ -49,7 +49,13 @@ public interface ISerialPortRx : IDisposable /// Gets the is open. /// /// The is open. - IReadOnlyReactiveProperty IsOpen { get; } + bool IsOpen { get; } + + /// + /// Gets the is open observable. + /// + /// The is open observable. + IObservable IsOpenObservable { get; } /// /// Gets or sets the parity. diff --git a/SerialPortRx/Properties/AssemblyInfo.cs b/SerialPortRx/Properties/AssemblyInfo.cs index 682937a..ef9a045 100644 --- a/SerialPortRx/Properties/AssemblyInfo.cs +++ b/SerialPortRx/Properties/AssemblyInfo.cs @@ -3,7 +3,7 @@ [assembly: AssemblyTitle("SerialPortRx")] [assembly: AssemblyDescription("An Observable Com port extension of System.IO.Ports.SerialPort")] -[assembly: AssemblyConfiguration(".Net 4.7.1")] +[assembly: AssemblyConfiguration(".Net 4.6.1")] [assembly: AssemblyCompany("ChrisPulman")] [assembly: AssemblyProduct("SerialPortRx")] [assembly: AssemblyCopyright("Copyright © https://github.com/ChrisPulman 2018")] @@ -11,5 +11,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("cda3585b-d3d6-4be4-9a6b-582ab5de0b8f")] -[assembly: AssemblyVersion("1.2.0")] -[assembly: AssemblyFileVersion("1.2.0")] +[assembly: AssemblyVersion("1.3.0")] +[assembly: AssemblyFileVersion("1.3.0")] diff --git a/SerialPortRx/SerialPortRx.cs b/SerialPortRx/SerialPortRx.cs index 8f84097..819e40a 100644 --- a/SerialPortRx/SerialPortRx.cs +++ b/SerialPortRx/SerialPortRx.cs @@ -202,7 +202,13 @@ public SerialPortRx() /// The is open. [Browsable(true)] [MonitoringDescription("IsOpen")] - public IReadOnlyReactiveProperty IsOpen => isOpen.ToReadOnlyReactiveProperty(); + public bool IsOpen => isOpen.Value; + + /// + /// Gets the is open observable. + /// + /// The is open observable. + public IObservable IsOpenObservable => Observable.Create(obs => isOpen.Subscribe(obs)); /// /// Gets or sets the parity. @@ -309,7 +315,7 @@ from data in port.ReadExisting() }); }).OnErrorRetry((Exception ex) => errors.OnNext(ex)).Publish().RefCount(); - private IReactiveProperty isOpen { get; } = new ReactiveProperty(); + internal IReactiveProperty isOpen { get; } = new ReactiveProperty(); /// /// Closes this instance. diff --git a/SerialPortRx/SerialPortRx.csproj b/SerialPortRx/SerialPortRx.csproj index bfb314b..3b9deb6 100644 --- a/SerialPortRx/SerialPortRx.csproj +++ b/SerialPortRx/SerialPortRx.csproj @@ -9,7 +9,7 @@ Properties CP.IO.Ports SerialPortRx - v4.7.1 + v4.6.1 512 @@ -35,6 +35,9 @@ true bin\Release\SerialPortRx.XML + + true + @@ -58,7 +61,7 @@ - 5.3.0 + 5.3.2 diff --git a/SerialPortRx/SerialPortRx.nuspec b/SerialPortRx/SerialPortRx.nuspec index 73bbf50..f366f50 100644 --- a/SerialPortRx/SerialPortRx.nuspec +++ b/SerialPortRx/SerialPortRx.nuspec @@ -12,10 +12,10 @@ Copyright © $author$ 2018 https://github.com/chrispulman/SerialPortRx - + - + \ No newline at end of file diff --git a/SerialPortRx/SerialPortRxMixins.cs b/SerialPortRx/SerialPortRxMixins.cs index 457bdb2..030344a 100644 --- a/SerialPortRx/SerialPortRxMixins.cs +++ b/SerialPortRx/SerialPortRxMixins.cs @@ -261,7 +261,7 @@ public static IObservable OnErrorRetry(this IObser /// public static IObservable WhileIsOpen(this SerialPortRx @this, TimeSpan timespan) => Observable.Defer(() => Observable.Create(obs => { - var isOpen = Observable.Interval(timespan).CombineLatest(@this.IsOpen.DistinctUntilChanged(), (a, b) => b).Where(x => x); + var isOpen = Observable.Interval(timespan).CombineLatest(@this.isOpen, (a, b) => b).Where(x => x); return isOpen.Subscribe(obs); })); }