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

Implement ICloneable for sgen objects #9

Closed
bruno-f-cruz opened this issue Nov 6, 2023 · 2 comments
Closed

Implement ICloneable for sgen objects #9

bruno-f-cruz opened this issue Nov 6, 2023 · 2 comments

Comments

@bruno-f-cruz
Copy link
Contributor

This would allow to copy and modify fields easily.

@glopesdev glopesdev changed the title Implement IClonable for sgen objects Implement ICloneable for sgen objects Jan 6, 2024
@glopesdev
Copy link
Member

glopesdev commented Jan 6, 2024

Implementing ICloneable is now actively discouraged in the MSDN reference manual. The reason seems to be ambiguity around whether Clone should perform a deep or shallow copy.

For C# record types the auto-generated implementation now provides a shallow copy constructor and a new with operator which allows creating modified copies of existing record objects.

#15 and #13 provide the first half of such an implementation, by introducing copy constructors for all generated classes and an overload for triggering copy on input. This allows using the InputMapping operator to pull any desired properties from the input, while allowing specification of other properties.

Later we can take this approach one step further either by making the copy constructor public, or exposing a Copy method to allow emulating something similar to the with operator. At the moment I feel we should experiment a bit first with the workflow-based functionality to get a better feel about future requirements before committing one way or the other.

@glopesdev
Copy link
Member

Closing this for now in favor of #13.

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

2 participants