Skip to content

Releases: AutoMapper/AutoMapper

4.2.0

28 Jan 04:04
Compare
Choose a tag to compare

As part of this release we had 42 issues closed.

The major change with 4.2 is the static API is marked as obsolete in favor of a new instance-based API. The static API will be removed with 5.0.

Features

  • #1043 Obsolete Mutable Profile calls
  • #1034 Mapping engine cleanup
  • #1031 Non-static version of Mapper
  • #1025 We can resolve optional parameters
  • #983 Change MemberInfo to IValueResolver
  • #980 Support expand with collections
  • #955 Add case sensitivity option for DefaultName comparer
  • #866 Mapping Dynamic Object to an Entity Framework DataObject
  • #670 Does AutoMapper support conventions?

Improvements

  • #1041 Marking Profile as abstract and Configure method abstract
  • #1039 Read only configuration
  • #1029 Fix ConcurrentDictionary issues
  • #1023 Am I doing maps to constructors wrong?
  • #998 Expand everything on the path to the passed member
  • #996 Explicit expansion is not transitive
  • #982 Max depth
  • #981 Better exception message
  • #966 Report missing includes bug 533
  • #960 Fix Conventions and Generic TypeMaps not caching
  • #958 Include base inheritance bug 911
  • #957 ProjectTo only reading from type map cache and not trying to resolve.
  • #956 Fixed duplicated path in the exception message
  • #953 Make dest property's name type pass over correctly
  • #937 Fix for #936
  • #936 Mapping from a null array doesn't overwrite not null array with empty array when AllowNullCollections is false
  • #911 Resolver is not inherited in some cases
  • #533 Can't find missing mappings in included mapping.
  • #514 Make it easier to create a MappingEngine instance

Bugs

  • #1044 Passing test for #1040
  • #1040 An empty integer collection doesn't map over a collection with values.
  • #1022 NullReferenceException using AddConditionalObjectMapper (not when using empty CreateMap) on SECOND attempt to map value
  • #994 Overwrite the context.DestinationType only if another destination typ…
  • #993 Mapper.AssertConfigurationIsValid() throws NullReferenceException for Nullable -> Nullable property map
  • #990 Removed DataReaderMapperYieldReturnEnabled; reverted ConstructorMappi…
  • #968 Fix for #967
  • #905 warning CS3001: Argument type 'AutoMapper.IConfiguration' is not CLS-compliant

Where to get it

You can download this release from nuget

4.1.1

26 Oct 21:59
Compare
Choose a tag to compare

This is a maintenance release to fix some regressions introduced in the 4.1.0 release and some issues in the NuGet package metadata.

As part of this release we had 8 issues closed.

Bugs

  • #954 GetUnmappedPropertyNames() seems broken in 4.1.0
  • #950 Automatically-mapped Properties are now case sensitive
  • #949 Breaking Change in 4.1.0 ProjectTo(IMappingEngine) overload
  • #945 AutoMapper 4.1.0 Exception with Proxy on Inherited object with Entity Framework
  • #916 Can't update from 3.3.1 to 4.0.4 via NuGet (Xamarin.Android)
  • #915 Cannot update to 4.0.4 on a Xamarin project (android)
  • #856 Can't add AutoMapper 4.x to Xamarin.Forms project
  • #817 Failed to compile the generated registrar code - Automapper 4.0.4 - Xamarin in Release Mode

Where to get it

You can download this release from nuget

4.1.0

22 Oct 03:01
Compare
Choose a tag to compare

As part of this release we had 49 issues closed.

Features

Improvements

  • #933 ProjectUsing for the entity being queried
  • #929 Allow custom factories in PlatformAdapter
  • #927 ProxyGenerator injection support
  • #894 Fixed Issues with property map inheritance
  • #853 Added Serializable attribute to AutoMapperMappingException
  • #849 Initial types in the resolution context
  • #840 Mapping and Projecting enum strange behavior
  • #836 Obsolete all Project.To and replace with ProjectTo
  • #830 Projections should honour As
  • #827 Use the constructor map only when we can resolve parameters
  • #824 The test execution process crashed while running the tests
  • #822 AutoMapper 4.0.4 - How to fix this breaking change: Base class mapping is now default for derived class mapping
  • #816 Fix for #815
  • #815 Strange issue with Automapper 4 and overloaded constructors
  • #624 Consistent ResolveUsing and ConvertUsing interfaces
  • #551 Error: Type does not have a default constructor when using destination override and abstract types

