Dolly 0.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dolly --version 0.0.6                
NuGet\Install-Package Dolly -Version 0.0.6                
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="Dolly" Version="0.0.6">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dolly --version 0.0.6                
#r "nuget: Dolly, 0.0.6"                
#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 Dolly as a Cake Addin
#addin nuget:?package=Dolly&version=0.0.6

// Install Dolly as a Cake Tool
#tool nuget:?package=Dolly&version=0.0.6                

<p align="center"> <a href="https://github.com/AnderssonPeter/Dolly"> <img src="icon_white.svg" alt="Logo" width="80" height="80"> </a>

<h3 align="center">Dolly</h3>

<p align="center"> Clone .net objects using source generation <br /> <br /> · <a href="https://github.com/AnderssonPeter/Dolly/issues">Report Bug</a> · <a href="https://github.com/AnderssonPeter/Dolly/issues">Request Feature</a> · </p> </p> <br />

NuGet version Nuget GitHub license

unit tests Testspace tests Coverage Status

Table of Contents

About The Project

Generate c# code to clone objects on the fly.

Getting Started

  • Add the Dolly nuget and add [Clonable] attribute to a class and ensure that the class is marked as partial.
  • Add [CloneIgnore] to any property or field that you don't want to include in the clone.
  • Call DeepClone() or ShallowClone() on the object.

Example

[Clonable]
public partial class SimpleClass
{
    public string First { get; set; }
    public int Second { get; set; }
    [CloneIgnore]
    public float DontClone { get; set; }
}

Should generate

partial class SimpleClass : IClonable<SimpleClass>
{
    
    object ICloneable.Clone() => this.DeepClone();

    public SimpleClass DeepClone() =>
        new SimpleClass()
        {
            First = First,
            Second = Second
        };

    public SimpleClass ShallowClone() =>
        new SimpleClass()
        {
            First = First,
            Second = Second
        };
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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
0.0.7 82 12/5/2024
0.0.6 73 12/5/2024