Initialize 0.2.4
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Initialize --version 0.2.4
NuGet\Install-Package Initialize -Version 0.2.4
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="Initialize" Version="0.2.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Initialize --version 0.2.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Initialize, 0.2.4"
#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 Initialize as a Cake Addin #addin nuget:?package=Initialize&version=0.2.4 // Install Initialize as a Cake Tool #tool nuget:?package=Initialize&version=0.2.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Overview
High performance automatic DTO mapper and properties initializer based on Roslyn dynamic code and compilation
Example Usage
var test = new Test();
var test2 = new Test2();
// INITIALIZER EXAMPLE
test.Dump("Test Pre Init");
// 1.Optional If you want to manipuate the default initialization logic.
Initializer<Test>.Template.Clear();
Initializer<Test>.Template.Add(typeof(string),
(obj, propInfo) => "string.Empty");
Initializer<Test>.Template.Add(typeof(Nullable<>),
(obj, propInfo) => string.Format("{0}.{1}!.InitValueOrDefault()", obj, propInfo.Name));
Initializer<Test>.Template.Add(typeof(ValueType),
(obj, propInfo) => string.Format("{0}.{1}.InitValueOrDefault()", obj, propInfo.Name));
// 2. Call initialize
Initializer<Test>.Initialize(test);
test.Dump("Test Post Init");
//MAPPER EXAMPLE
test2.Dump("Test2 Pre Map");
Mapper<Test, Test2>.Map(test, test2);
test2.Dump("Test2 Post Map");
Mapper Benchmarks
Initializer's Mapper is roughly 4x faster than AutoMapper...
BenchmarkDotNet=v0.13.4, OS=Windows 11 (10.0.22621.1265)
Intel Core i9-10980XE CPU 3.00GHz, 1 CPU, 36 logical and 18 physical cores
.NET SDK=7.0.103
[Host] : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Job-CCLJAY : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Jit=RyuJit Runtime=.NET 7.0 Arguments=/p:Optimize=true
InvocationCount=1 LaunchCount=1 RunStrategy=Throughput
UnrollFactor=1
| Method | Mean | Error | Allocated |
|----------------- |---------:|----------:|----------:|
| InitializeMapper | 2.204 us | 0.1209 us | 880 B |
| AutoMapper | 7.990 us | 0.6964 us | 880 B |
Feedback, Suggestions and Contributions
Are all welcome!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- System.CodeDom (>= 6.0.0)
-
net7.0
- Microsoft.CodeAnalysis.CSharp (>= 4.4.0)
- System.CodeDom (>= 6.0.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 |
---|---|---|
0.3.2 | 362 | 11/28/2023 |
0.2.8 | 311 | 2/17/2023 |
0.2.7 | 255 | 2/17/2023 |
0.2.6 | 252 | 2/16/2023 |
0.2.4 | 246 | 2/16/2023 |
0.2.3 | 252 | 2/15/2023 |
0.2.2 | 258 | 2/15/2023 |
0.2.1 | 273 | 2/15/2023 |
0.0.2-alpha | 151 | 2/14/2023 |
0.0.1-alpha | 149 | 2/14/2023 |