BindableObject logged warnings should provide better context. #23761
Unanswered
DanTravison
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to diagnose the following runtime warning but the logged message does not provide sufficient context:
Microsoft.Maui.Controls.BindableObject: Warning: Cannot convert 2 to type 'System.Single'
The warning is difficult to diagnose for any non-trivial UI
At a minimum, the logged warning should include the target property name:
Application.Current?.FindMauiContext()?.CreateLogger()?.LogWarning($"Cannot convert {value} to type '{property.ReturnType}' for {property.PropertyName}.");
While this brings the logged warning in line with other warnings, there is still sufficient ambiguity when the target property is used across multiple types (ie.g, ForegroundColor, FontFamily, Margin, etc).
Ideally, these logged warnings should consistently include the type name and property name.
For example:
Microsoft.Maui.Controls.BindableObject: Warning: Cannot convert 2 to type 'System.Single' for MyCustomControl.Stroke
This information would provide a concrete starting point for diagnosing the cause.
Beta Was this translation helpful? Give feedback.
All reactions