Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch MemoryStream to Microsoft.IO.RecyclableMemoryStream. #6093

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite.Design" Version="1.1.6" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.1" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.25.0" />
Expand Down
15 changes: 11 additions & 4 deletions Elsa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Workflows.PerformanceT
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "retention", "retention", "{3F20899B-C5E1-485F-808B-ADB1877EB3FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Retention", "src\modules\Elsa.Retention\Elsa.Retention.csproj", "{3D42FCA2-5BD0-4624-9FCA-F4BF935B27AE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Retention", "src\modules\Elsa.Retention\Elsa.Retention.csproj", "{3D42FCA2-5BD0-4624-9FCA-F4BF935B27AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MongoDb.UnitTests", "test\unit\Elsa.MongoDb.UnitTests\Elsa.MongoDb.UnitTests.csproj", "{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.MongoDb.UnitTests", "test\unit\Elsa.MongoDb.UnitTests\Elsa.MongoDb.UnitTests.csproj", "{56CAA9F2-1882-4EFA-BAC0-9C3D804553F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Workflows.Runtime.Distributed", "src\modules\Elsa.Workflows.Runtime.Distributed\Elsa.Workflows.Runtime.Distributed.csproj", "{0D4A88A1-8AEE-49ED-BC2E-ED68C96F60AD}"
EndProject
Expand Down Expand Up @@ -381,7 +381,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "multitenancy", "multitenanc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Tenants.AspNetCore", "src\modules\Elsa.Tenants.AspNetCore\Elsa.Tenants.AspNetCore.csproj", "{D5720DBC-8C2B-42D5-9D9F-2FF6EAD4001C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql", "src\modules\Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql\Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql.csproj", "{2B939AC9-03A4-479E-AA0D-CB58F4A7F480}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql", "src\modules\Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql\Elsa.Agents.Persistence.EntityFrameworkCore.PostgreSql.csproj", "{2B939AC9-03A4-479E-AA0D-CB58F4A7F480}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Helpers", "src\common\Elsa.Helpers\Elsa.Helpers.csproj", "{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -815,6 +817,10 @@ Global
{2B939AC9-03A4-479E-AA0D-CB58F4A7F480}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B939AC9-03A4-479E-AA0D-CB58F4A7F480}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B939AC9-03A4-479E-AA0D-CB58F4A7F480}.Release|Any CPU.Build.0 = Release|Any CPU
{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -921,6 +927,7 @@ Global
{690B0274-291F-4D9E-BA76-54EFF7D3E4BC} = {D92BEAB2-60D6-4BB4-885A-6BA681C6CCF1}
{060FD0BA-BD78-48E1-A8A7-4906A5AD5E39} = {D92BEAB2-60D6-4BB4-885A-6BA681C6CCF1}
{169A82A5-2DB3-40EA-801E-14C08D743DF7} = {D92BEAB2-60D6-4BB4-885A-6BA681C6CCF1}
{2CDF3E1C-267D-4198-B1C7-7E1F548FC120} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{01B96BB9-35E8-4364-ACB8-6D12A14D8DBA} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{47FBCB04-0C2D-453C-BE2F-7052CAC22524} = {EB3A7401-0DE3-476F-9E6F-057F1F4590FB}
{B32DB9B2-AD6C-48A5-8682-4373CB045185} = {C80C8231-D35C-4ACC-9ED6-9F3DB221535E}
Expand Down Expand Up @@ -958,7 +965,7 @@ Global
{2F3E1026-5054-4E1F-899B-F1A7F70F9912} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{D5720DBC-8C2B-42D5-9D9F-2FF6EAD4001C} = {2F3E1026-5054-4E1F-899B-F1A7F70F9912}
{2B939AC9-03A4-479E-AA0D-CB58F4A7F480} = {50470834-4CD8-479A-8B58-0A1869BA5D37}
{2CDF3E1C-267D-4198-B1C7-7E1F548FC120} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{4F159759-B22F-4DA6-BDDF-686E7AD0C9EB} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4B5CEAA-7D70-4FCB-A68E-B03FBE5E0E5E}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using System.Runtime.Loader;
using Elsa.Helpers;
using NuGet.Packaging;

