NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet
NuGet, #1403 most downloaded on NuGet
TinyMapper - a tiny and quick object mapper for .Net.
Latest stable
3.0.3
Last release 7 years ago
no release in 18 months
Ships unpredictably
gaps range from 8 days to 1.7 years
Some releases are documented
notes for 7 of 12 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
18 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
added: public static object Map(Type sourceType, Type targetType, object source, object target = null)
added: public static object Map(Type sourceType, Type targetType, object source, object target = null)
Thanks to: izaruba
fixed static fields mapping thanks to summitn
fixed static fields mapping thanks to summitn
public class MapWithStaticFields
{
[Fact]
public void MapStaticFields()
{
var source = new SourceStatic();
TinyMapper.Bind<SourceStatic, TargetDto>();
var actual = TinyMapper.Map<TargetDto>(source);
Assert.Equal(SourceStatic.Id, actual.Id);
Assert.Equal(SourceStatic.Name, actual.Name);
}
}
public class SourceStatic
{
public static string Name = "test";
public static int Id = 1;
}
public class TargetDto
{
public int Id { get; set; }
public string Name { get; set; }
}
Thanks to Summitn
Your coding agent can read these notes before it upgrades. Set up the MCP server →
added support supports circular reference mapping
Thanks to: sergiorykov, xihu69
https://github.com/TinyMapper/TinyMapper/releases/tag/v2.1.4-beta
Thanks to: sergiorykov, xihu69
var source = new Node
{
Id = "1",
Next = new Node
{
Id = "2",
Next = new Node
{
Id = "3",
Child = new[]
{
new Node
{
Id = " 123 1"
},
new Node
{
Id = "123 2"
}
}
}
},
Child = new[]
{
new Node
{
Id = "1 1"
},
new Node
{
Id = "1 2"
}
}
};
TinyMapper.Bind<Node, Node>();
var target = TinyMapper.Map<Node, Node>(source);
Assert.Equal(source.Id, target.Id);
Assert.Equal(source.Next.Id, target.Next.Id);
Assert.Equal(source.Next.Next.Id, target.Next.Next.Id);
Assert.Equal(source.Next.Next.Id, target.Next.Next.Id);
Assert.Equal(source.Next.Next.Child, target.Next.Next.Child);
Assert.Equal(source.Child, target.Child);
Improved mapping, i.e. now it's possible to map properties from other classes source.Address.Street
source.Address.Street TinyMapper.Bind<PersonDto, Person>(
config =>
{
config.Bind(source => source.Address.Street, target => target.Street);
config.Bind(source => source.Address.Phone, target => target.Phone);
}
);
https://github.com/TinyMapper/TinyMapper/releases/tag/v2.1.3-beta
source.Address.Street TinyMapper.Bind<PersonDto, Person>(
config =>
{
config.Bind(source => source.Address.Street, target => target.Street);
config.Bind(source => source.Address.Phone, target => target.Phone);
}
);
improved collection mapping (30% faster)
improved collection mapping (30% faster)
The time required to map one object with two collections (int and string), each collection has 100 items
Method | Mean | Error | StdDev |
------------------------------ |----------:|----------:|----------:| CollectionMapping_AutoMapper | 27.696 us | 0.5117 us | 1.2259 us | CollectionMapping_TinyMapper | 6.765 us | 0.0660 us | 0.0618 us | CollectionMapping_Handwritten | 3.521 us | 0.0387 us | 0.0343 us |
https://github.com/TinyMapper/TinyMapper/releases/tag/v2.1.2-beta
Before
| Method | Mean | Error | StdDev |
|---|---|---|---|
| CollectionMapping_AutoMapper | 27.753 us | 0.1789 us | 0.1494 us |
| CollectionMapping_TinyMapper | 9.594 us | 0.0912 us | 0.0853 us |
| CollectionMapping_Handwritten | 3.560 us | 0.0709 us | 0.0729 us |
After
| Method | Mean | Error | StdDev |
|---|---|---|---|
| CollectionMapping_AutoMapper | 27.696 us | 0.5117 us | 1.2259 us |
| CollectionMapping_TinyMapper | 6.765 us | 0.0660 us | 0.0618 us |
| CollectionMapping_Handwritten | 3.521 us | 0.0387 us | 0.0343 us |
Map can be called in parallel to Map methods, but cannot be called in parallel to Bind method
fixed: DeepCloneable member binding with custom mapping
fixed: DeepCloneable member binding with custom mapping
Thanks to: Gaclaudiu
fixed: Case sensitive binding Thanks to: Lecamarade
fixed: Case sensitive binding
Thanks to: Lecamarade
TinyMapper allows to set concrete type if required
TinyMapper allows to set concrete type if required
More Info: http://bit.ly/1DzDlPJ
Thanks to: Teknogecko, Oryol, iEmiya
TinyMapper allows to set concrete type if required, i.e.
public class Source
{
public IList<int> Ints { get; set; }
public List<string> Strings { get; set; }
}
public class Target
{
public List<int> Ints { get; set; }
public IEnumerable<string> Strings { get; set; }
}
TinyMapper.Bind<Source, Target>(config =>
{
config.Bind(target => target.Strings, typeof(List<string>));
});
Thanks to: Teknogecko, oryol
TinyMapper allows to set concrete type if required, i.e.
public class Source
{
public IList<int> Ints { get; set; }
public List<string> Strings { get; set; }
}
public class Target
{
public List<int> Ints { get; set; }
public IEnumerable<string> Strings { get; set; }
}
TinyMapper.Bind<Source, Target>(config =>
{
config.Bind(target => target.Strings, typeof(List<string>));
});
Thanks to: Teknogecko, oryol
Enum? -> Value? and Value? -> Enum?
Thanks to: marcWF2 and qihangnet
Easy mapping members with different names
TinyMapper.Bind<Person, PersonDto>(config =>
{
config.Bind(source => source.LastName, target => target.Surname);
});
source member instead of target memberTinyMapper.Bind<Person, PersonDto>(config =>
{
config.Ignore(x => x.Id); // Id from `Person`
});
Added Dictionary mapping, so you don't need TypeConverter for Dictionary mapping
Dictionary<TKey, TValue> mapping, so you don't need TypeConverter for Dictionary mappingNothing published for this version
``` csharp public class TargetClass { public string FullName { get; set; } }
For instance:
public class TargetClass
{
public string FullName { get; set; }
}
public class SourceClass
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public sealed class SourceClassConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(TargetClass);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
var concreteValue = (SourceClass)value;
var result = new TargetClass
{
FullName = string.Format("{0} {1}", concreteValue.FirstName, concreteValue.LastName)
};
return result;
}
}
Here's additional sample
Thru attribute
[TypeConverter(typeof(SourceClassConverter))]
public class SourceClass
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
or code
TypeDescriptor.AddAttributes(typeof(SourceClass), new TypeConverterAttribute(typeof(SourceClassConverter)));
and finally
TinyMapper.Bind<SourceClass, TargetClass>();
var source = new SourceClass
{
FirstName = "John",
LastName = "Doe"
};
var result = TinyMapper.Map<TargetClass>(source);
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.