Bugs

  • #941 Inheritance bug 910
  • #924 Derived type is created instead of requested type
  • #920 Fix for #918
  • #914 NestedDtos
  • #912 Auto-selecting child class even if you map from the parent one
  • #910 Unexpected behavior of AllowNullDestinationValues and Map(object) (Part 2)
  • #909 DTOs with ctors issue when mapping ef models
  • #893 Incorrect mapping chosen when immediate source type is not mapped.
  • #887 Subtype mappings declares using As() or Include() are ignored when mapping subtypes of the subtype.
  • #877 Non generic ConstructProjectionUsing bug
  • #868 As<>() is completely ignored. Can't specify subtypes to use in mapping.
  • #857 Nested explicit expand bug 838
  • #847 AutoMapper 4 targeting wrong constructor on instantiation
  • #846 Fix typo in AfterMap xml comment
  • #844 RT error calling CreateMap: Cannot find a field or property named X
  • #842 InvalidCastException when using mapping inheritance
  • #841 StackOverflowException on « GetCustomAttributes » when mapping Enum to Enum
  • #838 StackOverflowException with ExplicitExpand
  • #833 Fix for #832
  • #832 ReverseMap and ReplaceMemberName don't work together
  • #828 Overriding destination type with .As<> does not work as in 3.3.1.0
  • #825 System.AggregateException incluided in AutoMapper 4.0.4
  • #823 Overlapping assembly references after updating to 4.0.4
  • #819 Mapping inheritance doesn't work in 4.0.4
  • #812 Fixed misspelling of 'extension' in intellisense comments

Where to get it

You can download this release from nuget

4.0.3

05 Aug 22:18
Compare
Choose a tag to compare

Adds a UAP target to fix #810

4.0.1

05 Aug 18:47
Compare
Choose a tag to compare

As part of this release we had 1 issue closed.

This is a patch release for a bad nuspec file.

Bug

  • #811 Specify dependencies for .NET Core

Where to get it

You can download this release from nuget

4.0.0

05 Aug 16:38
Compare
Choose a tag to compare

As part of this release we had 198 commits which resulted in 77 issues being closed.

This release supports a wide variety of platforms, and consolidates the assemblies so that each platform only references one assembly. It supports:

  • .NET 4.0 +
  • Silverlight 5+
  • Windows Phone 8
  • Windows Phone 8.1
  • netcore45 apps
  • DNX 4.6
  • Anything that works with "dotnet"

Features

Improvements

  • #801 Fixes Include Seal() Problems #762 #683
  • #792 Exclude object methods
  • #782 Check if we are able to construct the destination object
  • #781 Dynamically map arrays
  • #780 Nullable int to nullable enum
  • #777 NullReferenceException when mapping nullable int to nullable enum
  • #771 Return also methods from base types when looking for source members
  • #770 Support multidimensional arrays
  • #769 Mapping a collection from an abstract base class via "Get" convention fails
  • #766 Resolve read-only filed mapping bug
  • #765 Unable to map type with read-only filed
  • #762 Polymorphic collections example does not work in latest 4.0 release.
  • #759 The expression mapper doesn't respect ConstructorParameterMaps; #654
  • #755 Possibility to define the MapFrom also by a string
  • #750 Nested mapping projections with explicit expanding bug 688
  • #749 AutoMapper.targets causing duplicate item error using Web Publishing
  • #743 Enum to nullable enum
  • #741 Non existing property bug 733
  • #733 Better error message when cannot find property
  • #724 FindTypeMapFor ignores type parameters when src/dest objects passed
  • #718 Slow Initialization
  • #712 AutoMapper doesn't support multi-dimensional arrays
  • #710 Enum -> Enum? mapping fails
  • #687 No .pdb files in nuget package
  • #683 IncludeBase must come before base overrides
  • #669 Automapper on 64 bit device with Xamarin Unified
  • #667 Error while building web application and class library using msbuild
  • #660 AssertConfigurationIsValid collect all errors rather than throw first one
  • #649 Fix ExpressionMapper error for sub property expression conversion
  • #648 Mapping Expressions with ICollection
  • #646 Nested Project().To(null, params string[] membersToExpand). How to?
  • #628 DynamicMap doesn't map arrays
  • #625 ConstructUsing does not throw exception or gives warning when null returned
  • #592 Support public readonly fields
  • #573 AutoMapperMappingException.Message can throw Exception
  • #566 [Feature] Add Global Ignore By Property Type
  • #565 Guidance on configuration is fractured
  • #561 Redundant IProjectionExpression, use ProjectTo<>() instead of Project().To<>()
  • #542 Related to issue #91, Source has no property named Type, Target does have property name Type

