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

Add Variable Name Validation and Wrapper Control #6117

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

sfmskywalker
Copy link
Member

@sfmskywalker sfmskywalker commented Nov 13, 2024

This PR adds an option to disable the automatic wrapper generation of C# and JavaScript functions for workflow variables.

Changes:

  • C# Syntax:
    When opting out, Variables.MyVariable will no longer be available. Variables can only be accessed using:

    • Variables.Get("MyVariable")
    • Variables.Get<T>("MyVariable")

    Configuration:
    To disable wrappers in C#, use the following configuration:

    elsa.UseCSharp(options =>
    {
        options.DisableWrappers = true;
    });
  • JavaScript Syntax:
    When opting out, variables.MyVariable and getMyVariable() will no longer be available. Variables can only be accessed using:

    • getVariable("MyVariable")

    Configuration:
    To disable wrappers in JavaScript, use the following configuration:

    .UseJavaScript(options =>
    {
        options.DisableWrappers = true;
    });

Use Case:

This feature is helpful for applications requiring the use of variable names that are invalid in JavaScript or C#.


This change is Reviewable

Renamed TypeDefinitions/Providers to Providers for better clarity. Added a new configuration option to disable generating variable wrappers for scenarios requiring invalid JavaScript variable names.
Introduced methods to validate variable names and filter invalid ones. Integrated `DisableWrappers` option to control the generation of variable wrappers, enhancing flexibility in variable management.
The item group containing the "TypeDefinitions\Providers\" folder was removed from the Elsa.JavaScript.csproj file. This folder was not serving any purpose and its removal helps in cleaning up the project structure.
@sfmskywalker sfmskywalker merged commit 02f4dc9 into main Nov 13, 2024
3 checks passed
@sfmskywalker sfmskywalker deleted the enh/variable-wrapper-opt-out branch November 13, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant