-
Notifications
You must be signed in to change notification settings - Fork 231
Compile all expressions at once when validating. #268
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b21f8f
Compile all expressions at once
aoltean16 aa79385
refactor
aoltean16 35d2624
added tests and refactored code
gabriela-lungu-uip 16bca3c
fixed test + small rename
aoltean16 0592fd5
added one more test scenario
gabriela-lungu-uip de8d1c2
fix.
aoltean16 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // This file is part of Core WF which is licensed under the MIT license. | ||
| // See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace System.Activities | ||
| { | ||
| internal class EnvironmentExtensions | ||
| { | ||
| private readonly Dictionary<Type, object> _extensions = new(); | ||
|
|
||
| /// <summary> | ||
| /// Gets the specified extension. | ||
| /// If the extension does not exist, | ||
| /// it will invoke the <paramref name="createExtensionFactory"/> parameter | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of the extension</typeparam> | ||
| /// <param name="createExtensionFactory">The factory to create the extension</param> | ||
| /// <exception cref="ArgumentNullException"></exception> | ||
| public TInterface GetOrAdd<TInterface>(Func<TInterface> createExtensionFactory) | ||
| where TInterface : class | ||
| { | ||
| var type = typeof(TInterface); | ||
| if (_extensions.TryGetValue(type, out object extension)) | ||
| { | ||
| return extension as TInterface; | ||
| } | ||
|
|
||
| return CreateAndAdd(createExtensionFactory, type); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Retrieves the extension registered for the given type | ||
| /// or null otherwise | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of the extension.</typeparam> | ||
| public T Get<T>() where T : class | ||
| { | ||
| if (_extensions.TryGetValue(typeof(T), out object extension)) | ||
| return extension as T; | ||
| return null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds the specified extension to the list. | ||
| /// The extension is treated as a singleton, | ||
| /// so if a second extension with the same type is added, it will | ||
| /// throw an <see cref="InvalidOperationException"/> | ||
| /// </summary> | ||
| /// <typeparam name="TInterface">The type of the extension</typeparam> | ||
| /// <param name="extension">The extension</param> | ||
| /// <exception cref="InvalidOperationException"></exception> | ||
| public void Add<TInterface, TImplementation>(TImplementation extension) | ||
| where TInterface : class | ||
| where TImplementation : class, TInterface | ||
| { | ||
| if (_extensions.ContainsKey(typeof(TInterface))) | ||
| throw new InvalidOperationException($"Service '{typeof(TInterface).FullName}' already exists"); | ||
|
|
||
| _extensions[typeof(TInterface)] = extension; | ||
| } | ||
|
|
||
|
|
||
| #region private methods | ||
| private T CreateAndAdd<T>(Func<T> createExtensionFactory, Type type) where T : class | ||
| { | ||
| var extension = createExtensionFactory(); | ||
| if (extension is null) | ||
| throw new ArgumentNullException(nameof(extension)); | ||
|
|
||
| _extensions[type] = extension; | ||
| return extension; | ||
| } | ||
| #endregion | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/UiPath.Workflow.Runtime/Validation/IValidationExtension.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace System.Activities.Validation | ||
| { | ||
| internal interface IValidationExtension | ||
| { | ||
| IEnumerable<ValidationError> Validate(Activity activity); | ||
| } | ||
| } |
135 changes: 0 additions & 135 deletions
135
src/UiPath.Workflow/Activities/CsExpressionValidator.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.