Bugs

  • #798 IEnumerable to ISet
  • #797 DynamicMap threading issues
  • #794 A passing test for #154
  • #789 Only apply EnumerableMapper to IList existing destination
  • #784 Only use the AssignableArrayMapper if the elements of the arrays are …
  • #753 Call the options after/before hooks only for the root map operation
  • #742 MapFrom subquery unexpected (incorrect) result
  • #740 Enum to string bug 720
  • #738 Int to nullable decimal bug 732
  • #734 AssertConfigurationIsValid hangs on recursive classes.
  • #732 int to nullable decimal fails
  • #723 .Include<> regression between 4.0-cli1052 and 4.0-cli1053 for dynamic proxies
  • #720 Enums unhelpfully converted to strings, in object-valued property, even when explicitly mapped
  • #674 after map action with nested objects
  • #620 Threading Issue when CreateMissingTypeMaps option is true
  • #618 Mapper.CreateMap<Self, Self> ignores nullability rules on collection properties
  • #557 Behaviour changed in 3.2.1, DestinationValue not null when no Destination object passed
  • #555 Cannot map type property resulting from a where
  • #154 Incorrect constructor is picked when the ctor parameter name is 'type', resulting in an InvalidCastException.
  • #28 When a target type property is of ISet, the CollectionMapper incorrectly attempts to set it to a List

Where to get it

You can download this release from nuget

3.3.1

29 Jan 16:30
Compare
Choose a tag to compare

As part of this release we had 1 issue closed.
Addressing bug around BindingFlags not being available in all platforms

Bug

  • Win8.1 Store app inherit from Automapper.Profile generates warning CS1684#658

Where to get it

You can download this release from nuget

3.3.0

28 Nov 21:39
Compare
Choose a tag to compare

As part of this release we had 36 issues closed.

Features

Improvements

  • Mapper.Reset does not clear the Project().To() expression trees.#614
  • AddGlobalIgnore does not work when the property name exists on both source and destination, but types are not compatible.#585
  • Addressing issues with ExpressionMapper logic.#584
  • Work around xunit issue which drops everything after dashes.#564
  • Support nullable destination when using custom MapFrom#559
  • Inheritance Include with Unincluded inherited mappings#537
  • Expose TypeMap in MappingExpression#531
  • Automapper projection don't support custom type converters#522
  • Fixed #511 - error when trying to map to a ReadOnlyCollection at top-level (i.e. not a property)#512
  • Mapping List to ReadOnlyCollection no longer works#511
  • Non Generic Version of .UseDestinationValue#509
  • Support NullSubstitute in LINQ expressions#506
  • Inheritance Maps specified from Derived Class#456
  • NotSupportedException on clear in ListSourceMapper #404

Bugs

  • Automapper 3.2.1 and appharbor -> failure#609
  • Fix Automapper.targets to not use Content type item#581
  • AssertConfigurationIsValid fails for destination overrides (As)#574
  • .targets file causes AutoMapper to be included by Web Publishing#556
  • Fixed #511 - error when trying to map to a ReadOnlyCollection at top-level (i.e. not a property)#532
  • Null array properties behaviour changes 3.0 -> 3.1#526
  • Using AutoMapper breaks design time experience in Expression Blend #524
  • AssertConfigurationIsValid ignore provided typemaps for DryRun#505
  • In post 3.0.0 builds, using NullSubstitute results in model type name being substituted instead of value provided#469

Where to get it

You can download this release from nuget

3.2.1

25 Apr 13:06
Compare
Choose a tag to compare

This is a patch release to address the PCL issues of WPA81 only being available in VS2013 Update 2 RC.

As part of this release we had 4 commits which resulted in 3 issues being closed.
Patch release

Bugs

#499 Automapper 3.2.0 through Nuget is not CLS-Compliant

