From 8e71c3d12fa74c5dd76692b103178713e82c1877 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Mon, 17 Aug 2020 15:13:22 +0200 Subject: [PATCH 1/2] fix: NonDisposableStream not available netcore3.1 (#263) * NonDisposableStream is not available when running Spark.Web which is a .net core 3.1 web application * Fixes TypeLoadException: "Could not load type Microsoft.AspNetCore.Mvc.Internal.NonDisposableStream from assembly Microsoft.AspNetCore.Mvc.Core." --- .../NetCore/ResourceXmlInputFormatter.cs | 2 +- src/Spark.Engine/IO/NonDisposableStream.cs | 140 ++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/Spark.Engine/IO/NonDisposableStream.cs diff --git a/src/Spark.Engine/Formatters/NetCore/ResourceXmlInputFormatter.cs b/src/Spark.Engine/Formatters/NetCore/ResourceXmlInputFormatter.cs index 653829e63..4a5baa374 100644 --- a/src/Spark.Engine/Formatters/NetCore/ResourceXmlInputFormatter.cs +++ b/src/Spark.Engine/Formatters/NetCore/ResourceXmlInputFormatter.cs @@ -3,10 +3,10 @@ using Hl7.Fhir.Serialization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.WebUtilities; using Spark.Core; using Spark.Engine.Extensions; +using Spark.Engine.IO; using System; using System.Diagnostics; using System.IO; diff --git a/src/Spark.Engine/IO/NonDisposableStream.cs b/src/Spark.Engine/IO/NonDisposableStream.cs new file mode 100644 index 000000000..e2827b42f --- /dev/null +++ b/src/Spark.Engine/IO/NonDisposableStream.cs @@ -0,0 +1,140 @@ +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +namespace Spark.Engine.IO +{ + internal class NonDisposableStream : Stream + { + private readonly Stream _innerStream; + + public NonDisposableStream(Stream innerStream) + { + _innerStream = innerStream; + } + + /// + public override bool CanRead => _innerStream.CanRead; + + /// + public override bool CanSeek => _innerStream.CanSeek; + + /// + public override bool CanWrite => _innerStream.CanWrite; + + /// + public override long Length => _innerStream.Length; + + /// + public override long Position { get => _innerStream.Position; set => _innerStream.Position = value; } + + /// + public override void Flush() + { + + } + + /// + public override int Read(byte[] buffer, int offset, int count) + { + return _innerStream.Read(buffer, offset, count); + } + + /// + public override long Seek(long offset, SeekOrigin origin) + { + return _innerStream.Seek(offset, origin); + } + + /// + public override void SetLength(long value) + { + _innerStream.SetLength(value); + } + + /// + public override void Write(byte[] buffer, int offset, int count) + { + _innerStream.Write(buffer, offset, count); + } + + /// + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return _innerStream.ReadAsync(buffer, offset, count, cancellationToken); + } + + /// + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return _innerStream.WriteAsync(buffer, offset, count, cancellationToken); + } + + /// + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return _innerStream.BeginRead(buffer, offset, count, callback, state); + } + + /// + public override int EndRead(IAsyncResult asyncResult) + { + return _innerStream.EndRead(asyncResult); + } + + /// + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + return _innerStream.BeginWrite(buffer, offset, count, callback, state); + } + + /// + public override void EndWrite(IAsyncResult asyncResult) + { + _innerStream.EndWrite(asyncResult); + } + + /// + public override bool CanTimeout => _innerStream.CanTimeout; + + /// + public override void Close() + { + // Don't want to close the underlying stream, therefore we not doing anything here + } + + /// + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) + { + return _innerStream.CopyToAsync(destination, bufferSize, cancellationToken); + } + + /// + protected override void Dispose(bool disposing) + { + // Don't want to close the underlying stream, therefore we not doing anything here + } + + /// + public override Task FlushAsync(CancellationToken cancellationToken) + { + return _innerStream.FlushAsync(cancellationToken); + } + + /// + public override int ReadByte() + { + return _innerStream.ReadByte(); + } + + /// + public override void WriteByte(byte value) + { + _innerStream.WriteByte(value); + } + + /// + public override int ReadTimeout { get => _innerStream.ReadTimeout; set => _innerStream.ReadTimeout = value; } + } +} From 613f79136cb89654ee530181333e72a4476ac556 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Mon, 17 Aug 2020 15:15:36 +0200 Subject: [PATCH 2/2] Bumped version number to v1.5.1 * Packages Spark.Engine and Spark.Mongo bumped to version 1.5.1 * Spark.Web reference implementation bumped to version 1.5.1 * Spark reference implementation bumped to 14.11.1 --- src/Spark.Engine/Spark.Engine.csproj | 2 +- src/Spark.Mongo/Spark.Mongo.csproj | 2 +- src/Spark.Web/Spark.Web.csproj | 2 +- src/Spark/Properties/AssemblyInfo.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Spark.Engine/Spark.Engine.csproj b/src/Spark.Engine/Spark.Engine.csproj index 8ad7251b5..9053b9f4d 100644 --- a/src/Spark.Engine/Spark.Engine.csproj +++ b/src/Spark.Engine/Spark.Engine.csproj @@ -3,7 +3,7 @@ netstandard2.0;net461 Spark.Engine.DSTU2 - 1.5.0 + 1.5.1 Copyright © Firely 2014, © Kufu 2018 Firely and Kufu Firely, Kufu and contributors diff --git a/src/Spark.Mongo/Spark.Mongo.csproj b/src/Spark.Mongo/Spark.Mongo.csproj index 4c42bc923..91bf3e407 100644 --- a/src/Spark.Mongo/Spark.Mongo.csproj +++ b/src/Spark.Mongo/Spark.Mongo.csproj @@ -3,7 +3,7 @@ netstandard2.0 Spark.Mongo.DSTU2 - 1.5.0 + 1.5.1 Copyright © Firely 2014, © Kufu 2018 Kufu Firely, Kufu and contributors diff --git a/src/Spark.Web/Spark.Web.csproj b/src/Spark.Web/Spark.Web.csproj index 1d749a6dd..5210b8a08 100644 --- a/src/Spark.Web/Spark.Web.csproj +++ b/src/Spark.Web/Spark.Web.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 AspNetCoreModuleV2 a4d3c2a3-5edd-47d1-8407-62489d5568c5 - 1.5.0 + 1.5.1 diff --git a/src/Spark/Properties/AssemblyInfo.cs b/src/Spark/Properties/AssemblyInfo.cs index 3145d94d6..7892100d1 100644 --- a/src/Spark/Properties/AssemblyInfo.cs +++ b/src/Spark/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("14.11.0.0")] +[assembly: AssemblyVersion("14.12.0.0")]