namespace Elsa.DropIns.Contexts;
Expand All @@ -15,7 +16,7 @@ public NuGetPackageAssemblyLoadContext(string nugetPackagePath)
foreach (var dllFile in packageReader.GetFiles().Where(fileName => fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)))
{
using var dllStream = packageReader.GetStream(dllFile);
using var memoryStream = new MemoryStream();
using var memoryStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.DropIns.Contexts.NuGetPackageAssemblyLoadContext));
dllStream.CopyTo(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
var assembly = LoadFromStream(memoryStream);
Expand Down
5 changes: 2 additions & 3 deletions src/common/Elsa.DropIns/Elsa.DropIns.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>
Expand All @@ -19,11 +19,10 @@

<!--Overridden
for vulnerability reasons with dependencies referencing older versions.-->
<ItemGroup>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elsa.DropIns.Core\Elsa.DropIns.Core.csproj" />
<ProjectReference Include="..\Elsa.Helpers\Elsa.Helpers.csproj" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/common/Elsa.DropIns/Helpers/AssemblyLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;
using System.Runtime.Loader;
using Elsa.DropIns.Contexts;
using Elsa.Helpers;

namespace Elsa.DropIns.Helpers;

Expand All @@ -13,7 +14,7 @@ public static Assembly LoadPath(string path)

// Copy drop in to memory stream to avoid file locking
using var fileStream = File.OpenRead(path);
using var memoryStream = new MemoryStream();
using var memoryStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.DropIns.Helpers.AssemblyLoader.LoadPath));
fileStream.CopyTo(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
fileStream.Close();
Expand Down
14 changes: 14 additions & 0 deletions src/common/Elsa.Helpers/Elsa.Helpers.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>
Provides static helper functions.
</Description>
<PackageTags>elsa common</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/common/Elsa.Helpers/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>
32 changes: 32 additions & 0 deletions src/common/Elsa.Helpers/StreamHelpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.IO;

namespace Elsa.Helpers;

public static class StreamHelpers
{
private static RecyclableMemoryStreamManager? _recyclableMemoryStreamManager;

public static RecyclableMemoryStreamManager RecyclableMemoryStreamManager
{
get => _recyclableMemoryStreamManager ?? new(new RecyclableMemoryStreamManager.Options()
{
BlockSize = RecyclableMemoryStreamManager.DefaultBlockSize,
LargeBufferMultiple = RecyclableMemoryStreamManager.DefaultLargeBufferMultiple,
MaximumBufferSize = RecyclableMemoryStreamManager.DefaultMaximumBufferSize,
GenerateCallStacks = false,
AggressiveBufferReturn = false,
MaximumLargePoolFreeBytes = 16 * 1024 * 1024 * 4,
MaximumSmallPoolFreeBytes = 100 * 1024
});

set
{
if (_recyclableMemoryStreamManager is not null)
{
return;
}

_recyclableMemoryStreamManager = value;
}
}
}
11 changes: 7 additions & 4 deletions src/modules/Elsa.FileStorage/Activities/SaveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO.Compression;
using System.Text;
using Elsa.Extensions;
using Elsa.Helpers;
using Elsa.Workflows;
using Elsa.Workflows.Attributes;
using Elsa.Workflows.Models;
Expand Down Expand Up @@ -45,19 +46,20 @@ protected override async ValueTask ExecuteAsync(ActivityExecutionContext context
await blobStorage.WriteAsync(path, data, append, cancellationToken);
}

// Returned streams are not disposed by the caller. Potential memory leak?!
private async Task<Stream> ResolveAsStreamAsync(object data, CancellationToken cancellationToken)
{
if(data is Stream stream)
return stream;

if(data is byte[] bytes)
return new MemoryStream(bytes);
return StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.FileStorage.Activities.SaveFile.ResolveAsStreamAsync), bytes);

if(data is IFormFile formFile)
return formFile.OpenReadStream();

if(data is string stringData)
return new MemoryStream(Encoding.UTF8.GetBytes(stringData));
return StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.FileStorage.Activities.SaveFile.ResolveAsStreamAsync), Encoding.UTF8.GetBytes(stringData));