I commmented on issue #464 but it didn't open the issue also it's for 3.1.1 and this is for 3.2.0

Here is my comment

I just updated Automapper to 3.2.0 through Nuget and I'm getting errors that AutoMapper.Profile is not CLS-Compliant when I extend it in my VB.net project.

I see that the Common Assembly Info has CLS Compliance so unless Nuget is pointing to the wrong version I don't really know what's going on here.

#498 ForMember breaks ReSharper after upgrade to 3.2

In VS2013:

Mapper.CreateMap<S,D>()
          .ForMember ( d=>d.Something, o=>o.MapFrom( s=> s.Value ) );

indicates (red squiggle) that d.Something is not valid "Cannot resolve symbol Something". It complies ok and runs ok.

What am I missing?

Thanks

#381 ForMember angering ReSharper? - Non-existing PCL profile on client machine causing compile/R# errors

I'm trying to use the ForMember to add an ignore mapping to an object. ReSharper refuses to believe that ".ForMember(x => x.Thing, o => o.Ignore())" exists, though it's fine with using the string varient of that method. I'd rather use the former for obvious reasons, but seem to be stuck using the latter for now.

Note it, will COMPILE the other way, ReSharper just doesn't seem able to grok the Expression using the other one. Using 3.0.0 NuGet package.

Where to get it

You can download this release from:

3.2.0

15 Apr 12:54
Compare
Choose a tag to compare

AutoMapper 3.2.0 now supports the following target platforms:

  • .NET 4+
  • Silverlight 5
  • Windows Phone 8+
  • Windows 8+
  • Windows Universal Apps (WPA81)
  • Xamarin MonoDroid
  • Xamarin MonoTouch

As part of this release we had 66 commits which resulted in 48 issues being closed.

Features

#487 Queryable mapping bug

Test cases and partial fix for mapping child collections. See http://stackoverflow.com/q/20046521/311289 for a bigger description.

#446 Evaluate IMemberConfigurationExpression conditions before resolve value

Hi,

it would be nice if conditions are evaluated before ResolveValue is called in order to avoid executing code (i.e. calling the getter of the underlying property) which won't be needed anyway because a condition will return false.

Specifing IMemberConfigurationExpression.Ignore() would work since this is evaluated before resolving the value but my use case depends on dynamic variables.

Source:

TypeMapObjectMapperRegistry::PropertyMapMappingStrategy:MapPropertyValue()

Content trimmed. See full issue

#429 Nuget ios version 3.1.0 does not compile for device

Setup:

  • xamarin ios 7.0.x, xamarin ios vs2012 1.8
  • create a new ios helloworld project, reference Automapper nuget
  • In MyViewController add
public class Test1 { public string Value1 { get; set; } }
public class Test2 { public string Value1 { get; set; } }
  • In ViewDidLoad add
    Content trimmed. See full issue

#422 support for optional args

added support for optional args with default values

#409 Handle NHibernate proxies of Abstract Type

Hi, I would like to be able to call

Mapper.Map<Animal, AnimalDto>(animal);

Where Both Animal and AnimalDto are abstract classes AND animal is in fact a proxy to a NHibernate object. I would imagine this working by using Mappings similar to this:

Mapper.CreateMap<Animal, AnimalDto>()
.PreMap(animalProxy => Helper.CastToEntity(animalProxy))
.Include<Cat, CatDto>
.Include<Dog, DogDto>

Content trimmed. See full issue

#354 IgnoreMap attribute

We use Automapper to map between models and view models. In some of our view models we want to map in a value from a model but never want it to be mapped back into the model itself. These values/properties are used on the view model in a read only fashion and considered reference only. We were hoping that by adding the ignore attribute to our view model would allow us to map a value in from the model but not back into the model but it appears to work both ways. We use the map config to write ignore() for each of these values but would rather use attributes. How about an overload to the ignore map attribute that allows us to configure the allowed or blocked direction of the map operation?

#256 AutoMapper caching objects when mapping twice

When you have a tree heirarcy of objects, and the same value exists in two places of the tree (but with different child values), and when mapping the second instance of the item - it uses the child values of the first instance, instead of re-evaluating what the child values should be.

Here is my example:

class Tag {
int Id {get; set;}
string Name {get; set;}
IEnumerable<Tag> ChildTags {get; set;}
}

public void Test()

Content trimmed. See full issue

