-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Make a serialization object for JS interops #5701
Comments
I am not sure I understand the issue correctly. I guess it's about the And you want to make sure it gets serialized like that (in camelCase ) no matter the externalities? Can you describe the externalities? To my understanding the camelCasing is already there. When the object arrives to js, all the Or did I misunderstood the issue completely @stsrki ? |
@tesar-tech if I remember correctly the point is that the serializer could be configured in a global way that could affect any convention we might rely on. So we shouldn't rely on conventions that are susceptible to be changed, if they can be that is. |
@David-Moreira It is not possible dotnet/runtime#31094 and also marked as |
So far, when we serialized the object to JS, we relied mostly on the built-in JSON serializer, assuming everyone would have camelCase settings. But assuming it is not ideal and we need to handle it ourselves. @tesar-tech The Tooltip you mentioned was just the first iteration of trying to solve the problem. So, the plan is to have a dedicated serialization object with all the field names properly named using the JSON name attribute. We have already made it on the Video component. See:
We basically need to look everywhere where we have a |
Oh, yeah. You mean making the object that goes to js a strong type... I agree with that. But I don't see a reason why to include the Also maybe records instead of class to make it more condensed? Or at least use require keyword to force all the important stuff to be declared..? But that's probably for a different discussion or pr... So what is left here? The JsOptions for tooltip? |
We want this make sure everything is handled properly. So all file must have JsonPropertyName. Tooltip also need to have a new object. As for what kind of. Stick with the class. As we have it for Video options. |
I think Blazor is always serializing to Camelcase.
Also, I found this comment from a Blazor team member saying that they don't have plans to change it as it could affect Blazor itself. dotnet/aspnetcore#38144 So we might not need to do this at all. |
@stsrki But that's precisely what @tesar-tech was saying. There's currently no way to configure the options globally. I personally was under the impression it was, since it was implied so before. I'd still take concrete objects over anonymous objects as an improvement to the code base. |
I was also under such an impression. But I never tried it in the past.
Agree. At least make concrete objects even though we might not need to have |
Yes. If we care about it. That's a way to go I guess, not doing guess work and hoping nothing external happens in my opinion.
Originally posted by @David-Moreira in #5691 (comment)
The text was updated successfully, but these errors were encountered: