diff --git a/configureawait.props b/configureawait.props index 8b0b7f593..6ba5aa116 100644 --- a/configureawait.props +++ b/configureawait.props @@ -1,7 +1,7 @@ - + All runtime; build; native; contentfiles; analyzers diff --git a/src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj b/src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj index a1e72c03e..44de7d657 100644 --- a/src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj +++ b/src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/activities/Elsa.Activities.Telnyx/Liquid/ConfigureLiquidEngine.cs b/src/activities/Elsa.Activities.Telnyx/Liquid/ConfigureLiquidEngine.cs index ec5ad1981..9aad773e8 100644 --- a/src/activities/Elsa.Activities.Telnyx/Liquid/ConfigureLiquidEngine.cs +++ b/src/activities/Elsa.Activities.Telnyx/Liquid/ConfigureLiquidEngine.cs @@ -15,7 +15,8 @@ namespace Elsa.Activities.Telnyx.Liquid public Task Handle(EvaluatingLiquidExpression notification, CancellationToken cancellationToken) { var context = notification.TemplateContext; - var memberAccessStrategy = context.MemberAccessStrategy; + var options = context.Options; + var memberAccessStrategy = options.MemberAccessStrategy; memberAccessStrategy.Register(); memberAccessStrategy.Register(); diff --git a/src/core/Elsa.Abstractions/Elsa.Abstractions.csproj b/src/core/Elsa.Abstractions/Elsa.Abstractions.csproj index a57800776..f335c39dc 100644 --- a/src/core/Elsa.Abstractions/Elsa.Abstractions.csproj +++ b/src/core/Elsa.Abstractions/Elsa.Abstractions.csproj @@ -20,15 +20,15 @@ - - + + - + diff --git a/src/core/Elsa.Core/Decorators/LockingWorkflowRunner.cs b/src/core/Elsa.Core/Decorators/LockingWorkflowRunner.cs index edb4be71b..2a644b9d3 100644 --- a/src/core/Elsa.Core/Decorators/LockingWorkflowRunner.cs +++ b/src/core/Elsa.Core/Decorators/LockingWorkflowRunner.cs @@ -32,12 +32,15 @@ namespace Elsa.Decorators { var key = $"locking-workflow-runner:{workflowInstance.Id}"; - await using var handle = await _distributedLockProvider.AcquireLockAsync(key, _elsaOptions.DistributedLockTimeout, cancellationToken); + await using (var handle = await _distributedLockProvider.AcquireLockAsync(key, _elsaOptions.DistributedLockTimeout, cancellationToken)) + { + if (handle == null) + throw new LockAcquisitionException("Could not acquire a lock within the configured amount of time"); - if (handle == null) - throw new LockAcquisitionException("Could not acquire a lock within the configured amount of time"); - - return await _workflowRunner.RunWorkflowAsync(workflowBlueprint, workflowInstance, activityId, input, cancellationToken); + workflowInstance = await _workflowRunner.RunWorkflowAsync(workflowBlueprint, workflowInstance, activityId, input, cancellationToken); + await handle.DisposeAsync(); + return workflowInstance; + } } } } \ No newline at end of file diff --git a/src/core/Elsa.Core/DistributedLockingOptions.cs b/src/core/Elsa.Core/DistributedLockingOptions.cs index 66e97ec81..b40d5620c 100644 --- a/src/core/Elsa.Core/DistributedLockingOptions.cs +++ b/src/core/Elsa.Core/DistributedLockingOptions.cs @@ -9,7 +9,7 @@ namespace Elsa { public DistributedLockingOptions() { - DistributedLockProviderFactory = sp => name => new FileDistributedLock(new DirectoryInfo(Environment.CurrentDirectory), name); + DistributedLockProviderFactory = sp => name => new FileDistributedLock(new DirectoryInfo(Path.GetTempPath()), name); } public Func> DistributedLockProviderFactory { get; set; } diff --git a/src/core/Elsa.Core/Elsa.Core.csproj b/src/core/Elsa.Core/Elsa.Core.csproj index cc0db566a..1df91af6e 100644 --- a/src/core/Elsa.Core/Elsa.Core.csproj +++ b/src/core/Elsa.Core/Elsa.Core.csproj @@ -29,7 +29,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/src/core/Elsa.Core/StartupTasks/ContinueRunningWorkflows.cs b/src/core/Elsa.Core/StartupTasks/ContinueRunningWorkflows.cs index 86d24846f..d1b372019 100644 --- a/src/core/Elsa.Core/StartupTasks/ContinueRunningWorkflows.cs +++ b/src/core/Elsa.Core/StartupTasks/ContinueRunningWorkflows.cs @@ -7,6 +7,7 @@ using Elsa.Persistence; using Elsa.Persistence.Specifications.WorkflowInstances; using Elsa.Services; using Microsoft.Extensions.Logging; +using NodaTime; using Open.Linq.AsyncExtensions; namespace Elsa.StartupTasks @@ -40,7 +41,7 @@ namespace Elsa.StartupTasks { var lockKey = GetType().Name; - await using var handle = await _distributedLockProvider.AcquireLockAsync(lockKey, default, cancellationToken); + await using var handle = await _distributedLockProvider.AcquireLockAsync(lockKey, Duration.FromSeconds(10), cancellationToken); if (handle == null) return; diff --git a/src/dashboards/blazor/ElsaDashboard.Abstractions/ElsaDashboard.Abstractions.csproj b/src/dashboards/blazor/ElsaDashboard.Abstractions/ElsaDashboard.Abstractions.csproj index 92a4a0da5..4ff2f970f 100644 --- a/src/dashboards/blazor/ElsaDashboard.Abstractions/ElsaDashboard.Abstractions.csproj +++ b/src/dashboards/blazor/ElsaDashboard.Abstractions/ElsaDashboard.Abstractions.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj b/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj index 20831a460..ca6a5cb80 100644 --- a/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj +++ b/src/dashboards/blazor/ElsaDashboard.Application/ElsaDashboard.Application.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj b/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj index 9acc6e67d..39f1080d6 100644 --- a/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj +++ b/src/dashboards/blazor/ElsaDashboard.WebAssembly/ElsaDashboard.WebAssembly.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/designer/bindings/blazor/Elsa.Designer.Bindings.Blazor/Elsa.Designer.Bindings.Blazor.csproj b/src/designer/bindings/blazor/Elsa.Designer.Bindings.Blazor/Elsa.Designer.Bindings.Blazor.csproj index c2dee2ee4..738f9287d 100644 --- a/src/designer/bindings/blazor/Elsa.Designer.Bindings.Blazor/Elsa.Designer.Bindings.Blazor.csproj +++ b/src/designer/bindings/blazor/Elsa.Designer.Bindings.Blazor/Elsa.Designer.Bindings.Blazor.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Core/Elsa.Persistence.EntityFramework.Core.csproj b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Core/Elsa.Persistence.EntityFramework.Core.csproj index 1d0afe9f7..fad3fde8b 100644 --- a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Core/Elsa.Persistence.EntityFramework.Core.csproj +++ b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Core/Elsa.Persistence.EntityFramework.Core.csproj @@ -13,10 +13,8 @@ - - - All - + + diff --git a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.PostgreSql/Elsa.Persistence.EntityFramework.PostgreSql.csproj b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.PostgreSql/Elsa.Persistence.EntityFramework.PostgreSql.csproj index 8fe83117c..832d905d0 100644 --- a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.PostgreSql/Elsa.Persistence.EntityFramework.PostgreSql.csproj +++ b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.PostgreSql/Elsa.Persistence.EntityFramework.PostgreSql.csproj @@ -17,7 +17,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.SqlServer/Elsa.Persistence.EntityFramework.SqlServer.csproj b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.SqlServer/Elsa.Persistence.EntityFramework.SqlServer.csproj index 3c4c37d1e..b1d5fbd04 100644 --- a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.SqlServer/Elsa.Persistence.EntityFramework.SqlServer.csproj +++ b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.SqlServer/Elsa.Persistence.EntityFramework.SqlServer.csproj @@ -13,11 +13,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Sqlite/Elsa.Persistence.EntityFramework.Sqlite.csproj b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Sqlite/Elsa.Persistence.EntityFramework.Sqlite.csproj index 96eb44f1f..5db82a72c 100644 --- a/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Sqlite/Elsa.Persistence.EntityFramework.Sqlite.csproj +++ b/src/persistence/Elsa.Persistence.EntityFramework/Elsa.Persistence.EntityFramework.Sqlite/Elsa.Persistence.EntityFramework.Sqlite.csproj @@ -17,11 +17,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/persistence/Elsa.Persistence.YesSql/Elsa.Persistence.YesSql.csproj b/src/persistence/Elsa.Persistence.YesSql/Elsa.Persistence.YesSql.csproj index 794d69b86..55a58b7bb 100644 --- a/src/persistence/Elsa.Persistence.YesSql/Elsa.Persistence.YesSql.csproj +++ b/src/persistence/Elsa.Persistence.YesSql/Elsa.Persistence.YesSql.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/src/persistence/Elsa.Persistence.YesSql/Migrations.cs b/src/persistence/Elsa.Persistence.YesSql/Migrations.cs index e8a8a9526..0777c3046 100644 --- a/src/persistence/Elsa.Persistence.YesSql/Migrations.cs +++ b/src/persistence/Elsa.Persistence.YesSql/Migrations.cs @@ -1,3 +1,4 @@ +using System; using System.Data; using Elsa.Persistence.YesSql.Data; using Elsa.Persistence.YesSql.Indexes; @@ -29,12 +30,12 @@ namespace Elsa.Persistence.YesSql .Column(nameof(WorkflowInstanceIndex.ContextId)) .Column(nameof(WorkflowInstanceIndex.ContextType)) .Column(nameof(WorkflowInstanceIndex.Name)) - .Column(nameof(WorkflowInstanceIndex.WorkflowStatus), DbType.String) - .Column(nameof(WorkflowInstanceIndex.CreatedAt), DbType.DateTime) - .Column(nameof(WorkflowInstanceIndex.LastExecutedAt), DbType.DateTime) - .Column(nameof(WorkflowInstanceIndex.FinishedAt), DbType.DateTime) - .Column(nameof(WorkflowInstanceIndex.CancelledAt), DbType.DateTime) - .Column(nameof(WorkflowInstanceIndex.FaultedAt), DbType.DateTime) + .Column(nameof(WorkflowInstanceIndex.WorkflowStatus)) + .Column(nameof(WorkflowInstanceIndex.CreatedAt)) + .Column(nameof(WorkflowInstanceIndex.LastExecutedAt)) + .Column(nameof(WorkflowInstanceIndex.FinishedAt)) + .Column(nameof(WorkflowInstanceIndex.CancelledAt)) + .Column(nameof(WorkflowInstanceIndex.FaultedAt)) , CollectionNames.WorkflowInstances); @@ -44,8 +45,8 @@ namespace Elsa.Persistence.YesSql .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.ActivityId)) .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.ActivityType)) .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.CorrelationId)) - .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.WorkflowStatus), DbType.String) - .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.CreatedAt), DbType.DateTime), + .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.WorkflowStatus)) + .Column(nameof(WorkflowInstanceBlockingActivitiesIndex.CreatedAt)), CollectionNames.WorkflowInstances); SchemaBuilder.CreateMapIndexTable( @@ -53,7 +54,7 @@ namespace Elsa.Persistence.YesSql .Column(nameof(WorkflowExecutionLogRecordIndex.RecordId)) .Column(nameof(WorkflowExecutionLogRecordIndex.TenantId)) .Column(nameof(WorkflowExecutionLogRecordIndex.WorkflowInstanceId)) - .Column(nameof(WorkflowExecutionLogRecordIndex.Timestamp), DbType.DateTime), + .Column(nameof(WorkflowExecutionLogRecordIndex.Timestamp)), CollectionNames.WorkflowExecutionLog); SchemaBuilder.CreateMapIndexTable( diff --git a/src/persistence/Elsa.Persistence.YesSql/Services/DataMigrationManager.cs b/src/persistence/Elsa.Persistence.YesSql/Services/DataMigrationManager.cs index 1aa0162bf..4c75b28c2 100644 --- a/src/persistence/Elsa.Persistence.YesSql/Services/DataMigrationManager.cs +++ b/src/persistence/Elsa.Persistence.YesSql/Services/DataMigrationManager.cs @@ -84,7 +84,7 @@ namespace Elsa.Persistence.YesSql.Services // Apply update methods to migration class. - var schemaBuilder = new SchemaBuilder(_store.Configuration, await _session.DemandAsync()); + var schemaBuilder = new SchemaBuilder(_store.Configuration, await _session.BeginTransactionAsync()); dataMigration.SchemaBuilder = schemaBuilder; // Copy the object for the Linq query. @@ -131,7 +131,7 @@ namespace Elsa.Persistence.YesSql.Services while (lookupTable.TryGetValue(current, out var methodInfo)) { _logger.LogInformation( - "Applying migration '{MigrationName}' from version {Version}.", + "Applying migration '{MigrationName}' from version {Version}", migrationName, current); @@ -152,11 +152,11 @@ namespace Elsa.Persistence.YesSql.Services { _logger.LogError( ex, - "Error while running migration version {Version} for '{MigrationName}'.", + "Error while running migration version {Version} for '{MigrationName}'", current, migrationName); - _session.Cancel(); + await _session.CancelAsync(); } finally { diff --git a/src/persistence/Elsa.Persistence.YesSql/Stores/YesSqlStore.cs b/src/persistence/Elsa.Persistence.YesSql/Stores/YesSqlStore.cs index 070c3e3ba..1d706ecf0 100644 --- a/src/persistence/Elsa.Persistence.YesSql/Stores/YesSqlStore.cs +++ b/src/persistence/Elsa.Persistence.YesSql/Stores/YesSqlStore.cs @@ -45,7 +45,7 @@ namespace Elsa.Persistence.YesSql.Stores var existingDocument = await FindDocumentAsync(entity, cancellationToken); var document = Mapper.Map(entity, existingDocument); Session.Save(document, CollectionName); - await Session.CommitAsync(); + await Session.SaveChangesAsync(); } finally { @@ -59,7 +59,7 @@ namespace Elsa.Persistence.YesSql.Stores { var document = Mapper.Map(entity); Session.Save(document, CollectionName); - await Session.CommitAsync(); + await Session.SaveChangesAsync(); } public async Task AddManyAsync(IEnumerable entities, CancellationToken cancellationToken = default) @@ -69,14 +69,14 @@ namespace Elsa.Persistence.YesSql.Stores foreach (var document in documents) Session.Save(document, CollectionName); - await Session.CommitAsync(); + await Session.SaveChangesAsync(); } public async Task DeleteAsync(T entity, CancellationToken cancellationToken = default) { var document = await FindDocumentAsync(entity, cancellationToken); Session.Delete(document, CollectionName); - await Session.CommitAsync(); + await Session.SaveChangesAsync(); } public async Task DeleteManyAsync(ISpecification specification, CancellationToken cancellationToken = default) @@ -95,7 +95,7 @@ namespace Elsa.Persistence.YesSql.Stores } _stopwatch.Restart(); - await Session.CommitAsync(); + await Session.SaveChangesAsync(); _stopwatch.Stop(); _logger.LogDebug("Committing deleted documents took {TimeElapsed}", _stopwatch.Elapsed); diff --git a/src/samples/aspnet/Elsa.Samples.ContextualWorkflowHttp/Elsa.Samples.ContextualWorkflowHttp.csproj b/src/samples/aspnet/Elsa.Samples.ContextualWorkflowHttp/Elsa.Samples.ContextualWorkflowHttp.csproj index 3e369fc76..e360bc82c 100644 --- a/src/samples/aspnet/Elsa.Samples.ContextualWorkflowHttp/Elsa.Samples.ContextualWorkflowHttp.csproj +++ b/src/samples/aspnet/Elsa.Samples.ContextualWorkflowHttp/Elsa.Samples.ContextualWorkflowHttp.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/samples/dashboard/ElsaDashboard.Samples.Monolith/ElsaDashboard.Samples.Monolith.csproj b/src/samples/dashboard/ElsaDashboard.Samples.Monolith/ElsaDashboard.Samples.Monolith.csproj index e4eba9a40..453cfc6e3 100644 --- a/src/samples/dashboard/ElsaDashboard.Samples.Monolith/ElsaDashboard.Samples.Monolith.csproj +++ b/src/samples/dashboard/ElsaDashboard.Samples.Monolith/ElsaDashboard.Samples.Monolith.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/samples/dashboard/ElsaDashboard.Samples.Server/ElsaDashboard.Samples.Server.csproj b/src/samples/dashboard/ElsaDashboard.Samples.Server/ElsaDashboard.Samples.Server.csproj index 39567b871..90308c975 100644 --- a/src/samples/dashboard/ElsaDashboard.Samples.Server/ElsaDashboard.Samples.Server.csproj +++ b/src/samples/dashboard/ElsaDashboard.Samples.Server/ElsaDashboard.Samples.Server.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/samples/dashboard/ElsaDashboard.Samples.WebAssembly/ElsaDashboard.Samples.WebAssembly.csproj b/src/samples/dashboard/ElsaDashboard.Samples.WebAssembly/ElsaDashboard.Samples.WebAssembly.csproj index ac0f8813c..ba3192e07 100644 --- a/src/samples/dashboard/ElsaDashboard.Samples.WebAssembly/ElsaDashboard.Samples.WebAssembly.csproj +++ b/src/samples/dashboard/ElsaDashboard.Samples.WebAssembly/ElsaDashboard.Samples.WebAssembly.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/samples/persistence/Elsa.Samples.Persistence.EntityFramework/Elsa.Samples.Persistence.EntityFramework.csproj b/src/samples/persistence/Elsa.Samples.Persistence.EntityFramework/Elsa.Samples.Persistence.EntityFramework.csproj index 141e20aea..90e039a8f 100644 --- a/src/samples/persistence/Elsa.Samples.Persistence.EntityFramework/Elsa.Samples.Persistence.EntityFramework.csproj +++ b/src/samples/persistence/Elsa.Samples.Persistence.EntityFramework/Elsa.Samples.Persistence.EntityFramework.csproj @@ -15,7 +15,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/samples/worker/Elsa.Samples.Timers.Quartz/Elsa.Samples.Timers.Quartz.csproj b/src/samples/worker/Elsa.Samples.Timers.Quartz/Elsa.Samples.Timers.Quartz.csproj index ac9ca73df..125696435 100644 --- a/src/samples/worker/Elsa.Samples.Timers.Quartz/Elsa.Samples.Timers.Quartz.csproj +++ b/src/samples/worker/Elsa.Samples.Timers.Quartz/Elsa.Samples.Timers.Quartz.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/scripting/Elsa.Scripting.Liquid/Elsa.Scripting.Liquid.csproj b/src/scripting/Elsa.Scripting.Liquid/Elsa.Scripting.Liquid.csproj index b95d424fd..6f8767c17 100644 --- a/src/scripting/Elsa.Scripting.Liquid/Elsa.Scripting.Liquid.csproj +++ b/src/scripting/Elsa.Scripting.Liquid/Elsa.Scripting.Liquid.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/scripting/Elsa.Scripting.Liquid/Extensions/TemplateContextExtensions.cs b/src/scripting/Elsa.Scripting.Liquid/Extensions/TemplateContextExtensions.cs index 47e04b27e..8e789532e 100644 --- a/src/scripting/Elsa.Scripting.Liquid/Extensions/TemplateContextExtensions.cs +++ b/src/scripting/Elsa.Scripting.Liquid/Extensions/TemplateContextExtensions.cs @@ -8,11 +8,11 @@ namespace Elsa.Scripting.Liquid.Extensions { public static class TemplateContextExtensions { - internal static void AddAsyncFilters(this TemplateContext templateContext, LiquidOptions options, IServiceProvider services) + internal static void AddFilters(this TemplateContext templateContext, LiquidOptions options, IServiceProvider services) { foreach (var registration in options.FilterRegistrations) { - templateContext.Filters.AddAsyncFilter(registration.Key, (input, arguments, ctx) => + templateContext.Options.Filters.AddFilter(registration.Key, (input, arguments, ctx) => { var filter = (ILiquidFilter) services.GetRequiredService(registration.Value); return filter.ProcessAsync(input, arguments, ctx); diff --git a/src/scripting/Elsa.Scripting.Liquid/Filters/JsonFilter.cs b/src/scripting/Elsa.Scripting.Liquid/Filters/JsonFilter.cs index 9b23c57c6..8b21e15ec 100644 --- a/src/scripting/Elsa.Scripting.Liquid/Filters/JsonFilter.cs +++ b/src/scripting/Elsa.Scripting.Liquid/Filters/JsonFilter.cs @@ -21,7 +21,7 @@ namespace Elsa.Scripting.Liquid.Filters return new ValueTask(new StringValue(JsonConvert.SerializeObject(input.ToBooleanValue()))); case FluidValues.Nil: - return new ValueTask(FluidValue.Create("null")); + return new ValueTask(FluidValue.Create("null", context.Options)); case FluidValues.Number: return new ValueTask(new StringValue(JsonConvert.SerializeObject(input.ToNumberValue()))); diff --git a/src/scripting/Elsa.Scripting.Liquid/Handlers/ConfigureLiquidEngine.cs b/src/scripting/Elsa.Scripting.Liquid/Handlers/ConfigureLiquidEngine.cs index 453debf9d..ad8747557 100644 --- a/src/scripting/Elsa.Scripting.Liquid/Handlers/ConfigureLiquidEngine.cs +++ b/src/scripting/Elsa.Scripting.Liquid/Handlers/ConfigureLiquidEngine.cs @@ -15,33 +15,31 @@ namespace Elsa.Scripting.Liquid.Handlers { public class ConfigureLiquidEngine : INotificationHandler { - static ConfigureLiquidEngine() - { - FluidValue.SetTypeMapping(x => new ObjectValue(x)); - FluidValue.SetTypeMapping(o => new ObjectValue(o)); - FluidValue.SetTypeMapping(o => FluidValue.Create(o.Value)); - } - public Task Handle(EvaluatingLiquidExpression notification, CancellationToken cancellationToken) { var context = notification.TemplateContext; + var options = context.Options; - context.MemberAccessStrategy.Register(); - context.MemberAccessStrategy.Register((x, name) => x.GetValueAsync(name)); - context.MemberAccessStrategy.Register("Input", x => ToFluidValue(x.Input)); - context.MemberAccessStrategy.Register("CorrelationId", x => ToFluidValue(x.CorrelationId)); - context.MemberAccessStrategy.Register("Variables", x => new LiquidPropertyAccessor(name => ToFluidValue(x.WorkflowExecutionContext.GetMergedVariables(), name))); - context.MemberAccessStrategy.Register("Activities", x => new LiquidPropertyAccessor(name => ToFluidValue(GetActivityModelAsync(x, name)))); - context.MemberAccessStrategy.Register("Output", GetActivityOutput); - context.MemberAccessStrategy.Register, object>((x, name) => x.GetValueAsync(name)); - context.MemberAccessStrategy.Register((x, name) => ((IDictionary) x)[name]); - context.MemberAccessStrategy.Register((source, name) => source[name]); + options.MemberAccessStrategy.Register(); + options.MemberAccessStrategy.Register(); + options.MemberAccessStrategy.Register(o => FluidValue.Create(o.Value, options)); + + options.MemberAccessStrategy.Register(); + options.MemberAccessStrategy.Register((x, name) => x.GetValueAsync(name)); + options.MemberAccessStrategy.Register("Input", x => ToFluidValue(x.Input, options)); + options.MemberAccessStrategy.Register("CorrelationId", x => ToFluidValue(x.CorrelationId, options)); + options.MemberAccessStrategy.Register("Variables", x => new LiquidPropertyAccessor(name => ToFluidValue(x.WorkflowExecutionContext.GetMergedVariables(), name, options))); + options.MemberAccessStrategy.Register("Activities", x => new LiquidPropertyAccessor(name => ToFluidValue(GetActivityModelAsync(x, name), options)!)); + options.MemberAccessStrategy.Register("Output", GetActivityOutput); + options.MemberAccessStrategy.Register, object>((x, name) => x.GetValueAsync(name)); + options.MemberAccessStrategy.Register((x, name) => ((IDictionary) x)[name]); + options.MemberAccessStrategy.Register((source, name) => source[name]); return Task.CompletedTask; } - private Task ToFluidValue(object? input) => Task.FromResult(FluidValue.Create(input)); - private Task ToFluidValue(Variables dictionary, string key) => Task.FromResult(!dictionary.Has(key) ? default : FluidValue.Create(dictionary.Get(key))); + private Task ToFluidValue(object? input, TemplateOptions options) => Task.FromResult(FluidValue.Create(input, options)); + private Task ToFluidValue(Variables dictionary, string key, TemplateOptions options) => Task.FromResult(!dictionary.Has(key) ? default : FluidValue.Create(dictionary.Get(key), options)); private LiquidActivityModel GetActivityModelAsync(ActivityExecutionContext context, string name) => new(context, name); private Task GetActivityOutput(LiquidActivityModel activityModel) diff --git a/src/scripting/Elsa.Scripting.Liquid/Services/LiquidTemplateManager.cs b/src/scripting/Elsa.Scripting.Liquid/Services/LiquidTemplateManager.cs index a4c0dbff6..d4ff35d14 100644 --- a/src/scripting/Elsa.Scripting.Liquid/Services/LiquidTemplateManager.cs +++ b/src/scripting/Elsa.Scripting.Liquid/Services/LiquidTemplateManager.cs @@ -29,7 +29,7 @@ namespace Elsa.Scripting.Liquid.Services if (string.IsNullOrWhiteSpace(source)) return default!; - context.AddAsyncFilters(_options, _serviceProvider); + context.AddFilters(_options, _serviceProvider); var result = GetCachedTemplate(source); return await result.RenderAsync(context, encoder); diff --git a/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj b/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj index 4dcdc16e2..fa7fd4acf 100644 --- a/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj +++ b/src/server/Elsa.Server.Api/Elsa.Server.Api.csproj @@ -15,12 +15,13 @@ - + - + + diff --git a/src/server/Elsa.Server.Hangfire/Elsa.Server.Hangfire.csproj b/src/server/Elsa.Server.Hangfire/Elsa.Server.Hangfire.csproj index 13d80f225..7ba506ce4 100644 --- a/src/server/Elsa.Server.Hangfire/Elsa.Server.Hangfire.csproj +++ b/src/server/Elsa.Server.Hangfire/Elsa.Server.Hangfire.csproj @@ -1,7 +1,7 @@ - - + + netstandard2.1 diff --git a/src/server/Elsa.Server.Orleans/Elsa.Server.Orleans.csproj b/src/server/Elsa.Server.Orleans/Elsa.Server.Orleans.csproj index 848f983fc..896475be9 100644 --- a/src/server/Elsa.Server.Orleans/Elsa.Server.Orleans.csproj +++ b/src/server/Elsa.Server.Orleans/Elsa.Server.Orleans.csproj @@ -1,7 +1,7 @@ - - + + net5.0 @@ -13,15 +13,15 @@ - - - + + + runtime; build; native; contentfiles; analyzers - + diff --git a/test/component/Elsa.ComponentTests/Elsa.ComponentTests.csproj b/test/component/Elsa.ComponentTests/Elsa.ComponentTests.csproj index 43f192453..e2d38de88 100644 --- a/test/component/Elsa.ComponentTests/Elsa.ComponentTests.csproj +++ b/test/component/Elsa.ComponentTests/Elsa.ComponentTests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj b/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj index dfabb319c..76ca1d91f 100644 --- a/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj +++ b/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj @@ -7,11 +7,11 @@ - - - + + + - + @@ -23,12 +23,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + diff --git a/test/shared/Elsa.Testing.Shared/Elsa.Testing.Shared.csproj b/test/shared/Elsa.Testing.Shared/Elsa.Testing.Shared.csproj index 01d7ff363..2185c9e8c 100644 --- a/test/shared/Elsa.Testing.Shared/Elsa.Testing.Shared.csproj +++ b/test/shared/Elsa.Testing.Shared/Elsa.Testing.Shared.csproj @@ -12,15 +12,15 @@ - - - + + + - + diff --git a/test/unit/Elsa.UnitTests/Elsa.UnitTests.csproj b/test/unit/Elsa.UnitTests/Elsa.UnitTests.csproj index ae9288aa8..bc77e0de7 100644 --- a/test/unit/Elsa.UnitTests/Elsa.UnitTests.csproj +++ b/test/unit/Elsa.UnitTests/Elsa.UnitTests.csproj @@ -7,10 +7,10 @@ - - - - + + + +