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 Task return value serialization #81

Open
blairconrad opened this issue Jun 18, 2020 · 2 comments · May be fixed by #86
Open

Support Task return value serialization #81

blairconrad opened this issue Jun 18, 2020 · 2 comments · May be fixed by #86
Assignees

Comments

@blairconrad
Copy link
Owner

Split from #79, as proposed by @CableZa.

@blairconrad
Copy link
Owner Author

@CableZa and friends, I have a proof-of-concept of serializing a Lazy<int> (because it was easy and available on all platforms) that I think I can expand to support Task and pretty much anything we want, for all serializers. I'm going to assign this issue to myself.

@blairconrad blairconrad self-assigned this Jun 20, 2020
@blairconrad
Copy link
Owner Author

Sketch of my plan: to implement type converters that will transform an unserializable type into a serializable representation, before we hit the serializer, and likewise to convert back.
Rough and provisional interface for such a converter:

interface ITypeConverter
{
     /// <summary>
    /// Potentially converts an unserializable object to a more serializable form.
    /// </summary>
    /// <param name="input">An input object.</param>
    /// <param name="output">An output object. Will be assigned to a simpler representation of <paramref name="input"/>, if this converter knows how.</param>
    /// <returns><c>true</c> if the conversion happened, otherwise <c>false</c>. Good for building a chain of responsibility.</returns>
    bool ConvertForSerialization(object? input, out object? output);

    /// <summary>
    /// Potentially converts the serializable form of an object back to its unserializable form.
    /// </summary>
    /// <param name="deserializedType">The desired deserialized type.</param>
    /// <param name="input">An input object.</param>
    /// <param name="output">An output object. Will be reconstituted from it's simpler representation as <paramref name="input"/>, if this converter knows how.</param>
    /// <returns><c>true</c> if the conversion happened, otherwise <c>false</c>. Good for building a chain of responsibility.</returns>
    bool ConvertForDeserialization(Type deserializedType, object? input, out object? output);
}

That'll probably change a bit as I work. My initial plan is to build in a few converters for some framework types, and allow a plugin mechanism for clients to add their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant