Skip to content

Conversation

@wieslawsoltes
Copy link
Owner

No description provided.

Copy link
Contributor

Copilot AI left a 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 ScriptOptions with common imports and references, then switch from EvaluateAsync to RunAsync
  • Revise the sample XAML to use a TextBox for 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)

@wieslawsoltes wieslawsoltes requested a review from Copilot May 19, 2025 09:43
Copy link
Contributor

Copilot AI left a 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}");

@wieslawsoltes wieslawsoltes merged commit 9185253 into master May 19, 2025
13 checks passed
@wieslawsoltes wieslawsoltes deleted the ImproveExecuteScriptAction branch May 19, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants