Skip to content
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

Support serialization of CLR Classes #2025

Closed

Conversation

joaompneves
Copy link
Contributor

@joaompneves joaompneves commented Apr 19, 2017

Bound objects (using RegisterAsyncJsObject) now can have methods that return Structs and Classes (before only structs were allowed). This PR introduces support for classes (returned to the JS side) serialization (only public fields will be serialized). Check the Binding examples: asyncStructsArray and asyncClassesArray.

…ted)

Replaced CreateInstanceInternal from ModelBindingExtensions.cs with .net framework Activator.CreateInstance that does the job better
@amaitland
Copy link
Member

Support CLR Classes serialization when before only Structs were allowed

In what context? Assuming you mean allow IJavascriptCallback to use a classes? Please be more descriptive, if you weren't the author of this PR would you be able to read the description and know what the changes were did?

CLR Classes can now also be returned to the JS side.

What does this mean exactly?

@@ -36,7 +36,7 @@ public static T CreateInstance<T>(this Type type, bool nonPublic = false)
/// <param name="nonPublic"><see langword="true"/> if a non-public constructor can be used, otherwise <see langword="false"/>.</param>
public static object CreateInstance(this Type type, bool nonPublic = false)
{
return CreateInstanceInternal(type, nonPublic);
return Activator.CreateInstance(type, nonPublic);
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this change? How does it relate to structs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Structs have implicit public parameterless constructors and the CreateInstanceInternal wasn't able to find that constructor. So I replaced with the Activator.CreateInstance which does the job right.

Copy link
Member

Choose a reason for hiding this comment

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

Much clearer, thank you.

@amaitland
Copy link
Member

Please provide an example that demos your changes.

@amaitland amaitland added this to the 59.0.0 milestone Apr 20, 2017
@amaitland
Copy link
Member

Will look at merging this soon, we need to add support for Properties as well, currently only Fields are supported which was fine for when only supporting Structs. Should be trivial to add to the serializer.

@joaompneves
Copy link
Contributor Author

Can't the properties support be made in another pull request and merge this one?

@amaitland
Copy link
Member

Can't the properties support be made in another pull request and merge this one?

I'd prefer for this to be complete. What's the advantage of merging this now?

@joaompneves
Copy link
Contributor Author

I would like to move to cefsharp master other than maintaining my own branch with fixes. But I don't have bandwidth to do those changes now.

@perlun
Copy link
Member

perlun commented Dec 1, 2017

@joaompneves This one has gone a bit stale. Would you have a chance to update it to resolve the conflicts?

@amaitland amaitland modified the milestones: 59.0.0, 63.0.0 Dec 13, 2017
@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@joaompneves
Copy link
Contributor Author

Not working with recent changes

@perlun
Copy link
Member

perlun commented Dec 27, 2017

@amaitland Do you think this is superseded by the recent JSB changes you did? I am thinking about 7a0b06a.

(Note: haven't looked at the PR myself.)

@amaitland
Copy link
Member

Support for returning a Class from an async bound method has been added in c303e1c

Returning properties and fields for both structs and classes is now possible (async bound objects only)

@amaitland amaitland mentioned this pull request Jan 17, 2018
26 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants