Skip to content

Commit

Permalink
Fix several Clone pathways that would incorrectly Record objects with…
Browse files Browse the repository at this point in the history
… a TreatAsValuelike converter, also improving performance.
  • Loading branch information
zorbathut committed Oct 2, 2024
1 parent ef9e10e commit 04d46ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ All notable changes to this project will be documented in this file.
### Breaking
* Dec doesn't guarantee what order Decs are initialized in, and it still doesn't . . . but it was *pretty consistent*, and boy, did the above change seriously scramble the order they tend to get initialized in! If you have load dependencies, even if you don't realize that you do, don't be surprised if stuff breaks. Future versions of Dec might include a Dev Mode that intentionally randomizes load order (within the bounds of dependencies) to help catch these issues.

### Fixed
* Several Clone pathways that would incorrectly Record objects with a TreatAsValuelike converter.

### Improved
* Clone performance on Dictionaries with asymmetrical copy-as-valuelike parameters.
* Clone performance on Dictionaries with asymmetrical clone-as-valuelike parameters.
* General Clone performance regarding asymmetrical clone-as-valuelike parameters.


## [v0.7.1]
Expand Down
2 changes: 1 addition & 1 deletion src/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ internal static void ComposeElement(WriterNode node, object value, Type fieldTyp

// Now we have things that *could* be references, but aren't.

if (node.AllowCloning && valType.GetCustomAttribute<CloneWithAssignmentAttribute>() != null)
if (node.AllowCloning && UtilType.CanBeCloneCopied(valType))
{
node.WriteCloneCopy(value);

Expand Down
2 changes: 1 addition & 1 deletion src/WriterClone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void CreateResult(bool sharable)
// this needs to deal with anything that has complicated constructor behavior
var originalType = original.GetType();
bool done = false;
if (originalType.GetCustomAttribute<CloneWithAssignmentAttribute>() != null)
if (UtilType.CanBeCloneCopied(originalType))
{
// okay
result = original;
Expand Down

0 comments on commit 04d46ca

Please sign in to comment.