Skip to content

Improve binding logic and logging in ActionMessage.cs #970

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

vb2ae
Copy link
Member

@vb2ae vb2ae commented Feb 25, 2025

This pull request includes changes to the src/Caliburn.Micro.Platform/ActionMessage.cs file to improve code readability and logging details. The most important changes include reformatting the Binding initialization, adding detailed logging for the ApplyAvailabilityEffect method, and adding a new line for better code separation.

Code readability improvements:

  • Reformatted the Binding initialization to follow a more consistent code style.

Logging enhancements:

  • Added detailed logging in the ApplyAvailabilityEffect method to log the state of the source.Name and whether the source is enabled or disabled.

Code separation:

  • Added a new line for better code separation in the ToString method.
ActionMessageGuard.mp4

closing #657

- Updated binding initialization to use object initializer syntax for better readability.
- Enhanced logging for `source` enabled status, including checks for `source.Name`.
- Added logging to indicate whether `source` is enabled or disabled after `CanExecute` check.
- Implemented null checks for `source` and its `DataContext` to prevent null reference exceptions.
Copy link
Contributor

@Copilot 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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

}
else
{
Log.Info("Skipping is enabled because source Name is not set");
Copy link
Preview

Copilot AI Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message 'Skipping is enabled because source Name is not set' is unclear. It should be 'Skipping enabling source because Name is not set'.

Suggested change
Log.Info("Skipping is enabled because source Name is not set");
Log.Info("Skipping enabling source because Name is not set");

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated log text to Skipping IsEnabled source because source Name is not set

@vb2ae vb2ae requested a review from Copilot February 25, 2025 12:31
Copy link
Contributor

@Copilot 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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/Caliburn.Micro.Platform/ActionMessage.cs:547

  • The log message 'Skipping is enabled because source Name is not set' is unclear. It should be 'Skipping enable check because source Name is not set'.
Log.Info("Skipping is enabled because source Name is not set");

@vb2ae vb2ae requested a review from Copilot February 25, 2025 12:39
Copy link
Contributor

@Copilot 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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/Caliburn.Micro.Platform/ActionMessage.cs:547

  • [nitpick] The logging message 'Skipping IsEnabled source because source Name is not set' could be more descriptive. Consider changing it to 'Skipping IsEnabled check because source Name is not set'.
Log.Info("Skipping IsEnabled source because source Name is not set");

src/Caliburn.Micro.Platform/ActionMessage.cs:537

  • Ensure that the new logging behavior added in the ApplyAvailabilityEffect method is covered by tests.
if (!hasBinding && context.CanExecute != null)

@vb2ae vb2ae removed the request for review from KasperSK February 25, 2025 13:56
@vb2ae vb2ae closed this Feb 25, 2025
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.

KeyBinding Issue when attaching it to windows with commands with CanExecute methods
1 participant