-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can I serialize out the results of GetAllForRepository? #1762
Comments
I thought I'd be able to leverage our JSON deserializer to convert the list of issues to a string, like this: var serializer = new Octokit.Internal.SimpleJsonSerializer();
var text = serializer.Serialize(issues);
var recreatedIssues = serializer.Deserialize<IReadOnlyList<Issue>>(text); However it blows up on the second line with this error:
I also tested this with JSON.NET to confirm it wasn't our deserializer to blame, but it has the same error. Our |
Yeah we only serialise request models, not response models @shiftkey the particular error you ran into is with a stringenum wrapper with an empty /unspecified value, which actually happens to be something I ran into with #1760 and am working on fixing There could well be other round trip serialise/deserialise problems after that one is fixed though |
@mylodeon I'm interested in doing something about your stated problem (some way to save/load our response objects) but in the meantime there potentially could be other options for you to explore to For example which GetAllForRepository call is this (issues, PR's, commits, etc)? If you don't actually need ALL of them you can use pagination to query data in more manageable chunks, or use search Api's to specify criteria to hone in on what you are looking for (eg PR's of a certain state or issues with a particular tag or whatever) You could also declare your own DTO class with the fields you care about and use automapper to map our responses to your DTO's which you would then be able to persist/serialise as you need to. In my case I'm doing this and storing certain objects via entity framework in a database |
Final thought... Because we try to have immutable response classes all the parameters have protected setters and the only way to create them is via a constructor... so I wouldn't think normal desetializers like newtonsoft would be able to instantiate our objects (unless it handles classes where only the constructor can be used)? So I'm thinking using our own serializer/deserializer is probably the only way that is likely to be able to handle things easily |
@ryangribble Thanks! I'm using this for issues. For now I am doing SearchIssues to work around it. But it does mean I can't use LINQ to form the majority of my filtering and processing - I have to format my reports effectively into a Github-compatible requests. It's fine for "pre-designed" reports, but not great for REPL-style quick queries. DTOs with Automapper is like... hard work :). j/k. I can do that as an option if need be. |
I tried this today and I ran into the same exact issue (for the same reason, GetAllForRepository is slow). |
I ran into this today as well - will try SearchIssues as a workaround. |
Me too, and the workaround worked. |
👋 Hey Friends, this issue has been automatically marked as |
I just ran into that issue when trying to serialize Team for storing in session storage. It looks like maybe I need to project the Octokit objects into my own DTOs? |
@idflyfish Sorry that you're running into some trouble here. Would you happen to have a snip or repro case that I could use to help chase down this issue? You should be able to use the built-in models - but since things have changed so much since we last supported this - I wouldn't be surprised if the structure of what a team looks like in the SDK would differ from what the GitHub REST API is sending over. Let me know if you have any additional info when you get the chance. Thanks! |
I also ran into this issue to cache the API reponse to session storage with Following issue contained https://api.github.com/repos/yfakariya/msgpack-rpc-cli/issues/5 This is stacktrace:
I hope this info helps you! |
👋 Hey Friends, this issue has been automatically marked as |
GetAllForRepository takes a few minutes to run on our repository.
Is there a way I can serialize the results out to something that I can deserialize back in to something I can query using Linq? (Without building a wrapper around all of Octokit).
I tried a BinaryFormatter, but the Octokit.Issue isn't marked as Serializable.
The text was updated successfully, but these errors were encountered: