Deep copy an object: retarget net10.0, drop AutoMapper, fix the benchmark - #2236
Open
vladimir-pecanac-main wants to merge 2 commits into
Open
vladimir-pecanac-main wants to merge 2 commits into
vladimir-pecanac-main wants to merge 2 commits into
Conversation
…mark - Both projects net7.0 to net10.0; BenchmarkDotNet 0.15.8, Newtonsoft.Json 13.0.4, Microsoft.NET.Test.Sdk 18.10.1, xunit 2.9.3, xunit.runner.visualstudio 4.0.0, coverlet.collector 10.0.1. DeepCopy 1.0.3 and FastDeepCloner 1.3.6 are already the newest published versions. - AutoMapper removed: the package reference, the mapper in DeepCopyMaker, its benchmark and its test. Every MIT-licensed AutoMapper version is inside GHSA-rvv3-g6hj-g44x (NU1903 on restore) and the patched versions are commercially licensed. - Expression trees: the compiled delegate is cached per type, and nested objects go through the same cache, instead of compiling on every call. - Program.cs no longer disables the optimizations validator, and each technique now copies, modifies and prints its own fresh original, so the shallow copy output is reachable again. - Copy constructors on Person and Address, with a test that the nested Address is not shared, and a copy constructor benchmark. - Nullable warnings fixed with ArgumentNullException.ThrowIfNull on the inputs.
… why BenchmarkDotNet 0.15.8 refuses to run this benchmark without ConfigOptions.DisableOptimizationsValidator: FastDeepCloner 1.3.6 ships an assembly built without optimizations, and the validator checks every referenced assembly. The switch stays, with a comment saying why and that the project must be run with -c Release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates the sample for "Deep Copy and Clone an Object in C#" (csharp-intermediate-topics/DeepCopyInCSharp). This PR touches only this folder.
Changes:
Verified locally on SDK 10.0.302, runtime .NET 10.0.10, Windows 10 (AMD Ryzen 5 3600): dotnet build -c Release, 0 warnings, 0 errors. dotnet test, 10 passed, 0 failed. dotnet list package --vulnerable --include-transitive reports no vulnerable packages in either project. The benchmark was re-run in Release on the same machine.