You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar methods exist, and work fine, but this one will return (when awaited) a SizeF of 0, 0. (Can you guess why? I couldn't — I assumed something was initialized wrong on the JS end.)
I had to add various logging code manually to figure out the issue: Leaflet's getSize() returns a Point, so its properties, from the C# side, would become X and Y, not Width and Height.
Trouble is, Blazor doesn't throw an exception, or log a warning — it just maps nothing, and thus the SizeF has an empty width.
Describe the solution you'd like
The methods on IJSInterop should have logging:
there should be Debug (perhaps Trace) logging to always log (even in the presumed success case) how the C# in arguments get serialized to JSON, how the JS result comes back as JSON, and how that gets mapped back to C#
there should be Warn logging to log when a mapping from JS back to C# didn't succeed. Due to lack of static typing, the reverse can't be validated, but this direction can: JSInterop knows which properties the generic type TValue has, and it knows if the returned JSON contains a property that the type does not.
there should especially be a Warn logging if no properties were mapped even though a JSON object came back. That's rarely got to be the intended result.
Additional context
1 of those would've helped me track down dotnet/runtime#39208 a lot faster. 2/3 would have helped me today.
The text was updated successfully, but these errors were encountered:
Thanks for contacting us.
We rely on the System.Text.Json serializer for this, which currently doesn't support logging. Feel free to file a separate issue on the dotnet/runtime repo to add that support. When done, we can enable it on our side too.
Is your feature request related to a problem? Please describe.
I am trying to wrap a JS library (in this case, Leaflet), but the tooling makes mistakes hard and time-consuming to figure out.
For example, consider this JS code:
And then this C# wrapper around it:
Similar methods exist, and work fine, but this one will return (when
await
ed) aSizeF
of 0, 0. (Can you guess why? I couldn't — I assumed something was initialized wrong on the JS end.)I had to add various logging code manually to figure out the issue: Leaflet's
getSize()
returns aPoint
, so its properties, from the C# side, would becomeX
andY
, notWidth
andHeight
.Trouble is, Blazor doesn't throw an exception, or log a warning — it just maps nothing, and thus the
SizeF
has an empty width.Describe the solution you'd like
The methods on
IJSInterop
should have logging:TValue
has, and it knows if the returned JSON contains a property that the type does not.Additional context
1 of those would've helped me track down dotnet/runtime#39208 a lot faster.
2/3 would have helped me today.
The text was updated successfully, but these errors were encountered: