DeepCopy.Fody 1.0.16

dotnet add package DeepCopy.Fody --version 1.0.16                
NuGet\Install-Package DeepCopy.Fody -Version 1.0.16                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DeepCopy.Fody" Version="1.0.16" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DeepCopy.Fody --version 1.0.16                
#r "nuget: DeepCopy.Fody, 1.0.16"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DeepCopy.Fody as a Cake Addin
#addin nuget:?package=DeepCopy.Fody&version=1.0.16

// Install DeepCopy.Fody as a Cake Tool
#tool nuget:?package=DeepCopy.Fody&version=1.0.16                

build nuget

This is an add-in for Fody

Icon

Generate copy constructors and extension methods to create a new instance with deep copy of properties.

Usage

See Wiki

See also Fody usage.

NuGet installation

Install the DeepCopy.Fody NuGet package and update the Fody NuGet package:

PM> Install-Package Fody
PM> Install-Package DeepCopy.Fody

The Install-Package Fody is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.

Add to FodyWeavers.xml

Add <DeepCopy/> to FodyWeavers.xml

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <DeepCopy/>
</Weavers>

Sample

Source at SmokeTest\ReadMeSample.cs

Your Code
public class ReadMeSample
{
  public ReadMeSample() { }
  [DeepCopyConstructor] public ReadMeSample(ReadMeSample source) { }
  
  public int Integer { get; set; }
  public ReadMeEnum Enum { get; set; }
  public DateTime DateTime { get; set; }
  public string String { get; set; }
  public IList<ReadMeSample> List { get; set; }
  public IDictionary<ReadMeEnum, ReadMeSample> Dictionary { get; set; }
}
What gets compiled
public class ReadMeSample
{
  public ReadMeSample() { }

  public ReadMeSample(ReadMeSample source)
  {
    this.Integer = source.Integer;
    this.Enum = source.Enum;
    this.DateTime = source.DateTime;
    this.String = source.String != null ? new string(source.String.ToCharArray()) : (string)null;
    if (source.List != null)
    {
      IList<ReadMeSample> readMeSampleList = (IList<ReadMeSample>)new System.Collections.Generic.List<ReadMeSample>();
      foreach (ReadMeSample source1 in (IEnumerable<ReadMeSample>)source.List)
        readMeSampleList.Add(source1 != null ? new ReadMeSample(source1) : (ReadMeSample)null);
      this.List = readMeSampleList;
    }
    if (source.Dictionary == null)
      return;
    IDictionary<ReadMeEnum, ReadMeSample> dictionary = (IDictionary<ReadMeEnum, ReadMeSample>)new System.Collections.Generic.Dictionary<ReadMeEnum, ReadMeSample>();
    foreach (KeyValuePair<ReadMeEnum, ReadMeSample> keyValuePair in (IEnumerable<KeyValuePair<ReadMeEnum, ReadMeSample>>)source.Dictionary)
    {
      ReadMeEnum key = keyValuePair.Key;
      ReadMeSample readMeSample = keyValuePair.Value != null ? new ReadMeSample(keyValuePair.Value) : (ReadMeSample)null;
      dictionary[key] = readMeSample;
    }
    this.Dictionary = dictionary;
  }
  
  public int Integer { get; set; }
  public ReadMeEnum Enum { get; set; }
  public DateTime DateTime { get; set; }
  public string String { get; set; }
  public IList<ReadMeSample> List { get; set; }
  public IDictionary<ReadMeEnum, ReadMeSample> Dictionary { get; set; }
}

Decompiled with JetBrains dotPeek 2021.2.1 Build 212.0.20210826.112035

Icon

Icon copy by projecthayat of The Noun Project

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

  • .NETStandard 2.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.16 787 4/25/2022
1.0.16-build.39 135 4/25/2022
1.0.16-build.38 130 3/29/2022
1.0.16-build.37 198 10/27/2021
1.0.16-build.36 170 10/26/2021
1.0.16-build.35 150 10/24/2021
1.0.16-build.34 234 10/17/2021
1.0.16-build.33 150 10/13/2021
1.0.16-build.32 158 10/9/2021
1.0.16-build.31 176 10/9/2021
1.0.16-build.30 188 10/9/2021
1.0.15 447 10/9/2021
1.0.14 2,224 8/28/2020
1.0.12 643 9/29/2019
1.0.11 560 7/22/2019
1.0.10 519 7/21/2019
1.0.9 576 6/19/2019
1.0.8 620 6/7/2019
1.0.7 594 4/12/2019
1.0.6 595 4/12/2019
1.0.5 587 4/8/2019
1.0.4 628 4/4/2019
1.0.3 627 4/2/2019
1.0.2 609 4/1/2019
1.0.1 725 4/1/2019
1.0.0 709 3/30/2019