#255 Are there any plans to release WinRT version ?

I'm building Metro app based on C#/XMAL approach and I would really like to use automapper. So, is there a chance to get it ? Currently I'm not able to add it the project due to that automapper is not complied against winRT.

Preferable : it would be nice to get it thru nuget package.

#254 Support for yielding records from DataReaderMapper rather than using a list

For the most part, the DataReaderMapper has always worked well for me. The use of a List rather than yielding records was never that big of a deal for the majority of my typical scenarios. However, I finally have a legitimate need for yielding the records due to some rather large result sets.

You might decide against merging this, but I wanted to offer it since others have asked for this ability. All of the existing unit tests pass and I also tested the changes in my own projects. Depending on how AutoMapper is being applied to data readers, there are some scenarios that could be problematic due to deferred execution.

For example, code written such as this would now fail because the reader will already be closed when iteration of the enumerable begins. The reader will not actually be processed until deferred execution is triggered.

public IEnumerable<Person> GetAllPersonRecords()
{
   using (var connection = CreateConnection())
   using (var command = CreateCommand())

Content trimmed. See full issue

#247 Support Entity Framework in CreateMapExpression

Hello,

I have made changes to enhance the support for building queries that translate to SQL using the Entity Framework.

  • Allow nested queries that can be mapped to SQL.
  • Added support for mapping to Arrays using CreateMapExpression.
  • Created Unit Test cases for Linq Expressions.
 Mapper.CreateMap<Entity, EntityViewModel>()
.ForMember(m => m.SubEntityNames, o => o.MapFrom(f => f.SubEntities.Select(e => e.Name)));

Content trimmed. See full issue

#209 Shortcut for mapping subtypes

instead of writing:
.ForMember(dto => dto.Contact, opt => opt.MapFrom(src => Mapper.Map<SOHeader, SalesOrderContact>(src)))

it would be nice to write something like

           .ForMember(dto => dto.Contact, opt => opt.UsingMap<SOHeader, SalesOrderContact>() )

Improvements

#489 Support for WP8.1

Hi Jimmy!
Is it possible for you to add support for WP8.1/Universal Apps?

#482 Mapper.AssertConfigurationIsValid()

I like to have one unit test for each profile I've defined, so I use the overload of Mapper.AssertConfigurationIsValid() that takes a profile name. However, I'd rather have a type-safe reference to the profile than a string, since if I happen to have misspelled the profile name in the test, my test will always pass.

I would therefore suggest the addition of the following method to the Mapper class:

public static void AssertConfigurationIsValid<TProfile>()
    where TProfile : Profile, new()
{
    AssertConfigurationIsValid(new TProfile().ProfileName);
}

As far as I can tell that's all it would take.
Content trimmed. See full issue

#480 Issue #473. Static DynamicMap and CreateMap APIs should be thread-safe

It's variant of changes. Mostly idea, because of strong types are used and not all platforms were tested.

#473 Static DynamicMap and CreateMap APIs should be thread-safe

I know, there have been closed bug reports in the past (#208, #50), but we just stumbled into the same trap. Since AutoMapper's primary API is static and AutoMapper is meant to be used in complex applications, we automatically assumed that it must be thread-safe.

Instead, it is not - calling DynamicMap and CreateMap on different threads can lead to (and, in our case, has lead to) multithreading issues. As static APIs are bound to be called from different threads, I want to again raise this request for thread-safe static APIs.

(Indeed, the static DynamicMap API is useless as long as not thread-safe, isn't it? In what context could you ever use it in an application?)

#468 Update QueryableExtensions.cs

Handles null source property so it will not create an object with possible non-nullable properties which would result in an exception.

#466 Set ResolutionContext.DestinationValue when it is resolved

When a value is resolved, set it on ResolutionContext.DestinationValue so that subsequent mappers in the resolution chain can make use of the resolved value.

This is in regards to my efforts to use AutoMapper to map from a DTO to a domain model that uses DDD, see https://groups.google.com/forum/#!topic/automapper-users/_xm0A-mA03U.

#465 Linq expression builder doesn't support max depth

There is a MaxDepth configuration option for CreateMap, but seems the linq expression doesn't respect that. So if I have circular references of an entity and its property, .Project() would result in stackoverflow.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using System.Data.Entity;

_Content trimmed. See [full issue](ht...

Read more