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

missing IDeserializer object? Deserialize(string input) method #828

Closed
FyiurAmron opened this issue Jul 29, 2023 · 2 comments · Fixed by #832
Closed

missing IDeserializer object? Deserialize(string input) method #828

FyiurAmron opened this issue Jul 29, 2023 · 2 comments · Fixed by #832

Comments

@FyiurAmron
Copy link
Contributor

FyiurAmron commented Jul 29, 2023

Is your feature request related to a problem? Please describe.
Currently, there are matching pairs of methods on this interface, but one combination is missing:

    T Deserialize<T>(string input);
    T Deserialize<T>(TextReader input);
    T Deserialize<T>(IParser parser);

    // no object? Deserialize(string input); here :(
    object? Deserialize(TextReader input);
    object? Deserialize(IParser parser);

    object? Deserialize(string input, Type type);
    object? Deserialize(TextReader input, Type type);
    object? Deserialize(IParser parser, Type type); // the "real" method, i.e. the one that the others call in impl

It makes it impossible to call the deserializer this way.

Describe the solution you'd like
Add the missing interface method and implementation. See below for an example implementation for Deserializer class.

Describe alternatives you've considered

static class Extensions {
    public static object? Deserialize(this IDeserializer iSerializer, string input)
    {
        using (StringReader input1 = new StringReader(input))
            return iSerializer.Deserialize((TextReader) input1);
    }
}

or similar (in new .NET/C# versions, the body it can be even as simple as

        using StringReader input1 = new(input);
        return iSerializer.Deserialize(input1);

)

Additional context
In case of "sure, but no manpower, PR welcome", I can gladly do a PR for this as soon as I have some spare time, since it's trivial :D

@EdwardCooke
Copy link
Collaborator

A pr would be very much appreciated. Please be sure to add it to the staticdeserializer as well.

@FyiurAmron
Copy link
Contributor Author

FyiurAmron commented Aug 7, 2023

@EdwardCooke sorry if I'm being dumb here, but can you elaborate on the

Please be sure to add it to the staticdeserializer as well.

part? I've went through StaticDeserializerBuilder (and also StaticSerializerBuilder) and honestly don't know where (and if, TBH) anything should be put there alongside the main change. I mean, those missing methods are just helper methods, the core functionality remains unchanged, and I don't see those kind of helpers as applicable to the StaticXyzBuilder classes (or even present in them ATM). They invoke only the "main" c-tor on Build() calls anyway (which is untampered).

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