From 0a35fcbf8d095ef66443a4b3ad7a5d0f2b1220ab Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 8 Sep 2024 19:40:24 +0300 Subject: [PATCH] Upgrade Quartz and some warning fixes --- Directory.Build.props | 4 ++++ Directory.Packages.props | 6 ++---- .../Elsa.Api.Client/Extensions/PropertyBagExtensions.cs | 6 +++++- .../Elsa.Common/Features/DefaultFormattersFeature.cs | 2 +- src/modules/Elsa.Common/Results/TenantResolutionResult.cs | 2 +- src/modules/Elsa.Common/Serialization/JsonSerializer.cs | 2 +- .../Abstractions/DesignTimeDbContextFactoryBase.cs | 2 +- .../DbSchemaAwareMigrationAssembly.cs | 2 +- .../Extensions/ExpressionOptionsExtensions.cs | 2 +- src/modules/Elsa.Expressions/Extensions/ModuleExtensions.cs | 2 +- .../Extensions/WellKnowTypeRegistryExtensions.cs | 2 +- src/modules/Elsa.Expressions/Models/Expression.cs | 1 - src/modules/Elsa.Quartz/Elsa.Quartz.csproj | 2 -- src/modules/Elsa.Quartz/Features/QuartzFeature.cs | 3 --- src/modules/Elsa.Tenants/Extensions/ModuleExtensions.cs | 2 +- .../Contexts/WorkflowExecutionContext.cs | 4 +++- 16 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index cb6d30d9d6..6dea5e8396 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -28,9 +28,13 @@ true snupkg true + + false $(NoWarn);CS0162;CS1591 + + $(NoWarn);IL2026;IL2046;IL2057;IL2067;IL2070;IL2072;IL2075;IL2087;IL2091 3.3.0-preview.470 diff --git a/Directory.Packages.props b/Directory.Packages.props index 7fed26f9be..a798111da3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -82,10 +82,8 @@ - - - - + + diff --git a/src/clients/Elsa.Api.Client/Extensions/PropertyBagExtensions.cs b/src/clients/Elsa.Api.Client/Extensions/PropertyBagExtensions.cs index a72b7b5562..7ff42162bf 100644 --- a/src/clients/Elsa.Api.Client/Extensions/PropertyBagExtensions.cs +++ b/src/clients/Elsa.Api.Client/Extensions/PropertyBagExtensions.cs @@ -17,12 +17,16 @@ public static class PropertyBagExtensions /// The key of the value to retrieve. /// A function that returns the default value to be returned if the key does not exist in the PropertyBag. /// The value associated with the key, or the default value if the key does not exist. - public static T TryGetValueOrDefault(this PropertyBag propertyBag, string key, Func defaultValue) + public static T? TryGetValueOrDefault(this PropertyBag propertyBag, string key, Func defaultValue) { if (!propertyBag.TryGetValue(key, out var value)) return defaultValue(); var json = value.ToString(); + + if (string.IsNullOrWhiteSpace(json)) + return defaultValue(); + return JsonSerializer.Deserialize(json); } diff --git a/src/modules/Elsa.Common/Features/DefaultFormattersFeature.cs b/src/modules/Elsa.Common/Features/DefaultFormattersFeature.cs index c916458dbd..aa8643247b 100644 --- a/src/modules/Elsa.Common/Features/DefaultFormattersFeature.cs +++ b/src/modules/Elsa.Common/Features/DefaultFormattersFeature.cs @@ -10,6 +10,6 @@ public class DefaultFormattersFeature(IModule module) : FeatureBase(module) { public override void Configure() { - module.Services.AddSingleton(); + Module.Services.AddSingleton(); } } \ No newline at end of file diff --git a/src/modules/Elsa.Common/Results/TenantResolutionResult.cs b/src/modules/Elsa.Common/Results/TenantResolutionResult.cs index 68bfa7188d..ab6f352415 100644 --- a/src/modules/Elsa.Common/Results/TenantResolutionResult.cs +++ b/src/modules/Elsa.Common/Results/TenantResolutionResult.cs @@ -3,7 +3,7 @@ namespace Elsa.Common.Results; /// /// Represents the result of a tenant resolution. /// -/// The resolved tenant. +/// The resolved tenant. public record TenantResolutionResult(string? TenantId) { /// diff --git a/src/modules/Elsa.Common/Serialization/JsonSerializer.cs b/src/modules/Elsa.Common/Serialization/JsonSerializer.cs index 9c994af4eb..93ebfb5ba3 100644 --- a/src/modules/Elsa.Common/Serialization/JsonSerializer.cs +++ b/src/modules/Elsa.Common/Serialization/JsonSerializer.cs @@ -24,7 +24,7 @@ public string Serialize(object value) /// [RequiresUnreferencedCode("The type is not known at compile time.")] - public string Serialize(object value, Type type) + public string Serialize(object? value, Type type) { var options = GetOptions(); return JsonSerializer.Serialize(value, type, options); diff --git a/src/modules/Elsa.EntityFrameworkCore.Common/Abstractions/DesignTimeDbContextFactoryBase.cs b/src/modules/Elsa.EntityFrameworkCore.Common/Abstractions/DesignTimeDbContextFactoryBase.cs index e5284bf079..d88b1490c3 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Common/Abstractions/DesignTimeDbContextFactoryBase.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Common/Abstractions/DesignTimeDbContextFactoryBase.cs @@ -27,7 +27,7 @@ public TDbContext CreateDbContext(string[] args) ConfigureBuilder(builder, connectionString); - return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options, serviceProvider); + return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options, serviceProvider)!; } /// diff --git a/src/modules/Elsa.EntityFrameworkCore.Common/DbSchemaAwareMigrationAssembly.cs b/src/modules/Elsa.EntityFrameworkCore.Common/DbSchemaAwareMigrationAssembly.cs index f0e0003eb6..6245c17716 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Common/DbSchemaAwareMigrationAssembly.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Common/DbSchemaAwareMigrationAssembly.cs @@ -32,7 +32,7 @@ public override Migration CreateMigration(TypeInfo migrationClass, string active if (hasCtorWithSchema && _context is IElsaDbContextSchema schema) { - var instance = (Migration)Activator.CreateInstance(migrationClass.AsType(), schema); + var instance = (Migration)Activator.CreateInstance(migrationClass.AsType(), schema)!; instance.ActiveProvider = activeProvider; return instance; } diff --git a/src/modules/Elsa.Expressions/Extensions/ExpressionOptionsExtensions.cs b/src/modules/Elsa.Expressions/Extensions/ExpressionOptionsExtensions.cs index e3b29e504e..7c398e4c83 100644 --- a/src/modules/Elsa.Expressions/Extensions/ExpressionOptionsExtensions.cs +++ b/src/modules/Elsa.Expressions/Extensions/ExpressionOptionsExtensions.cs @@ -11,7 +11,7 @@ namespace Elsa.Extensions; public static class ExpressionOptionsExtensions { /// - /// Register type with the specified alias. + /// Register type with the specified alias. /// public static void AddTypeAlias(this ExpressionOptions options) => options.RegisterTypeAlias(typeof(T), typeof(T).Name); public static void AddTypeAlias(this ExpressionOptions options, string alias) => options.RegisterTypeAlias(typeof(T), alias); diff --git a/src/modules/Elsa.Expressions/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Expressions/Extensions/ModuleExtensions.cs index 8ab88bc951..5112979b6c 100644 --- a/src/modules/Elsa.Expressions/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Expressions/Extensions/ModuleExtensions.cs @@ -35,7 +35,7 @@ public static IServiceCollection AddExpressionDescriptorProvider(this IServic } /// - /// Register type with the specified alias. + /// Register type with the specified alias. /// /// The module. /// The alias. diff --git a/src/modules/Elsa.Expressions/Extensions/WellKnowTypeRegistryExtensions.cs b/src/modules/Elsa.Expressions/Extensions/WellKnowTypeRegistryExtensions.cs index c24edc7f51..76003aebf2 100644 --- a/src/modules/Elsa.Expressions/Extensions/WellKnowTypeRegistryExtensions.cs +++ b/src/modules/Elsa.Expressions/Extensions/WellKnowTypeRegistryExtensions.cs @@ -9,7 +9,7 @@ namespace Elsa.Expressions.Extensions; public static class WellKnowTypeRegistryExtensions { /// - /// Register type with the specified alias. + /// Register type with the specified alias. /// public static void RegisterType(this IWellKnownTypeRegistry registry, string alias) => registry.RegisterType(typeof(T), alias); diff --git a/src/modules/Elsa.Expressions/Models/Expression.cs b/src/modules/Elsa.Expressions/Models/Expression.cs index 19a5020e44..b1f0fbe2dc 100644 --- a/src/modules/Elsa.Expressions/Models/Expression.cs +++ b/src/modules/Elsa.Expressions/Models/Expression.cs @@ -47,7 +47,6 @@ public Expression(string type, object? value) /// Creates an expression that represents a delegate. /// /// The delegate. - /// The return type of the delegate. /// An expression that represents a delegate. public static Expression DelegateExpression(Func> value) => new() { diff --git a/src/modules/Elsa.Quartz/Elsa.Quartz.csproj b/src/modules/Elsa.Quartz/Elsa.Quartz.csproj index 32b8484099..4af095308f 100644 --- a/src/modules/Elsa.Quartz/Elsa.Quartz.csproj +++ b/src/modules/Elsa.Quartz/Elsa.Quartz.csproj @@ -9,8 +9,6 @@ - - diff --git a/src/modules/Elsa.Quartz/Features/QuartzFeature.cs b/src/modules/Elsa.Quartz/Features/QuartzFeature.cs index 04e6f60c68..906b5f5b0e 100644 --- a/src/modules/Elsa.Quartz/Features/QuartzFeature.cs +++ b/src/modules/Elsa.Quartz/Features/QuartzFeature.cs @@ -52,9 +52,6 @@ public override void Apply() private static void ConfigureQuartzInternal(IServiceCollectionQuartzConfigurator quartz, Action? configureQuartz) { - quartz.UseMicrosoftDependencyInjectionJobFactory(); - quartz.UseSimpleTypeLoader(); - quartz.UseInMemoryStore(); configureQuartz?.Invoke(quartz); } } \ No newline at end of file diff --git a/src/modules/Elsa.Tenants/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Tenants/Extensions/ModuleExtensions.cs index 9db8ad5fb1..052a294955 100644 --- a/src/modules/Elsa.Tenants/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Tenants/Extensions/ModuleExtensions.cs @@ -10,7 +10,7 @@ namespace Elsa.Tenants.Extensions; public static class ModuleExtensions { /// - /// Installs & configures the feature. + /// Installs and configures the feature. /// public static IModule UseTenants(this IModule module, Action? configure = default) { diff --git a/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs b/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs index 3571ff9423..fe54aed741 100644 --- a/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs +++ b/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs @@ -280,7 +280,8 @@ public async Task SetWorkflowGraphAsync(WorkflowGraph workflowGraph) public Diff BookmarksDiff => Diff.For(OriginalBookmarks, Bookmarks); /// - /// A dictionary of inputs provided at the start of the current workflow execution. + /// A dictionary of inputs provided at the start of the current workflow execution. + /// public IDictionary Input { get; set; } /// A dictionary of outputs provided by the current workflow execution. @@ -398,6 +399,7 @@ internal void RemoveCompletionCallbacks(IEnumerable /// Returns the with the specified activity ID from the workflow graph. + /// public ActivityNode? FindNodeById(string nodeId) => NodeIdLookup.TryGetValue(nodeId, out var node) ? node : default; /// Returns the with the specified hash of the activity node ID from the workflow graph.