-
Notifications
You must be signed in to change notification settings - Fork 47
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
Custom ISerializerExtension is throwing "Recursive dependency detected" exceptions #410
Comments
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details. |
Ah, yes indeed @gmkado the call to
Note that the result of this operation is cached so instantiating a new instance of As for
For some additional context, every object has a "container" context. This could be the root document or the property/field of a parent serializer. Note that a "container" is the start + end tags. Please let me know if you have any further questions around this and I will do my best to answer them for you. 👍 |
Thanks for the clarification, that makes sense regarding the dependency injection, I didn't realize it was cached. Regarding ISerializers vs IContents, can you give an example of when to use one vs the other? As far as I can tell, I can use |
Sure @gmkado let me think about this and see if I can get some sample code for you here to delineate the two scenarios. |
Alright @gmkado I looked into this some more. You are correct in that the approaches you mention are similar. I would say the following about the two:
Worth noting that the serializer returned from So that stated, the For reference, there are about a dozen implementations of When I think of As for examples, I think of So to sum up for Hope that adds some clarification for you. Please let me know if you have any further questions or points that need additional clarification. FWIW I am tagging this post now as |
Doh, I guess I said I was going to provide some code, but got distracted with traveling through the codebase and looking at existing implementations. I figured I would use them instead as they do a better job anyways as, you know, working code. 😅 Hopefully those links provided will help assist in providing some further context and meet the intended effect. Please let me know if that's not the case. 👍 |
@Mike-E-wins Thanks as always for the quick and detailed response. I'm new to coding in general so digging through the codebase has been very helpful in learning how to write decoupled code. That being said, I'm finding it a bit tricky to follow whats going on behind the scenes (I guess those go hand in hand). So this bit was particularly helpful for me:
Is the process of how IContents and ISerializers pass and execute control documented anywhere? I'm trying to look through the code to see how this works but it would be helpful to have a framework in my mind as I go through it. |
Ah so we're actually really in uncharted territory I'm afraid, @gmkado. Earlier in the year (or late last year) we took a pass at improving the documentation and even though we (I) spent a ton of time addressing conceptual concerns I wasn't able to make it into the customization/extension model. The thinking -- besides there being limited time to spend on such matters -- is that the extension model is considered "advanced" so if someone has any questions around this they can ask away and I will do my best to assist. I guess what I should do is have a better strategy/plan around sharing existing code with good examples to get interested developers better on their way. Along such lines, one thing I did want to mention is that, to add to the above, the "root" You can see that on line #19 the
|
Thanks @Mike-E-wins . I do feel like the true power of this library comes from the extensibility, so it would be nice if that were a little more accessible. I wonder if you could have a "dumbed down" version of the ISerializerExtension that could decorate a type's serializer without the dependency injection boilerplate. Ideally I just want to write the ISerializer and register it with its type (similar to IConverter and the v1 IExtendedXmlCustomSerializer). Also, its not clear to me how to use
These can be nested so my xml ends up looking something like
Now this is a very simplified model of what I actually have. I have some command lists that are purely lists and some that have other elements. For the commands that are purely lists, I'd like to intercept the serialization and have it serialize something like:
I.e. clean it up by taking out the superfluous
As you can see from my comments, its not clear to me how to correctly use IFormatWriter and IFormatReader to get what I need. Thanks again for your help! |
Oh man, what you are after here @gmkado is default content, which is something of a sore topic with me, mainly because I have not been able to figure out a way to do it myself. This has been captured in #240. I have given it a go several times now and it's failed due to challenges from the design of the reader. The reader needs a rewrite, pure and simple. As for The best I can do in light of #383 is try to help out with some code for you. I will see if I can put aside some time here in the next day or so to get you something that can provide you some better context/knowledge on how the pieces are put together. |
Looking into this now @gmkado ... one thing I did notice that I wanted to share is that there's this notion of composing serializer, which you can use to essentially intercept the serializer creation pipeline and then further use to decorate created serializers. Here's some code demonstrating that for you: I also like this as it makes use of the
|
I believe we have addressed this issue as much as possible. Ideally we should have some advanced documentation but my time is fully spent in fixing bugs with this project. If, however, you manage to get comfortable around the topic and have something to add, I would be more than happy to accept a pull request. :) In any case, please do let me know if there is any further assistance you require on this issue (or any other) and I will do my best to assist. Closing for now. |
I'm trying to resolve my own references to get more flexibility on how I resolve them (i.e. some of the references come from other documents).
I'm having a hard time getting a custom ISerializerExtension working. I was able to get the example case to work but when I tried replacing ISerializer with ISerializer I got a LightInject "Recursive dependency" error.
I thought it might be due to using IContents vs ISerializers (not really sure what the difference is there) but both attempts throw the same error. I'm showing the test with ISerializers because that's what I'm working with now. Any ideas?
Heres the test:
And here's the error:
The text was updated successfully, but these errors were encountered: