diff --git a/src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs b/src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs
index 8b302ab0b..75f7d9644 100644
--- a/src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs
+++ b/src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs
@@ -137,7 +137,7 @@ public static class ObjectConverter
return Enum.ToObject(underlyingTargetType, value);
if (underlyingSourceType == typeof(double))
- return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int)));
+ return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int), CultureInfo.InvariantCulture));
}
if (value is string s)
@@ -178,7 +178,7 @@ public static class ObjectConverter
try
{
- return Convert.ChangeType(value, underlyingTargetType);
+ return Convert.ChangeType(value, underlyingTargetType, CultureInfo.InvariantCulture);
}
catch (InvalidCastException)
{
diff --git a/src/clients/Elsa.Api.Client/IsExternalInit.cs b/src/clients/Elsa.Api.Client/IsExternalInit.cs
index c3a98e575..653e3c181 100644
--- a/src/clients/Elsa.Api.Client/IsExternalInit.cs
+++ b/src/clients/Elsa.Api.Client/IsExternalInit.cs
@@ -4,4 +4,4 @@ using System.ComponentModel;
namespace System.Runtime.CompilerServices;
[EditorBrowsable(EditorBrowsableState.Never)]
-internal class IsExternalInit{}
\ No newline at end of file
+internal sealed class IsExternalInit;
\ No newline at end of file
diff --git a/src/clients/Elsa.Api.Client/Resources/ActivityDescriptorOptions/Requests/GetActivityDescriptorOptionsRequest.cs b/src/clients/Elsa.Api.Client/Resources/ActivityDescriptorOptions/Requests/GetActivityDescriptorOptionsRequest.cs
index 6d1725249..7897cef6f 100644
--- a/src/clients/Elsa.Api.Client/Resources/ActivityDescriptorOptions/Requests/GetActivityDescriptorOptionsRequest.cs
+++ b/src/clients/Elsa.Api.Client/Resources/ActivityDescriptorOptions/Requests/GetActivityDescriptorOptionsRequest.cs
@@ -8,5 +8,5 @@ public class GetActivityDescriptorOptionsRequest
///
/// Object context use to pass custom information
///
- public object? Context { get; set; } = default;
+ public object? Context { get; set; }
}
\ No newline at end of file
diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs
index f3fe5d0eb..4a6ddb194 100644
--- a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs
+++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs
@@ -81,5 +81,5 @@ public class WorkflowDefinition : LinkedEntity
///
/// An option to use the workflow as a readonly workflow.
///
- public bool IsReadonly { get; set; } = false;
+ public bool IsReadonly { get; set; }
}
\ No newline at end of file
diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Models/Bookmark.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Models/Bookmark.cs
index f4a48d1bf..40f7f62dd 100644
--- a/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Models/Bookmark.cs
+++ b/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Models/Bookmark.cs
@@ -12,8 +12,9 @@ namespace Elsa.Api.Client.Resources.WorkflowInstances.Models;
/// The data associated with the bookmark.
/// The ID of the activity node associated with the bookmark.
/// The ID of the activity instance associated with the bookmark.
-/// Whether or not the bookmark should be automatically burned.
+/// Whether the bookmark should be automatically burned.
/// The name of the method on the activity class to invoke when the bookmark is resumed.
+/// The metadata associated with this bookmark.
[PublicAPI]
public record Bookmark(
string Id,
diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Responses/BulkDeleteWorkflowInstancesResponse.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Responses/BulkDeleteWorkflowInstancesResponse.cs
index 73aa8280c..b72920995 100644
--- a/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Responses/BulkDeleteWorkflowInstancesResponse.cs
+++ b/src/clients/Elsa.Api.Client/Resources/WorkflowInstances/Responses/BulkDeleteWorkflowInstancesResponse.cs
@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
namespace Elsa.Api.Client.Resources.WorkflowInstances.Responses;
-internal class BulkDeleteWorkflowInstancesResponse
+internal sealed class BulkDeleteWorkflowInstancesResponse
{
[JsonPropertyName("deleted")] public int DeletedCount { get; }
}
\ No newline at end of file
diff --git a/src/clients/Elsa.Api.Client/Shared/Models/ActivityNode.cs b/src/clients/Elsa.Api.Client/Shared/Models/ActivityNode.cs
index c04cd79c4..752595141 100644
--- a/src/clients/Elsa.Api.Client/Shared/Models/ActivityNode.cs
+++ b/src/clients/Elsa.Api.Client/Shared/Models/ActivityNode.cs
@@ -37,7 +37,7 @@ public class ActivityNode
get
{
var ancestorIds = Ancestors().Reverse().Select(x => x.Activity.GetId()).ToList();
- return ancestorIds.Any() ? $"{string.Join(":", ancestorIds)}:{Activity.GetId()}" : Activity.GetId();
+ return ancestorIds.Count > 0 ? $"{string.Join(":", ancestorIds)}:{Activity.GetId()}" : Activity.GetId();
}
}
diff --git a/src/clients/Elsa.Api.Client/Shared/Models/LinkedEntity.cs b/src/clients/Elsa.Api.Client/Shared/Models/LinkedEntity.cs
index 306ddd26a..2d5047e5a 100644
--- a/src/clients/Elsa.Api.Client/Shared/Models/LinkedEntity.cs
+++ b/src/clients/Elsa.Api.Client/Shared/Models/LinkedEntity.cs
@@ -8,5 +8,5 @@ public class LinkedEntity : VersionedEntity
///
/// A list of links that with the possible actions used in the context of HATEOAS.
///
- public Link[]? Links { get; set; } = default;
+ public Link[]? Links { get; set; }
}
diff --git a/src/clients/Elsa.Api.Client/Shared/Models/PagedListResponse.cs b/src/clients/Elsa.Api.Client/Shared/Models/PagedListResponse.cs
index 14866e631..beb9415f0 100644
--- a/src/clients/Elsa.Api.Client/Shared/Models/PagedListResponse.cs
+++ b/src/clients/Elsa.Api.Client/Shared/Models/PagedListResponse.cs
@@ -3,11 +3,9 @@ namespace Elsa.Api.Client.Shared.Models;
///
/// Represents a generic paged list response that offers a unified format for returning paged list of things from API endpoints.
///
-/// A page of items.
-/// The total number of items.
/// The type of the items.
public class PagedListResponse : LinkedEntity
{
- public ICollection Items { get; set; }
+ public ICollection Items { get; set; } = default!;
public long TotalCount { get; set; }
}
\ No newline at end of file
diff --git a/src/clients/Elsa.Api.Client/Shared/Models/VersionOptions.cs b/src/clients/Elsa.Api.Client/Shared/Models/VersionOptions.cs
index 1a76ee1e4..ab36220bc 100644
--- a/src/clients/Elsa.Api.Client/Shared/Models/VersionOptions.cs
+++ b/src/clients/Elsa.Api.Client/Shared/Models/VersionOptions.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Globalization;
using System.Text.Json.Serialization;
using Elsa.Api.Client.Converters;
using JetBrains.Annotations;
@@ -60,7 +61,7 @@ public struct VersionOptions
"Published" => Published,
"LatestOrPublished" => LatestOrPublished,
"LatestAndPublished" => LatestAndPublished,
- _ => SpecificVersion(int.Parse(value))
+ _ => SpecificVersion(int.Parse(value, CultureInfo.InvariantCulture))
};
///
@@ -113,5 +114,5 @@ public struct VersionOptions
///
/// Returns a simple string representation of this .
///
- public override string ToString() => AllVersions ? "AllVersions" : IsDraft ? "Draft" : IsLatest ? "Latest" : IsPublished ? "Published" : IsLatestOrPublished ? "LatestOrPublished" : IsLatestAndPublished ? "LatestAndPublished" : Version.ToString();
+ public override string ToString() => AllVersions ? "AllVersions" : IsDraft ? "Draft" : IsLatest ? "Latest" : IsPublished ? "Published" : IsLatestOrPublished ? "LatestOrPublished" : IsLatestAndPublished ? "LatestAndPublished" : Version.ToString(CultureInfo.InvariantCulture);
}
diff --git a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs
index 05c90b968..53cd50bd6 100644
--- a/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs
+++ b/src/clients/Elsa.Api.Client/Shared/UIHints/CheckList/CheckListItem.cs
@@ -2,7 +2,9 @@ namespace Elsa.Api.Client.Shared.UIHints.CheckList;
public class CheckListItem
{
+#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public string Text { get; set; }
public string Value { get; set; }
+#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public bool IsChecked { get; set; }
}
\ No newline at end of file
diff --git a/src/common/Elsa.DropIns/Catalogs/DirectoryDropInCatalog.cs b/src/common/Elsa.DropIns/Catalogs/DirectoryDropInCatalog.cs
index 6b1b4de87..8a05e2460 100644
--- a/src/common/Elsa.DropIns/Catalogs/DirectoryDropInCatalog.cs
+++ b/src/common/Elsa.DropIns/Catalogs/DirectoryDropInCatalog.cs
@@ -50,12 +50,12 @@ public class DirectoryDropInCatalog : IDropInCatalog
}
}
- private IEnumerable ListPackages()
+ private string[] ListPackages()
{
return Directory.GetFiles(_directoryPath, "*.nupkg", SearchOption.AllDirectories);
}
- private Assembly? LoadDropInAssembly(string path)
+ private static Assembly? LoadDropInAssembly(string path)
{
return !File.Exists(path) ? null : AssemblyLoader.LoadPath(path);
}
diff --git a/src/common/Elsa.DropIns/Contexts/DirectoryAssemblyLoadContext.cs b/src/common/Elsa.DropIns/Contexts/DirectoryAssemblyLoadContext.cs
index 45bd6bd99..4a33f99db 100644
--- a/src/common/Elsa.DropIns/Contexts/DirectoryAssemblyLoadContext.cs
+++ b/src/common/Elsa.DropIns/Contexts/DirectoryAssemblyLoadContext.cs
@@ -3,7 +3,7 @@ using System.Runtime.Loader;
namespace Elsa.DropIns.Contexts;
-internal class DirectoryAssemblyLoadContext : AssemblyLoadContext
+internal sealed class DirectoryAssemblyLoadContext : AssemblyLoadContext
{
private readonly AssemblyDependencyResolver _resolver;
diff --git a/src/common/Elsa.DropIns/Contexts/NuGetPackageAssemblyLoadContext.cs b/src/common/Elsa.DropIns/Contexts/NuGetPackageAssemblyLoadContext.cs
index f0fd3e59b..febba4f8a 100644
--- a/src/common/Elsa.DropIns/Contexts/NuGetPackageAssemblyLoadContext.cs
+++ b/src/common/Elsa.DropIns/Contexts/NuGetPackageAssemblyLoadContext.cs
@@ -4,7 +4,7 @@ using NuGet.Packaging;
namespace Elsa.DropIns.Contexts;
-internal class NuGetPackageAssemblyLoadContext : AssemblyLoadContext
+internal sealed class NuGetPackageAssemblyLoadContext : AssemblyLoadContext
{
private readonly Dictionary _loadedAssemblies = new Dictionary();
@@ -12,7 +12,7 @@ internal class NuGetPackageAssemblyLoadContext : AssemblyLoadContext
{
var packageReader = new PackageArchiveReader(nugetPackagePath);
- foreach (var dllFile in packageReader.GetFiles().Where(fileName => fileName.EndsWith(".dll")))
+ foreach (var dllFile in packageReader.GetFiles().Where(fileName => fileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)))
{
using var dllStream = packageReader.GetStream(dllFile);
using var memoryStream = new MemoryStream();
@@ -26,6 +26,6 @@ internal class NuGetPackageAssemblyLoadContext : AssemblyLoadContext
protected override Assembly? Load(AssemblyName assemblyName)
{
- return _loadedAssemblies.TryGetValue(assemblyName.FullName, out var assembly) ? assembly : null;
+ return _loadedAssemblies.GetValueOrDefault(assemblyName.FullName);
}
}
\ No newline at end of file
diff --git a/src/common/Elsa.Features/Attributes/DependsOn.cs b/src/common/Elsa.Features/Attributes/DependsOn.cs
index 6a38ec575..fb9e3fa0a 100644
--- a/src/common/Elsa.Features/Attributes/DependsOn.cs
+++ b/src/common/Elsa.Features/Attributes/DependsOn.cs
@@ -4,13 +4,13 @@ namespace Elsa.Features.Attributes;
/// Specifies that the feature depends on another feature.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
-public class DependsOn : Attribute
+public class DependsOnAttribute : Attribute
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The type of the feature this feature depends on.
- public DependsOn(Type type)
+ public DependsOnAttribute(Type type)
{
Type = type;
}
diff --git a/src/common/Elsa.Features/Extensions/EnumerableTopologicalSortExtensions.cs b/src/common/Elsa.Features/Extensions/EnumerableTopologicalSortExtensions.cs
index bf1a1ca84..3be72b1d8 100644
--- a/src/common/Elsa.Features/Extensions/EnumerableTopologicalSortExtensions.cs
+++ b/src/common/Elsa.Features/Extensions/EnumerableTopologicalSortExtensions.cs
@@ -23,10 +23,8 @@ public static class EnumerableTopologicalSortExtensions
private static void Visit(T item, ISet visited, ICollection sorted, Func> dependencies, bool throwOnCycle)
{
- if (!visited.Contains(item))
+ if (visited.Add(item))
{
- visited.Add(item);
-
foreach (var dep in dependencies(item))
Visit(dep, visited, sorted, dependencies, throwOnCycle);
diff --git a/src/common/Elsa.Features/Implementations/Module.cs b/src/common/Elsa.Features/Implementations/Module.cs
index 1728843cc..66e16e4d1 100644
--- a/src/common/Elsa.Features/Implementations/Module.cs
+++ b/src/common/Elsa.Features/Implementations/Module.cs
@@ -14,11 +14,11 @@ namespace Elsa.Features.Implementations;
///
public class Module : IModule
{
- private record HostedServiceDescriptor(int Order, Type Type);
+ private sealed record HostedServiceDescriptor(int Order, Type Type);
- private IDictionary _features = new Dictionary();
- private readonly ISet _configuredFeatures = new HashSet();
- private readonly ICollection _hostedServiceDescriptors = new List();
+ private Dictionary _features = new();
+ private readonly HashSet _configuredFeatures = new();
+ private readonly List _hostedServiceDescriptors = new();
///
/// Constructor.
@@ -134,7 +134,7 @@ public class Module : IModule
let featureType = feature.GetType()
let dependencyOfAttributes = featureType.GetCustomAttributes().ToList()
let missingDependencies = dependencyOfAttributes.Where(x => !_features.ContainsKey(x.Type)).ToList()
- where !missingDependencies.Any()
+ where missingDependencies.Count == 0
select feature;
}
@@ -154,17 +154,17 @@ public class Module : IModule
return _features.TryGetValue(featureType, out var existingFeature) ? existingFeature : (IFeature)Activator.CreateInstance(featureType, this)!;
}
- private ISet GetFeatureTypes()
+ private HashSet GetFeatureTypes()
{
var featureTypes = _features.Keys.ToHashSet();
var featureTypesWithDependencies = featureTypes.Concat(featureTypes.SelectMany(GetDependencyTypes)).ToHashSet();
- return featureTypesWithDependencies.TSort(x => x.GetCustomAttributes().Select(dependsOn => dependsOn.Type)).ToHashSet();
+ return featureTypesWithDependencies.TSort(x => x.GetCustomAttributes().Select(dependsOn => dependsOn.Type)).ToHashSet();
}
// Recursively get dependency types.
private IEnumerable GetDependencyTypes(Type type)
{
- var dependencies = type.GetCustomAttributes().Select(dependsOn => dependsOn.Type).ToList();
+ var dependencies = type.GetCustomAttributes().Select(dependsOn => dependsOn.Type).ToList();
return dependencies.Concat(dependencies.SelectMany(GetDependencyTypes));
}
}
\ No newline at end of file
diff --git a/src/common/Elsa.Features/Services/InstalledFeatureRegistry.cs b/src/common/Elsa.Features/Services/InstalledFeatureRegistry.cs
index 205a790da..abd2e6d7c 100644
--- a/src/common/Elsa.Features/Services/InstalledFeatureRegistry.cs
+++ b/src/common/Elsa.Features/Services/InstalledFeatureRegistry.cs
@@ -6,7 +6,7 @@ namespace Elsa.Features.Services;
///
public class InstalledFeatureRegistry : IInstalledFeatureRegistry
{
- private readonly IDictionary _descriptors = new Dictionary();
+ private readonly Dictionary _descriptors = new();
///
public void Add(FeatureDescriptor descriptor) => _descriptors[descriptor.FullName] = descriptor;
@@ -15,5 +15,5 @@ public class InstalledFeatureRegistry : IInstalledFeatureRegistry
public IEnumerable List() => _descriptors.Values;
///
- public FeatureDescriptor? Find(string fullName) => _descriptors.TryGetValue(fullName, out var descriptor) ? descriptor : null;
+ public FeatureDescriptor? Find(string fullName) => _descriptors.GetValueOrDefault(fullName);
}
\ No newline at end of file
diff --git a/src/common/Elsa.Mediator/Contracts/ICommandSender.cs b/src/common/Elsa.Mediator/Contracts/ICommandSender.cs
index d6dde4dba..fb7a44b34 100644
--- a/src/common/Elsa.Mediator/Contracts/ICommandSender.cs
+++ b/src/common/Elsa.Mediator/Contracts/ICommandSender.cs
@@ -37,5 +37,5 @@ public interface ICommandSender
/// The command to send.
/// The command strategy to use.
/// The cancellation token.
- Task SendAsync(ICommand command, ICommandStrategy strategy, CancellationToken cancellationToken = default);
+ Task SendAsync(ICommand command, ICommandStrategy? strategy, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/src/common/Elsa.Mediator/Contracts/INotificationSender.cs b/src/common/Elsa.Mediator/Contracts/INotificationSender.cs
index 980c6b6dc..75c2fbaae 100644
--- a/src/common/Elsa.Mediator/Contracts/INotificationSender.cs
+++ b/src/common/Elsa.Mediator/Contracts/INotificationSender.cs
@@ -18,7 +18,7 @@ public interface INotificationSender
/// Publishes the given notification.
///
/// The notification to publish.
- ///
+ ///
/// The cancellation token.
- Task SendAsync(INotification notification, IEventPublishingStrategy strategy, CancellationToken cancellationToken = default);
+ Task SendAsync(INotification notification, IEventPublishingStrategy? strategy, CancellationToken cancellationToken = default);
}
\ No newline at end of file
diff --git a/src/common/Elsa.Mediator/HostedServices/BackgroundCommandSenderHostedService.cs b/src/common/Elsa.Mediator/HostedServices/BackgroundCommandSenderHostedService.cs
index b661c13d7..6b5092dbc 100644
--- a/src/common/Elsa.Mediator/HostedServices/BackgroundCommandSenderHostedService.cs
+++ b/src/common/Elsa.Mediator/HostedServices/BackgroundCommandSenderHostedService.cs
@@ -14,7 +14,7 @@ public class BackgroundCommandSenderHostedService : BackgroundService
private readonly int _workerCount;
private readonly ICommandsChannel _commandsChannel;
private readonly IServiceScopeFactory _scopeFactory;
- private readonly IList> _outputs;
+ private readonly List> _outputs;
private readonly ILogger _logger;
///
diff --git a/src/common/Elsa.Mediator/HostedServices/BackgroundEventPublisherHostedService.cs b/src/common/Elsa.Mediator/HostedServices/BackgroundEventPublisherHostedService.cs
index b467581f9..19d6e686d 100644
--- a/src/common/Elsa.Mediator/HostedServices/BackgroundEventPublisherHostedService.cs
+++ b/src/common/Elsa.Mediator/HostedServices/BackgroundEventPublisherHostedService.cs
@@ -14,7 +14,7 @@ public class BackgroundEventPublisherHostedService : BackgroundService
private readonly int _workerCount;
private readonly INotificationsChannel _notificationsChannel;
private readonly IServiceScopeFactory _scopeFactory;
- private readonly IList> _outputs;
+ private readonly List> _outputs;
private readonly ILogger _logger;
///
diff --git a/src/common/Elsa.Mediator/HostedServices/MessageProcessorHostedService.cs b/src/common/Elsa.Mediator/HostedServices/MessageProcessorHostedService.cs
index a7858c94d..9f99961ec 100644
--- a/src/common/Elsa.Mediator/HostedServices/MessageProcessorHostedService.cs
+++ b/src/common/Elsa.Mediator/HostedServices/MessageProcessorHostedService.cs
@@ -14,7 +14,7 @@ public class MessageProcessorHostedService : BackgroundService where T : notn
private readonly Channel _channel;
private readonly IEnumerable> _consumers;
private readonly ILogger _logger;
- private readonly IList> _workers;
+ private readonly List> _workers;
///
// ReSharper disable once ContextualLoggerProblem
diff --git a/src/common/Elsa.Mediator/Middleware/Command/CommandPipelineBuilder.cs b/src/common/Elsa.Mediator/Middleware/Command/CommandPipelineBuilder.cs
index b5added8e..8b98d49a3 100644
--- a/src/common/Elsa.Mediator/Middleware/Command/CommandPipelineBuilder.cs
+++ b/src/common/Elsa.Mediator/Middleware/Command/CommandPipelineBuilder.cs
@@ -6,7 +6,7 @@ namespace Elsa.Mediator.Middleware.Command;
public class CommandPipelineBuilder : ICommandPipelineBuilder
{
private const string ServicesKey = "mediator.Services";
- private readonly IList> _components = new List>();
+ private readonly List> _components = new();
///
/// Initializes a new instance of the class.
@@ -38,8 +38,10 @@ public class CommandPipelineBuilder : ICommandPipelineBuilder
{
CommandMiddlewareDelegate pipeline = _ => new ValueTask();
- foreach (var component in _components.Reverse())
- pipeline = component(pipeline);
+ for (int i = _components.Count - 1; i >= 0; i--)
+ {
+ pipeline = _components[i](pipeline);
+ }
return pipeline;
}
diff --git a/src/common/Elsa.Mediator/Middleware/Command/Components/CommandHandlerInvokerMiddleware.cs b/src/common/Elsa.Mediator/Middleware/Command/Components/CommandHandlerInvokerMiddleware.cs
index d9ea80593..7ad8487eb 100644
--- a/src/common/Elsa.Mediator/Middleware/Command/Components/CommandHandlerInvokerMiddleware.cs
+++ b/src/common/Elsa.Mediator/Middleware/Command/Components/CommandHandlerInvokerMiddleware.cs
@@ -33,7 +33,7 @@ public class CommandHandlerInvokerMiddleware : ICommandMiddleware
var handlerType = typeof(ICommandHandler<,>).MakeGenericType(commandType, resultType);
var handlers = _commandHandlers.Where(x => handlerType.IsInstanceOfType(x)).ToArray();
- if (!handlers.Any())
+ if (handlers.Length == 0)
throw new InvalidOperationException($"There is no handler to handle the {commandType.FullName} command");
if (handlers.Length > 1)
diff --git a/src/common/Elsa.Mediator/Middleware/Notification/NotificationPipelineBuilder.cs b/src/common/Elsa.Mediator/Middleware/Notification/NotificationPipelineBuilder.cs
index cfa803c01..850229f3b 100644
--- a/src/common/Elsa.Mediator/Middleware/Notification/NotificationPipelineBuilder.cs
+++ b/src/common/Elsa.Mediator/Middleware/Notification/NotificationPipelineBuilder.cs
@@ -6,7 +6,7 @@ namespace Elsa.Mediator.Middleware.Notification;
public class NotificationPipelineBuilder : INotificationPipelineBuilder
{
private const string ServicesKey = "mediator.Services";
- private readonly IList> _components = new List>();
+ private readonly List> _components = new();
///
/// Initializes a new instance of the class.
@@ -38,8 +38,10 @@ public class NotificationPipelineBuilder : INotificationPipelineBuilder
{
NotificationMiddlewareDelegate pipeline = _ => new ValueTask();
- foreach (var component in _components.Reverse())
- pipeline = component(pipeline);
+ for (int i = _components.Count - 1; i >= 0; i--)
+ {
+ pipeline = _components[i](pipeline);
+ }
return pipeline;
}
diff --git a/src/common/Elsa.Mediator/Middleware/Request/RequestPipelineBuilder.cs b/src/common/Elsa.Mediator/Middleware/Request/RequestPipelineBuilder.cs
index 5d210c6bd..173203b91 100644
--- a/src/common/Elsa.Mediator/Middleware/Request/RequestPipelineBuilder.cs
+++ b/src/common/Elsa.Mediator/Middleware/Request/RequestPipelineBuilder.cs
@@ -6,7 +6,7 @@ namespace Elsa.Mediator.Middleware.Request;
public class RequestPipelineBuilder : IRequestPipelineBuilder
{
private const string ServicesKey = "mediator.Services";
- private readonly IList> _components = new List>();
+ private readonly List> _components = new();
///
/// Initializes a new instance of the class.
@@ -38,8 +38,10 @@ public class RequestPipelineBuilder : IRequestPipelineBuilder
{
RequestMiddlewareDelegate pipeline = _ => new ValueTask();
- foreach (var component in _components.Reverse())
- pipeline = component(pipeline);
+ for (int i = _components.Count - 1; i >= 0; i--)
+ {
+ pipeline = _components[i](pipeline);
+ }
return pipeline;
}
diff --git a/src/modules/Elsa.Common/Contexts/TenantResolutionContext.cs b/src/modules/Elsa.Common/Contexts/TenantResolutionContext.cs
index 8dc9ec2c3..e0b544d9c 100644
--- a/src/modules/Elsa.Common/Contexts/TenantResolutionContext.cs
+++ b/src/modules/Elsa.Common/Contexts/TenantResolutionContext.cs
@@ -25,7 +25,7 @@ public class TenantResolutionContext
///
/// Gets the cancellation token.
///
- public CancellationToken CancellationToken { get; } = default;
+ public CancellationToken CancellationToken { get; }
///
/// Finds a tenant based on the provided tenant ID.
diff --git a/src/modules/Elsa.Common/Converters/DecimalJsonConverter.cs b/src/modules/Elsa.Common/Converters/DecimalJsonConverter.cs
index 95b172545..b4c41e55e 100644
--- a/src/modules/Elsa.Common/Converters/DecimalJsonConverter.cs
+++ b/src/modules/Elsa.Common/Converters/DecimalJsonConverter.cs
@@ -1,3 +1,4 @@
+using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -17,7 +18,7 @@ public class DecimalJsonConverter : JsonConverter
if (reader.TokenType == JsonTokenType.String)
{
var value = reader.GetString()!;
- return decimal.Parse(value);
+ return decimal.Parse(value, CultureInfo.InvariantCulture);
}
throw new JsonException("Expected number or string.");
diff --git a/src/modules/Elsa.Common/Converters/IntegerJsonConverter.cs b/src/modules/Elsa.Common/Converters/IntegerJsonConverter.cs
index 8c2bbf5b7..142aadeec 100644
--- a/src/modules/Elsa.Common/Converters/IntegerJsonConverter.cs
+++ b/src/modules/Elsa.Common/Converters/IntegerJsonConverter.cs
@@ -1,3 +1,4 @@
+using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -17,7 +18,7 @@ public class IntegerJsonConverter : JsonConverter
if (reader.TokenType == JsonTokenType.String)
{
var value = reader.GetString()!;
- return int.Parse(value);
+ return int.Parse(value, CultureInfo.InvariantCulture);
}
throw new JsonException("Expected number or string.");
diff --git a/src/modules/Elsa.Common/Models/VersionOptions.cs b/src/modules/Elsa.Common/Models/VersionOptions.cs
index f3c56f598..e854587d2 100644
--- a/src/modules/Elsa.Common/Models/VersionOptions.cs
+++ b/src/modules/Elsa.Common/Models/VersionOptions.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Globalization;
using System.Text.Json.Serialization;
using Elsa.Common.Converters;
using JetBrains.Annotations;
@@ -60,7 +61,7 @@ public struct VersionOptions
"Published" => Published,
"LatestOrPublished" => LatestOrPublished,
"LatestAndPublished" => LatestAndPublished,
- _ => SpecificVersion(int.Parse(value))
+ _ => SpecificVersion(int.Parse(value, CultureInfo.InvariantCulture))
};
///
@@ -113,5 +114,5 @@ public struct VersionOptions
///
/// Returns a simple string representation of this .
///
- public override string ToString() => AllVersions ? "AllVersions" : IsDraft ? "Draft" : IsLatest ? "Latest" : IsPublished ? "Published" : IsLatestOrPublished ? "LatestOrPublished" : IsLatestAndPublished ? "LatestAndPublished" : Version.ToString();
+ public override string ToString() => AllVersions ? "AllVersions" : IsDraft ? "Draft" : IsLatest ? "Latest" : IsPublished ? "Published" : IsLatestOrPublished ? "LatestOrPublished" : IsLatestAndPublished ? "LatestAndPublished" : Version.ToString(CultureInfo.InvariantCulture);
}
diff --git a/src/modules/Elsa.Common/Serialization/ConfigurableSerializer.cs b/src/modules/Elsa.Common/Serialization/ConfigurableSerializer.cs
index a017e645b..60ce4a00a 100644
--- a/src/modules/Elsa.Common/Serialization/ConfigurableSerializer.cs
+++ b/src/modules/Elsa.Common/Serialization/ConfigurableSerializer.cs
@@ -67,7 +67,7 @@ public abstract class ConfigurableSerializer
///
/// Creates a new instance of .
///
- private JsonSerializerOptions CreateOptionsInternal()
+ private static JsonSerializerOptions CreateOptionsInternal()
{
var options = new JsonSerializerOptions
{
diff --git a/src/modules/Elsa.Common/Services/MemoryStore.cs b/src/modules/Elsa.Common/Services/MemoryStore.cs
index ab0d71ac4..d08fc8603 100644
--- a/src/modules/Elsa.Common/Services/MemoryStore.cs
+++ b/src/modules/Elsa.Common/Services/MemoryStore.cs
@@ -119,7 +119,7 @@ public class MemoryStore
foreach (var entry in entries)
Entities.Remove(entry);
- return entries.LongCount();
+ return entries.Count;
}
///
diff --git a/src/modules/Elsa.Expressions/Helpers/ObjectConverter.cs b/src/modules/Elsa.Expressions/Helpers/ObjectConverter.cs
index 571397bee..142b9de09 100644
--- a/src/modules/Elsa.Expressions/Helpers/ObjectConverter.cs
+++ b/src/modules/Elsa.Expressions/Helpers/ObjectConverter.cs
@@ -181,10 +181,10 @@ public static class ObjectConverter
return Enum.ToObject(underlyingTargetType, value);
if (underlyingSourceType == typeof(double))
- return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int)));
+ return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int), CultureInfo.InvariantCulture));
if (underlyingSourceType == typeof(long))
- return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int)));
+ return Enum.ToObject(underlyingTargetType, Convert.ChangeType(value, typeof(int), CultureInfo.InvariantCulture));
}
if (value is string s)
@@ -225,7 +225,7 @@ public static class ObjectConverter
try
{
- return Convert.ChangeType(value, underlyingTargetType);
+ return Convert.ChangeType(value, underlyingTargetType, CultureInfo.InvariantCulture);
}
catch (InvalidCastException e)
{
diff --git a/src/modules/Elsa.Expressions/Services/WellKnownTypeRegistry.cs b/src/modules/Elsa.Expressions/Services/WellKnownTypeRegistry.cs
index 8a973d3b1..3ca1f622c 100644
--- a/src/modules/Elsa.Expressions/Services/WellKnownTypeRegistry.cs
+++ b/src/modules/Elsa.Expressions/Services/WellKnownTypeRegistry.cs
@@ -7,8 +7,8 @@ namespace Elsa.Expressions.Services;
///
public class WellKnownTypeRegistry : IWellKnownTypeRegistry
{
- private readonly IDictionary _aliasTypeDictionary = new Dictionary();
- private readonly IDictionary _typeAliasDictionary = new Dictionary();
+ private readonly Dictionary _aliasTypeDictionary = new();
+ private readonly Dictionary _typeAliasDictionary = new();
///
/// Creates a new instance of the class.
diff --git a/test/unit/Elsa.MongoDb.UnitTests/Elsa.MongoDb.UnitTests.csproj b/test/unit/Elsa.MongoDb.UnitTests/Elsa.MongoDb.UnitTests.csproj
index e3e605c9f..d511196d0 100644
--- a/test/unit/Elsa.MongoDb.UnitTests/Elsa.MongoDb.UnitTests.csproj
+++ b/test/unit/Elsa.MongoDb.UnitTests/Elsa.MongoDb.UnitTests.csproj
@@ -4,11 +4,6 @@
net8.0
-
-
-
-
-
diff --git a/test/unit/Elsa.Workflows.Runtime.UnitTests/Elsa.Workflows.Runtime.UnitTests.csproj b/test/unit/Elsa.Workflows.Runtime.UnitTests/Elsa.Workflows.Runtime.UnitTests.csproj
index 4a25fd633..243a3ddde 100644
--- a/test/unit/Elsa.Workflows.Runtime.UnitTests/Elsa.Workflows.Runtime.UnitTests.csproj
+++ b/test/unit/Elsa.Workflows.Runtime.UnitTests/Elsa.Workflows.Runtime.UnitTests.csproj
@@ -8,8 +8,4 @@
-
-
-
-