diff --git a/src/modules/Elsa.JavaScript/Providers/VariableTypeDefinitionProvider.cs b/src/modules/Elsa.JavaScript/Providers/VariableTypeDefinitionProvider.cs
index a5888b87b..743ee22a8 100644
--- a/src/modules/Elsa.JavaScript/Providers/VariableTypeDefinitionProvider.cs
+++ b/src/modules/Elsa.JavaScript/Providers/VariableTypeDefinitionProvider.cs
@@ -1,36 +1,38 @@
using System.Dynamic;
-using Elsa.Extensions;
using Elsa.JavaScript.TypeDefinitions.Abstractions;
using Elsa.JavaScript.TypeDefinitions.Contracts;
using Elsa.JavaScript.TypeDefinitions.Models;
+using Elsa.Workflows.Management.Options;
+using JetBrains.Annotations;
+using Microsoft.Extensions.Options;
namespace Elsa.JavaScript.Providers;
///
/// Produces s for variable types.
///
-internal class VariableTypeDefinitionProvider(ITypeDescriber typeDescriber) : TypeDefinitionProvider
+[UsedImplicitly]
+internal class VariableTypeDefinitionProvider(ITypeDescriber typeDescriber, IOptions options) : TypeDefinitionProvider
{
protected override IEnumerable GetTypeDefinitions(TypeDefinitionContext context)
{
var excludedTypes = new Func[]
{
type => type == typeof(ExpandoObject),
- type => typeof(IDictionary).IsAssignableFrom(type),
- type => type == typeof(object)
+ type => type.IsPrimitive,
+ type => type.ContainsGenericParameters,
+ type => type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary<,>),
+ type => type == typeof(object),
+ type => type == typeof(string)
};
- var variables = context.WorkflowGraph.Workflow.Variables;
-
- var variableTypeQuery =
- from variable in variables
- let variableType = variable.GetVariableType()
- where (variableType.IsClass || variableType.IsInterface || variableType.IsEnum) && !variableType.IsPrimitive && !excludedTypes.Any(x => x(variableType))
+ var variableTypes =
+ from variableDescriptor in options.Value.VariableDescriptors
+ let variableType = variableDescriptor.Type
+ where (variableType.IsClass || variableType.IsInterface || variableType.IsEnum) && !excludedTypes.Any(x => x(variableType))
select variableType;
- var variableTypes = variableTypeQuery.Distinct();
-
- foreach (var variableType in variableTypes)
+ foreach (var variableType in variableTypes.Distinct())
{
yield return typeDescriber.DescribeType(variableType);
}
diff --git a/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDefinitionDocumentRenderer.cs b/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDefinitionDocumentRenderer.cs
index f5699e6f5..04b22f103 100644
--- a/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDefinitionDocumentRenderer.cs
+++ b/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDefinitionDocumentRenderer.cs
@@ -58,7 +58,7 @@ public class TypeDefinitionDocumentRenderer : ITypeDefinitionDocumentRenderer
}
private void Render(PropertyDefinition property, StringBuilder output) => output.AppendLine($"{property.Name}{(property.IsOptional ? "?" : "")}: {property.Type};");
- private void RenderEnumMember(PropertyDefinition property, StringBuilder output) => output.AppendLine($"{property.Name} = \"{property.Name}\";");
+ private void RenderEnumMember(PropertyDefinition property, StringBuilder output) => output.AppendLine($"{property.Name} = \"{property.Name}\",");
private void Render(VariableDefinition variable, StringBuilder output) => output.AppendLine($"declare var {variable.Name}: {variable.Type};");
string RenderParameter(ParameterDefinition parameter) => $"{parameter.Name}{(parameter.IsOptional ? "?" : "")}: {parameter.Type}";
string RenderParameters(IEnumerable parameters) => string.Join(", ", parameters.Select(RenderParameter));
diff --git a/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDescriber.cs b/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDescriber.cs
index af4a85b74..fe699b6a9 100644
--- a/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDescriber.cs
+++ b/src/modules/Elsa.JavaScript/TypeDefinitions/Services/TypeDescriber.cs
@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Elsa.Extensions;
using Elsa.JavaScript.Contracts;
using Elsa.JavaScript.TypeDefinitions.Contracts;
@@ -40,7 +41,10 @@ public class TypeDescriber : ITypeDescriber
yield break;
#pragma warning disable IL2070
- var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static).Where(x => !x.IsSpecialName).ToList();
+ var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
+ .Where(x => !x.IsSpecialName)
+ .Where(x => x.GetCustomAttribute() == null)
+ .ToList();
#pragma warning restore IL2070
foreach (var method in methods)