if (data is IEnumerable enumerable)
{
Expand All @@ -67,11 +69,12 @@ private async Task<Stream> ResolveAsStreamAsync(object data, CancellationToken c

throw new NotSupportedException($"The provided data type is not supported: {data.GetType().Name}");
}


// Returned streams are not disposed by the caller. Potential memory leak?!
private async Task<Stream> CreateZipArchiveAsync(IEnumerable files, CancellationToken cancellationToken = default)
{
var currentFileIndex = 0;
var zipStream = new MemoryStream();
var zipStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.FileStorage.Activities.SaveFile.CreateZipArchiveAsync));
var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true);

foreach (var file in files)
Expand Down
5 changes: 3 additions & 2 deletions src/modules/Elsa.FileStorage/Elsa.FileStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Management\Elsa.Workflows.Management.csproj" />
<ProjectReference Include="..\..\common\Elsa.Helpers\Elsa.Helpers.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Management\Elsa.Workflows.Management.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Elsa.Helpers;
using Elsa.Http.Abstractions;
using Elsa.Http.Contexts;

Expand All @@ -15,9 +16,10 @@ public class BinaryDownloadableContentHandler : DownloadableContentHandlerBase
protected override Downloadable GetDownloadable(DownloadableContext context)
{
var bytes = (byte[]) context.Content;
var stream = new MemoryStream(bytes);
var stream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Http.DownloadableContentHandlers.BinaryDownloadableContentHandler.GetDownloadable), bytes);
var fileName = "file.bin";
var contentType = "application/octet-stream";
return new(stream, fileName, contentType);
// Returned streams are not disposed by the caller. Potential memory leak?! Dowloadable should implement IDisposable and dispose the stream.
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using Elsa.Helpers;
using Elsa.Http.Abstractions;
using Elsa.Http.Contexts;

Expand All @@ -15,7 +16,8 @@ public class StringDownloadableContentHandler : DownloadableContentHandlerBase
/// <inheritdoc />
protected override Downloadable GetDownloadable(DownloadableContext context)
{
var stream = new MemoryStream(Encoding.UTF8.GetBytes((string)context.Content));
var stream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Http.DownloadableContentHandlers.StringDownloadableContentHandler.GetDownloadable), Encoding.UTF8.GetBytes((string)context.Content));
return new(stream, "file.txt", "text/plain");
// Returned streams are not disposed by the caller. Potential memory leak?! Dowloadable should implement IDisposable and dispose the stream.
}
}
1 change: 1 addition & 0 deletions src/modules/Elsa.Http/Elsa.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Helpers\Elsa.Helpers.csproj" />
<ProjectReference Include="..\Elsa.Liquid\Elsa.Liquid.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Runtime.ProtoActor\Elsa.Workflows.Runtime.ProtoActor.csproj" />
<ProjectReference Include="..\Elsa.SasTokens\Elsa.SasTokens.csproj" />
Expand Down
4 changes: 3 additions & 1 deletion src/modules/Elsa.Http/Models/HttpFile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Net.Http.Headers;
using System.Text.Json.Serialization;
using Elsa.Helpers;
using FluentStorage.Utils.Extensions;

namespace Elsa.Http;

Expand Down Expand Up @@ -56,7 +58,7 @@ public HttpFile(Stream stream, string? filename = default, string? contentType =
/// </summary>
public byte[] GetBytes()
{
using var memoryStream = new MemoryStream();
using var memoryStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Http.HttpFile.GetBytes), Stream.Length);
if (Stream.CanSeek) Stream.Seek(0, SeekOrigin.Begin);
Stream.CopyTo(memoryStream);
return memoryStream.ToArray();
Expand Down
1 change: 1 addition & 0 deletions src/modules/Elsa.Workflows.Api/Elsa.Workflows.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Api.Common\Elsa.Api.Common.csproj" />
<ProjectReference Include="..\..\common\Elsa.Helpers\Elsa.Helpers.csproj" />
<ProjectReference Include="..\Elsa.Http\Elsa.Http.csproj" />
<ProjectReference Include="..\Elsa.JavaScript\Elsa.JavaScript.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Management\Elsa.Workflows.Management.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Buffers;
using System.IO.Compression;
using System.Text.Json;
using Elsa.Abstractions;
using Elsa.Common.Models;
using Elsa.Helpers;
using Elsa.Workflows.Management;
using Elsa.Workflows.Management.Entities;
using Elsa.Workflows.Management.Filters;
Expand Down Expand Up @@ -65,7 +67,8 @@ private async Task DownloadMultipleWorkflowsAsync(ICollection<string> ids, Cance
return;
}

