Dolly 0.0.7
dotnet add package Dolly --version 0.0.7
NuGet\Install-Package Dolly -Version 0.0.7
<PackageReference Include="Dolly" Version="0.0.7"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Dolly --version 0.0.7
#r "nuget: Dolly, 0.0.7"
// Install Dolly as a Cake Addin #addin nuget:?package=Dolly&version=0.0.7 // Install Dolly as a Cake Tool #tool nuget:?package=Dolly&version=0.0.7
<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 />
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 aspartial
. - Add
[CloneIgnore]
to any property or field that you don't want to include in the clone. - Call
DeepClone()
orShallowClone()
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
};
}
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.