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

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Caliburn.Micro.Platform/ActionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,9 @@ void ElementLoaded(object sender, RoutedEventArgs e)
Log.Info($"Binding {binding.Source}");

#elif (NET || CAL_NETCORE) && !WinUI3 && !WINDOWS_UWP
var binding = new Binding {
Path = new PropertyPath(Message.HandlerProperty),
var binding = new Binding
{
Path = new PropertyPath(Message.HandlerProperty),
Source = currentElement
};
#elif WINDOWS_UWP || WinUI3
Expand Down Expand Up @@ -536,7 +537,23 @@ public override string ToString()
if (!hasBinding && context.CanExecute != null)
{
Log.Info($"ApplyAvailabilityEffect CanExecute {context.CanExecute()} - {context.Method.Name}");
source.IsEnabled = context.CanExecute();
if (!string.IsNullOrEmpty(source.Name))
{
Log.Info($"ApplyAvailabilityEffect CanExecute {context.CanExecute()} - {context.Method.Name} - {source.Name}");
source.IsEnabled = context.CanExecute();
}
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

}
if (!source.IsEnabled)
{
Log.Info($"Disabled {source.Name}");
}
else
{
Log.Info($"Enabled {source.Name}");
}
}
#endif
Log.Info($"ApplyAvailabilityEffect source enabled {source.IsEnabled}");
Expand Down Expand Up @@ -615,6 +632,7 @@ public override string ToString()
}
}
#else

if (source != null && source.DataContext != null)
{
var target = source.DataContext;
Expand Down
Loading