Initialize 0.2.2
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.2
NuGet\Install-Package Initialize -Version 0.2.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Initialize --version 0.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Initialize, 0.2.2"
#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.2 // Install Initialize as a Cake Tool #tool nuget:?package=Initialize&version=0.2.2
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
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-DVEUFE : .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.178 us | 0.1041 us | 880 B |
| AutoMapper | 5.857 us | 0.3292 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 | 349 | 11/28/2023 |
0.2.8 | 308 | 2/17/2023 |
0.2.7 | 252 | 2/17/2023 |
0.2.6 | 249 | 2/16/2023 |
0.2.4 | 241 | 2/16/2023 |
0.2.3 | 247 | 2/15/2023 |
0.2.2 | 253 | 2/15/2023 |
0.2.1 | 268 | 2/15/2023 |
0.0.2-alpha | 148 | 2/14/2023 |
0.0.1-alpha | 146 | 2/14/2023 |