var zipStream = new MemoryStream();
// Stream is not disposed. Potential memory leak?!
var zipStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Export.Export.DownloadMultipleWorkflowsAsync));
using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
{
// Create a JSON file for each workflow definition:
Expand Down Expand Up @@ -121,8 +124,8 @@ private async Task<byte[]> SerializeWorkflowDefinitionAsync(WorkflowDefinitionMo
var document = JsonSerializer.SerializeToDocument(model, serializerOptions);
var rootElement = document.RootElement;

using var output = new MemoryStream();
await using var writer = new Utf8JsonWriter(output);
using var output = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Export.Export.SerializeWorkflowDefinitionAsync));
await using var writer = new Utf8JsonWriter((IBufferWriter<byte>)output);

writer.WriteStartObject();
writer.WriteString("$schema", "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Elsa.Abstractions;
using Elsa.Common.Entities;
using Elsa.Common.Models;
using Elsa.Helpers;
using Elsa.Workflows.Api.Endpoints.WorkflowInstances.Get;
using Elsa.Workflows.Api.Models;
using Elsa.Workflows.Management;
Expand Down Expand Up @@ -77,7 +78,8 @@ private async Task DownloadMultipleInstancesAsync(Request request, CancellationT
return;
}

var zipStream = new MemoryStream();
// Streams is not disposed. Potential memory leak?!
var zipStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Api.Endpoints.WorkflowInstances.Export.Export.DownloadMultipleInstancesAsync));
using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
{
// Create a JSON file for each workflow definition:
Expand All @@ -94,6 +96,8 @@ private async Task DownloadMultipleInstancesAsync(Request request, CancellationT

// Send the zip file to the client:
zipStream.Position = 0;

// This could be optimized by using the SendStreamAsync function and the zipStream stream instead of a byte array.
await SendBytesAsync(zipStream.ToArray(), "workflow-instances.zip", cancellation: cancellationToken);
}

Expand Down
7 changes: 4 additions & 3 deletions src/modules/Elsa.Workflows.Management/Compression/GZip.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO.Compression;
using System.Text;
using Elsa.Helpers;

namespace Elsa.Workflows.Management.Compression;

Expand All @@ -12,7 +13,7 @@ public class GZip : ICompressionCodec
public async ValueTask<string> CompressAsync(string input, CancellationToken cancellationToken)
{
var inputBytes = Encoding.UTF8.GetBytes(input);
using var output = new MemoryStream();
using var output = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Management.Compression.GZip.CompressAsync));
await using var compressionStream = new GZipStream(output, CompressionMode.Compress);
await compressionStream.WriteAsync(inputBytes, 0, inputBytes.Length, cancellationToken);
await compressionStream.FlushAsync(cancellationToken);
Expand All @@ -24,9 +25,9 @@ public async ValueTask<string> CompressAsync(string input, CancellationToken can
public async ValueTask<string> DecompressAsync(string input, CancellationToken cancellationToken)
{
var inputBytes = Convert.FromBase64String(input);
using var inputMemoryStream = new MemoryStream(inputBytes);
using var inputMemoryStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Management.Compression.GZip.DecompressAsync), inputBytes);
await using var decompressionStream = new GZipStream(inputMemoryStream, CompressionMode.Decompress);
using var outputMemoryStream = new MemoryStream();
using var outputMemoryStream = StreamHelpers.RecyclableMemoryStreamManager.GetStream(nameof(Elsa.Workflows.Management.Compression.GZip.DecompressAsync));
await decompressionStream.CopyToAsync(outputMemoryStream, cancellationToken);
var decompressedBytes = outputMemoryStream.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ItemGroup>
<ProjectReference Include="..\..\common\Elsa.Api.Common\Elsa.Api.Common.csproj" />
<ProjectReference Include="..\..\common\Elsa.Helpers\Elsa.Helpers.csproj" />
<ProjectReference Include="..\Elsa.Caching\Elsa.Caching.csproj" />
<ProjectReference Include="..\Elsa.Dsl\Elsa.Dsl.csproj" />
<ProjectReference Include="..\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj" />
Expand Down
Loading