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

#enhancement Partial deep-cloning #13

Open
thelazydogsback opened this issue Jun 5, 2020 · 0 comments
Open

#enhancement Partial deep-cloning #13

thelazydogsback opened this issue Jun 5, 2020 · 0 comments

Comments

@thelazydogsback
Copy link

I have a case where I want deep-cloned objects, but not too deep...

One way to do this would be to have a callback on DeepClone that got called at code-gen time with the name and type of the object that's about to have code generated for it. (Or you could include the whole provenance of the type built during the recursion, so it would have a path of names/types.)
If I return false (by looking at the name of the class or field, or custom attrs on the type etc.), then codegen won't build code that clones below that level.

You could also include a second callback -- if that one is present, then it is called at run-time rather than codegen time -- this way deep clone control could also depend on values, through the cloning will be slower. (If deep cloning doesn't use codegen then there is only the 2nd type of callback.)

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

No branches or pull requests

1 participant