-
-
Notifications
You must be signed in to change notification settings - Fork 19
Improve ExecuteScriptAction #86
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances ExecuteScriptAction by introducing customizable script options with predefined imports and dynamic assembly references, and updates the sample view to allow editing the script at runtime.
- Load all non-dynamic assemblies and feed them into the scripting engine
- Configure
ScriptOptionswith common imports and references, then switch fromEvaluateAsynctoRunAsync - Revise the sample XAML to use a
TextBoxfor live script input
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs | Add ScriptOptions with imports/references and switch to RunAsync |
| samples/BehaviorsTestApplication/Views/Pages/ExecuteScriptActionView.axaml | Change layout to StackPanel and bind script source to a TextBox |
Comments suppressed due to low confidence (1)
src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs:67
- The catch block currently swallows all exceptions silently. Consider logging the exception (
Debug.WriteLine, logger) or surface compilation/runtime errors to aid debugging.
catch (Exception ex)
src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs
Outdated
Show resolved
Hide resolved
samples/BehaviorsTestApplication/Views/Pages/ExecuteScriptActionView.axaml
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances script execution by updating the ExecuteScriptAction logic and its usage in sample views. Key changes include:
- Adding a UseDispatcher property to enable script execution via Dispatcher.UIThread or Task.Run.
- Preloading assemblies and setting up ScriptOptions with new imports for improved script context.
- Updating the sample view layout and binding syntax to demonstrate the new property usage.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs | Introduces new asynchronous script execution using Dispatcher.UIThread or Task.Run along with enhanced script options. |
| samples/BehaviorsTestApplication/Views/Pages/ExecuteScriptActionView.axaml | Updates the UI layout and binding syntax to align with the revised script execution behavior. |
Comments suppressed due to low confidence (2)
src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs:77
- Consider capturing and handling the task returned by Dispatcher.UIThread.InvokeAsync instead of using '_ =' to ensure any asynchronous exceptions are logged or managed.
_ = Dispatcher.UIThread.InvokeAsync(async () =>
src/Avalonia.Xaml.Interactions.Scripting/ExecuteScriptAction.cs:106
- Consider implementing a more robust error handling or logging mechanism in the catch block to better support troubleshooting of script execution failures.
Debug.WriteLine("Script execution failed: {ex.Message}");
No description provided.