Skip to content
Draft
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
15 changes: 10 additions & 5 deletions src/Caliburn.Micro.Platform/ViewModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using System.Text;
#if XFORMS
using UIElement = global::Xamarin.Forms.Element;
using FrameworkElement = global::Xamarin.Forms.VisualElement;
Expand Down Expand Up @@ -176,11 +177,11 @@
}
#endif

var message = method.Name;
var parameters = method.GetParameters();
var messageBuilder = new StringBuilder(method.Name);

if (parameters.Length > 0) {
message += "(";
messageBuilder.Append("(");

foreach (var parameter in parameters) {
var paramName = parameter.Name;
Expand All @@ -189,15 +190,19 @@
if (MessageBinder.SpecialValues.ContainsKey(specialValue))
paramName = specialValue;

message += paramName + ",";
messageBuilder.Append(paramName).Append(",");
}

message = message.Remove(message.Length - 1, 1);
message += ")";
// Remove the trailing comma
if (parameters.Length > 0)
messageBuilder.Length -= 1;
Comment on lines +212 to +213
Copy link

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

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

This condition check is redundant since this code is already inside a block that only executes when parameters.Length > 0 (line 183). The condition will always be true and can be removed.

Suggested change
if (parameters.Length > 0)
messageBuilder.Length -= 1;
messageBuilder.Length -= 1;

Copilot uses AI. Check for mistakes.

messageBuilder.Append(")");
var message = messageBuilder.ToString();

}
Copy link

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

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

The variable message is declared inside the if block but used outside of it at line 204. This will cause a compilation error because message is not in scope when parameters.Length is 0. Move the declaration outside the if block or ensure it's accessible in all code paths.

Suggested change
var message = messageBuilder.ToString();
}
}
message = messageBuilder.ToString();

Copilot uses AI. Check for mistakes.


Log.Info("Action Convention Applied: Action {0} on element {1}.", method.Name, message);

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 204 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context
Message.SetAttach(foundControl, message);

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / Analyse

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context

Check failure on line 205 in src/Caliburn.Micro.Platform/ViewModelBinder.cs

View workflow job for this annotation

GitHub Actions / build

The name 'message' does not exist in the current context
}
#endif
return unmatchedElements;
Expand Down
Loading