├── icon.png
├── nuget.exe
├── AutoMapper.snk
├── docs
├── requirements.txt
├── source
│ ├── img
│ │ └── logo.png
│ ├── 9.0-Upgrade-Guide.md
│ ├── API-Changes.md
│ ├── 8.1.1-Upgrade-Guide.md
│ ├── Value-transformers.md
│ ├── The-MyGet-build.md
│ ├── Null-substitution.md
│ ├── conf.py
│ ├── Dynamic-and-ExpandoObject-Mapping.md
│ ├── 13.0-Upgrade-Guide.md
│ └── Understanding-your-mapping.md
├── Makefile
└── make.bat
├── .github
├── FUNDING.yml
└── workflows
│ ├── lock.yml
│ ├── ci.yml
│ └── release.yml
├── src
├── UnitTests
│ ├── Bug
│ │ ├── MapAtRuntime
│ │ │ ├── BaseEntity.cs
│ │ │ ├── BaseEntityDTO.cs
│ │ │ ├── Entity2.cs
│ │ │ ├── Entity4.cs
│ │ │ ├── Entity9.cs
│ │ │ ├── Entity15.cs
│ │ │ ├── Entity19.cs
│ │ │ ├── Entity21.cs
│ │ │ ├── Entity23.cs
│ │ │ ├── EntityDTO2.cs
│ │ │ ├── EntityDTO23.cs
│ │ │ ├── EntityDTO4.cs
│ │ │ ├── EntityDTO9.cs
│ │ │ ├── EntityDTO19.cs
│ │ │ ├── EntityDTO21.cs
│ │ │ ├── Entity10.cs
│ │ │ ├── EntityDTO15.cs
│ │ │ ├── Entity26.cs
│ │ │ ├── EntityDTO10.cs
│ │ │ ├── EntityDTO26.cs
│ │ │ ├── Entity13.cs
│ │ │ ├── Entity24.cs
│ │ │ ├── Entity7.cs
│ │ │ ├── Entity16.cs
│ │ │ ├── Entity18.cs
│ │ │ ├── EntityDTO13.cs
│ │ │ ├── EntityDTO24.cs
│ │ │ ├── EntityDTO16.cs
│ │ │ ├── EntityDTO18.cs
│ │ │ ├── EntityDTO7.cs
│ │ │ ├── Entity3.cs
│ │ │ ├── Entity11.cs
│ │ │ ├── Entity14.cs
│ │ │ ├── Entity22.cs
│ │ │ ├── EntityDTO3.cs
│ │ │ ├── EntityDTO11.cs
│ │ │ ├── EntityDTO22.cs
│ │ │ ├── EntityDTO14.cs
│ │ │ ├── Entity6.cs
│ │ │ ├── Entity25.cs
│ │ │ ├── Entity12.cs
│ │ │ ├── EntityDTO6.cs
│ │ │ ├── EntityDTO25.cs
│ │ │ ├── EntityDTO12.cs
│ │ │ ├── Entity17.cs
│ │ │ ├── EntityDTO17.cs
│ │ │ ├── Entity8.cs
│ │ │ ├── EntityDTO8.cs
│ │ │ ├── Entity5.cs
│ │ │ ├── EntityDTO5.cs
│ │ │ ├── Entity1.cs
│ │ │ ├── EntityDTO1.cs
│ │ │ ├── Entity20.cs
│ │ │ └── EntityDTO20.cs
│ │ ├── MapAtRuntimeWithCollections
│ │ │ ├── BaseEntity.cs
│ │ │ ├── BaseEntityDTO.cs
│ │ │ ├── Entity2.cs
│ │ │ ├── Entity4.cs
│ │ │ ├── Entity9.cs
│ │ │ ├── Entity15.cs
│ │ │ ├── Entity19.cs
│ │ │ ├── Entity21.cs
│ │ │ ├── Entity23.cs
│ │ │ ├── EntityDTO2.cs
│ │ │ ├── EntityDTO23.cs
│ │ │ ├── EntityDTO4.cs
│ │ │ ├── EntityDTO9.cs
│ │ │ ├── EntityDTO19.cs
│ │ │ ├── EntityDTO21.cs
│ │ │ ├── EntityDTO15.cs
│ │ │ ├── Entity10.cs
│ │ │ ├── Entity26.cs
│ │ │ ├── EntityDTO10.cs
│ │ │ ├── EntityDTO26.cs
│ │ │ ├── Entity13.cs
│ │ │ ├── Entity24.cs
│ │ │ ├── Entity7.cs
│ │ │ ├── Entity16.cs
│ │ │ ├── Entity18.cs
│ │ │ ├── EntityDTO13.cs
│ │ │ ├── EntityDTO24.cs
│ │ │ ├── EntityDTO16.cs
│ │ │ ├── EntityDTO18.cs
│ │ │ ├── EntityDTO7.cs
│ │ │ ├── Entity3.cs
│ │ │ ├── Entity22.cs
│ │ │ ├── Entity14.cs
│ │ │ ├── EntityDTO3.cs
│ │ │ ├── EntityDTO11.cs
│ │ │ ├── EntityDTO22.cs
│ │ │ ├── Entity11.cs
│ │ │ ├── EntityDTO14.cs
│ │ │ ├── Entity6.cs
│ │ │ ├── Entity25.cs
│ │ │ ├── EntityDTO6.cs
│ │ │ ├── EntityDTO25.cs
│ │ │ ├── Entity12.cs
│ │ │ ├── EntityDTO12.cs
│ │ │ ├── Entity17.cs
│ │ │ ├── EntityDTO17.cs
│ │ │ ├── Entity5.cs
│ │ │ ├── EntityDTO5.cs
│ │ │ ├── EntityDTO8.cs
│ │ │ ├── EntityDTO1.cs
│ │ │ ├── Entity1.cs
│ │ │ ├── Entity8.cs
│ │ │ ├── EntityDTO20.cs
│ │ │ └── Entity20.cs
│ │ ├── NonExistingProperty.cs
│ │ ├── CaseSensitivityBug.cs
│ │ ├── NullablePropertiesBug.cs
│ │ ├── AssertConfigurationIsValidNullables.cs
│ │ ├── MissingMapping.cs
│ │ ├── NullableEnums.cs
│ │ ├── PropertyNamedType.cs
│ │ ├── RemovePrefixes.cs
│ │ ├── ReadOnlyCollectionMappingBug.cs
│ │ ├── NullableToInvalid.cs
│ │ ├── MapExpandoObjectProperty.cs
│ │ ├── CreateMapExpressionWithIgnoredPropertyBug.cs
│ │ ├── ConstructorParameterNamedType.cs
│ │ ├── ConstructUsingReturnsNull.cs
│ │ ├── NullToString.cs
│ │ ├── NullSubstituteType.cs
│ │ ├── NullableResolveUsing.cs
│ │ ├── NullableUntypedMapFrom.cs
│ │ ├── IntToNullableDecimal.cs
│ │ ├── InternalProperties.cs
│ │ ├── CannotConvertEnumToNullable.cs
│ │ ├── NullableIntToNullableEnum.cs
│ │ ├── ProjectUsingTheQueriedEntity.cs
│ │ ├── ReadOnlyFieldMappingBug.cs
│ │ ├── ForAllMembersAndDoNotUseDestinationValue.cs
│ │ ├── CollectionsNullability.cs
│ │ ├── ListSourceMapperBug.cs
│ │ ├── InterfaceSelfMappingBug.cs
│ │ ├── ObjectTypeMapFailure.cs
│ │ ├── DeepCloningBug.cs
│ │ ├── GuidTryExpression.cs
│ │ ├── ConvertMapperThreading.cs
│ │ ├── SubclassMappings.cs
│ │ ├── EnumCaseSensitivityBug.cs
│ │ ├── RecognizeDestinationPostfixes.cs
│ │ ├── AllowNullCollectionsAssignableArray.cs
│ │ ├── TargetISet.cs
│ │ ├── AddingConfigurationForNonMatchingDestinationMemberBug.cs
│ │ ├── CollectionBaseClassGetConvention.cs
│ │ ├── SequenceContainsNoElementsTest.cs
│ │ ├── OneSourceWithMultipleDestinationsWithoutPR.cs
│ │ ├── NullableEnumToNullableValueType.cs
│ │ ├── ObjectEnumToObjectEnum.cs
│ │ ├── CannotProjectStringToNullableEnum.cs
│ │ ├── AfterMapNestedObjects.cs
│ │ ├── RepeatedMappingConfigurationTest.cs
│ │ ├── NullArrayBug.cs
│ │ ├── OneSourceWithMultipleDestinationsAndPreserveReferences.cs
│ │ ├── MultipleInterfaceInheritance.cs
│ │ ├── EnumMatchingOnValue.cs
│ │ ├── SelectiveConfigurationValidation.cs
│ │ ├── DuplicateExtensionMethods.cs
│ │ ├── EFCollections.cs
│ │ ├── NullSubstituteInnerClass.cs
│ │ ├── MemberListSourceAndForPath.cs
│ │ ├── CannotProjectIEnumerableToAggregateDestinations.cs
│ │ ├── SetterOnlyBug.cs
│ │ ├── CollectionWhere.cs
│ │ ├── ProjectConstructorParameters.cs
│ │ └── CannotMapICollectionToAggregateSumDestination.cs
│ ├── TesterExtensions.cs
│ ├── Mappers
│ │ ├── ConstructorMapperTests.cs
│ │ └── TypeHelperTests.cs
│ ├── MappingInheritance
│ │ ├── IncludeBaseShouldValidateTypes.cs
│ │ ├── InheritanceWithoutIncludeShouldWork.cs
│ │ ├── IncludeBaseShouldNotCreateMaps.cs
│ │ ├── IncludeAllDerived.cs
│ │ ├── MultipleInheritedBaseMappingsOfSameTypeFails.cs
│ │ └── IgnoreShouldBeInheritedIfConventionCannotMap.cs
│ ├── Internal
│ │ ├── MapperTests.cs
│ │ ├── ObjectFactoryTests.cs
│ │ └── CreateProxyThreading.cs
│ ├── App.config
│ ├── ExplicitMapperCreation.cs
│ ├── ConfigCompilation.cs
│ ├── AddProfiles.cs
│ ├── TypeExtensionsTests.cs
│ ├── CustomCollectionTester.cs
│ ├── SeparateConfiguration.cs
│ ├── AutoMapper.UnitTests.csproj
│ ├── IMappingExpression
│ │ ├── NonGenericResolveUsing.cs
│ │ └── NonGenericConstructorTests.cs
│ ├── EnumToNullableEnum.cs
│ ├── Projection
│ │ ├── ExplicitValues.cs
│ │ ├── MoreExplanatoryExceptionTests.cs
│ │ ├── GenericsTests.cs
│ │ ├── RecursiveQuery.cs
│ │ └── ProjectionMappers.cs
│ ├── AutoMapperTester.cs
│ ├── AssertionExtensions.cs
│ ├── IgnoreAllPropertiesWithAnInaccessibleSetterTests.cs
│ ├── Indexers.cs
│ └── Internationalization.cs
├── Benchmark
│ ├── IObjectToObjectMapper.cs
│ ├── Benchmark.csproj
│ ├── BenchEngine.cs
│ └── Program.cs
├── AutoMapper
│ ├── Configuration
│ │ └── Annotations
│ │ │ ├── IMemberConfigurationProvider.cs
│ │ │ ├── IgnoreAttribute.cs
│ │ │ ├── UseExistingValueAttribute.cs
│ │ │ ├── MapAtRuntimeAttribute.cs
│ │ │ ├── MappingOrderAttribute.cs
│ │ │ ├── NullSubstituteAttribute.cs
│ │ │ ├── SourceMemberAttribute.cs
│ │ │ └── ValueConverterAttribute.cs
│ ├── AssemblyInfo.cs
│ ├── Mappers
│ │ ├── AssignableMapper.cs
│ │ ├── UnderlyingEnumTypeMapper.cs
│ │ ├── ParseStringMapper.cs
│ │ ├── ToStringMapper.cs
│ │ ├── ConstructorMapper.cs
│ │ ├── ConvertMapper.cs
│ │ ├── NullableDestinationMapper.cs
│ │ ├── NullableSourceMapper.cs
│ │ ├── ToStringDictionaryMapper.cs
│ │ ├── EnumToEnumMapper.cs
│ │ ├── KeyValueMapper.cs
│ │ └── ConversionOperatorMapper.cs
│ ├── QueryableExtensions
│ │ └── ProjectionMappers
│ │ │ ├── StringProjectionMapper.cs
│ │ │ ├── AssignableProjectionMapper.cs
│ │ │ ├── EnumProjectionMapper.cs
│ │ │ └── NullableSourceProjectionMapper.cs
│ ├── ApiCompat
│ │ ├── PreBuild.ps1
│ │ └── PreBuild.sh
│ ├── Internal
│ │ ├── LockingConcurrentDictionary.cs
│ │ └── MemberPath.cs
│ └── PathMap.cs
├── TestApp
│ ├── TestApp.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
├── AutoMapper.DI.Tests
│ ├── AttributeTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── AppDomainResolutionTests.cs
│ ├── AutoMapper.DI.Tests.csproj
│ └── DependencyTests.cs
└── IntegrationTests
│ ├── AutoMapper.IntegrationTests.csproj
│ └── ProjectionAdvanced.cs
├── .readthedocs.yml
├── nuget.config
├── .gitignore
├── .gitattributes
├── Push.ps1
├── Directory.Build.props
├── LICENSE.txt
├── Build.ps1
└── Setup.ps1
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sulhan12/AutoMapper/HEAD/icon.png
--------------------------------------------------------------------------------
/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sulhan12/AutoMapper/HEAD/nuget.exe
--------------------------------------------------------------------------------
/AutoMapper.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sulhan12/AutoMapper/HEAD/AutoMapper.snk
--------------------------------------------------------------------------------
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | sphinx==7.1.2
2 | sphinx-rtd-theme==1.3.0rc1
3 | myst_parser==2.0.0
--------------------------------------------------------------------------------
/docs/source/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sulhan12/AutoMapper/HEAD/docs/source/img/logo.png
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [jbogard, lbargaoanu]
4 |
5 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class BaseEntity
4 | {
5 | public Guid Id { get; set; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/BaseEntityDTO.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class BaseEntity
4 | {
5 | public Guid Id { get; set; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/BaseEntity.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class BaseEntity
4 | {
5 | public Guid Id { get; set; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/BaseEntityDTO.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class BaseEntity
4 | {
5 | public Guid Id { get; set; }
6 | }
7 |
--------------------------------------------------------------------------------
/src/Benchmark/IObjectToObjectMapper.cs:
--------------------------------------------------------------------------------
1 | namespace Benchmark;
2 |
3 | public interface IObjectToObjectMapper
4 | {
5 | string Name { get; }
6 | void Initialize();
7 | object Map();
8 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity2.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity2 : BaseEntity
4 | {
5 | public Guid Entity1Id { get; set; }
6 | public Entity1 Entity1 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity4.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity4 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity9.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity9 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity15.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity15 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity19.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity19 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public Entity25 Entity25 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity21.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity21 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public Entity20 Entity20 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity23.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity23 : BaseEntity
4 | {
5 | public Guid Entity5Id { get; set; }
6 | public Entity5 Entity5 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO2.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO2 : BaseEntity
4 | {
5 | public Guid Entity1Id { get; set; }
6 | public EntityDTO1 Entity1 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO23.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO23 : BaseEntity
4 | {
5 | public Guid Entity5Id { get; set; }
6 | public EntityDTO5 Entity5 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO4.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO4 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO9.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO9 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO19.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO19 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public EntityDTO25 Entity25 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO21.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO21 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public EntityDTO20 Entity20 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity2.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity2 : BaseEntity
4 | {
5 | public Guid Entity1Id { get; set; }
6 | public Entity1 Entity1 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity4.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity4 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity9.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity9 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/.readthedocs.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 |
3 | build:
4 | os: "ubuntu-22.04"
5 | tools:
6 | python: "3.10"
7 |
8 | python:
9 | install:
10 | - requirements: docs/requirements.txt
11 |
12 | sphinx:
13 | configuration: docs/source/conf.py
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity15.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity15 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity19.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity19 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public Entity25 Entity25 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity21.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity21 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public Entity20 Entity20 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity23.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity23 : BaseEntity
4 | {
5 | public Guid Entity5Id { get; set; }
6 | public Entity5 Entity5 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO2.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO2 : BaseEntity
4 | {
5 | public Guid Entity1Id { get; set; }
6 | public EntityDTO1 Entity1 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO23.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO23 : BaseEntity
4 | {
5 | public Guid Entity5Id { get; set; }
6 | public EntityDTO5 Entity5 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO4.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO4 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO9.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO9 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO19.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO19 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public EntityDTO25 Entity25 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO21.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO21 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public EntityDTO20 Entity20 { get; set; }
7 | }
8 |
--------------------------------------------------------------------------------
/src/AutoMapper/Configuration/Annotations/IMemberConfigurationProvider.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Configuration;
2 |
3 | public interface IMemberConfigurationProvider
4 | {
5 | void ApplyConfiguration(IMemberConfigurationExpression memberConfigurationExpression);
6 | }
--------------------------------------------------------------------------------
/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity10.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity10 : BaseEntity
4 | {
5 | public Entity10()
6 | {
7 | this.Entities11 = new Entity11();
8 | }
9 | public Entity11 Entities11 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO15.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO15 : BaseEntity
4 | {
5 | public EntityDTO15()
6 | {
7 | }
8 | public Guid Entity17Id { get; set; }
9 | public EntityDTO17 Entity17 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity26.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity26 : BaseEntity
4 | {
5 | public Entity26()
6 | {
7 | //this.Entities20 = new Entity20();
8 | }
9 |
10 | public Entity20 Entities20 { get; set; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO10.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO10 : BaseEntity
4 | {
5 | public EntityDTO10()
6 | {
7 | this.Entities11 = new EntityDTO11();
8 | }
9 | public EntityDTO11 Entities11 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO26.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO26 : BaseEntity
4 | {
5 | public EntityDTO26()
6 | {
7 | this.Entities20 = new EntityDTO20();
8 | }
9 |
10 | public EntityDTO20 Entities20 { get; set; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/AutoMapper/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: CLSCompliant(true)]
5 | [assembly: ComVisible(false)]
6 | [assembly: NeutralResourcesLanguage("en")]
7 |
8 | namespace System.Runtime.CompilerServices;
9 |
10 | static class IsExternalInit { }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO15.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO15 : BaseEntity
4 | {
5 | public EntityDTO15()
6 | {
7 | }
8 | public Guid Entity17Id { get; set; }
9 | public EntityDTO17 Entity17 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity13.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity13 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | public Guid Entity8Id { get; set; }
8 | public Entity8 Entity8 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity24.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity24 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | public Guid Entity22Id { get; set; }
8 | public Entity22 Entity22 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity7.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity7 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public Entity25 Entity25 { get; set; }
7 | public Guid? Entity14Id { get; set; }
8 | public Entity14 Entity14 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity16.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity16 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public Entity20 Entity20 { get; set; }
7 | public Guid Entity12Id { get; set; }
8 | public Entity12 Entity12 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity18.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity18 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | public Guid Entity20Id { get; set; }
8 | public Entity20 Entity20 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO13.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO13 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public EntityDTO17 Entity17 { get; set; }
7 | public Guid Entity8Id { get; set; }
8 | public EntityDTO8 Entity8 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO24.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO24 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | public Guid Entity22Id { get; set; }
8 | public EntityDTO22 Entity22 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO16.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO16 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public EntityDTO20 Entity20 { get; set; }
7 | public Guid Entity12Id { get; set; }
8 | public EntityDTO12 Entity12 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO18.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO18 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public EntityDTO17 Entity17 { get; set; }
7 | public Guid Entity20Id { get; set; }
8 | public EntityDTO20 Entity20 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO7.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO7 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public EntityDTO25 Entity25 { get; set; }
7 | public Guid? Entity14Id { get; set; }
8 | public EntityDTO14 Entity14 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity10.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity10 : BaseEntity
4 | {
5 | public Entity10()
6 | {
7 | this.Entities11 = new List();
8 | }
9 | public ICollection Entities11 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity26.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity26 : BaseEntity
4 | {
5 | public Entity26()
6 | {
7 | this.Entities20 = new List();
8 | }
9 |
10 | public ICollection Entities20 { get; set; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/UnitTests/TesterExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 |
3 | public static class StopgapNBehaveExtensions
4 | {
5 | public static void ShouldBeOfLength(this IEnumerable collection, int length)
6 | {
7 | collection.ShouldNotBeNull();
8 | collection.Count().ShouldBe(length);
9 | }
10 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO10.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO10 : BaseEntity
4 | {
5 | public EntityDTO10()
6 | {
7 | this.Entities11 = new List();
8 | }
9 | public ICollection Entities11 { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO26.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO26 : BaseEntity
4 | {
5 | public EntityDTO26()
6 | {
7 | this.Entities20 = new List();
8 | }
9 |
10 | public ICollection Entities20 { get; set; }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Benchmark/Benchmark.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | Exe
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity13.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity13 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | public Guid Entity8Id { get; set; }
8 | public Entity8 Entity8 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity24.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity24 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public Entity3 Entity3 { get; set; }
7 | public Guid Entity22Id { get; set; }
8 | public Entity22 Entity22 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity7.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity7 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public Entity25 Entity25 { get; set; }
7 | public Guid? Entity14Id { get; set; }
8 | public Entity14 Entity14 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity16.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity16 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public Entity20 Entity20 { get; set; }
7 | public Guid Entity12Id { get; set; }
8 | public Entity12 Entity12 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity18.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity18 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public Entity17 Entity17 { get; set; }
7 | public Guid Entity20Id { get; set; }
8 | public Entity20 Entity20 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO13.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO13 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public EntityDTO17 Entity17 { get; set; }
7 | public Guid Entity8Id { get; set; }
8 | public EntityDTO8 Entity8 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO24.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO24 : BaseEntity
4 | {
5 | public Guid Entity3Id { get; set; }
6 | public EntityDTO3 Entity3 { get; set; }
7 | public Guid Entity22Id { get; set; }
8 | public EntityDTO22 Entity22 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO16.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO16 : BaseEntity
4 | {
5 | public Guid Entity20Id { get; set; }
6 | public EntityDTO20 Entity20 { get; set; }
7 | public Guid Entity12Id { get; set; }
8 | public EntityDTO12 Entity12 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO18.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO18 : BaseEntity
4 | {
5 | public Guid Entity17Id { get; set; }
6 | public EntityDTO17 Entity17 { get; set; }
7 | public Guid Entity20Id { get; set; }
8 | public EntityDTO20 Entity20 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO7.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO7 : BaseEntity
4 | {
5 | public Guid Entity25Id { get; set; }
6 | public EntityDTO25 Entity25 { get; set; }
7 | public Guid? Entity14Id { get; set; }
8 | public EntityDTO14 Entity14 { get; set; }
9 | }
10 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity3.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity3 : BaseEntity
4 | {
5 | public Entity3()
6 | {
7 | this.Entities4 = new Entity4();
8 | this.Entities8 = new Entity8();
9 | }
10 | public Entity4 Entities4 { get; set; }
11 | public Entity8 Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity11.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity11 : BaseEntity
4 | {
5 | public Entity11()
6 | {
7 | this.Entities10 = new Entity10();
8 | this.Entities8 = new Entity8();
9 | }
10 | public Entity10 Entities10 { get; set; }
11 | public Entity8 Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity14.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity14 : BaseEntity
4 | {
5 | public Entity14()
6 | {
7 | this.Entities12 = new Entity12();
8 | this.Entities1 = new Entity1();
9 | }
10 |
11 | public Entity12 Entities12 { get; set; }
12 | public Entity1 Entities1 { get; set; }
13 | }
14 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity22.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity22 : BaseEntity
4 | {
5 | public Entity22()
6 | {
7 | this.Entities20 = new Entity20();
8 | this.Entities24 = new Entity24();
9 | }
10 | public Entity20 Entities20 { get; set; }
11 | public Entity24 Entities24 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO3.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO3 : BaseEntity
4 | {
5 | public EntityDTO3()
6 | {
7 | //this.Entities4 = new EntityDTO4();
8 | //this.Entities8 = new EntityDTO8();
9 | }
10 | public EntityDTO4 Entities4 { get; set; }
11 | public EntityDTO8 Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO11.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO11 : BaseEntity
4 | {
5 | public EntityDTO11()
6 | {
7 | //this.Entities10 = new EntityDTO10();
8 | //this.Entities8 = new EntityDTO8();
9 | }
10 | public EntityDTO10 Entities10 { get; set; }
11 | public EntityDTO8 Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO22.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO22 : BaseEntity
4 | {
5 | public EntityDTO22()
6 | {
7 | //this.Entities20 = new EntityDTO20();
8 | //this.Entities24 = new EntityDTO24();
9 | }
10 | public EntityDTO20 Entities20 { get; set; }
11 | public EntityDTO24 Entities24 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity3.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity3 : BaseEntity
4 | {
5 | public Entity3()
6 | {
7 | this.Entities4 = new List();
8 | this.Entities8 = new List();
9 | }
10 | public ICollection Entities4 { get; set; }
11 | public ICollection Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO14.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO14 : BaseEntity
4 | {
5 | public EntityDTO14()
6 | {
7 | this.Entities12 = new EntityDTO12();
8 | this.Entities1 = new EntityDTO1();
9 | }
10 |
11 | //public Address Address { get; set; }
12 | public EntityDTO12 Entities12 { get; set; }
13 | public EntityDTO1 Entities1 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity22.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity22 : BaseEntity
4 | {
5 | public Entity22()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities24 = new List();
9 | }
10 | public ICollection Entities20 { get; set; }
11 | public ICollection Entities24 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity14.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity14 : BaseEntity
4 | {
5 | public Entity14()
6 | {
7 | this.Entities12 = new List();
8 | this.Entities1 = new List();
9 | }
10 |
11 | public ICollection Entities12 { get; set; }
12 | public ICollection Entities1 { get; set; }
13 | }
14 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO3.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO3 : BaseEntity
4 | {
5 | public EntityDTO3()
6 | {
7 | this.Entities4 = new List();
8 | this.Entities8 = new List();
9 | }
10 | public ICollection Entities4 { get; set; }
11 | public ICollection Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/AutoMapper/Mappers/AssignableMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Internal.Mappers;
2 |
3 | public class AssignableMapper : IObjectMapper
4 | {
5 | public bool IsMatch(TypePair context) => context.DestinationType.IsAssignableFrom(context.SourceType);
6 | public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap,
7 | MemberMap memberMap, Expression sourceExpression, Expression destExpression) => sourceExpression;
8 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO11.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO11 : BaseEntity
4 | {
5 | public EntityDTO11()
6 | {
7 | this.Entities10 = new List();
8 | this.Entities8 = new List();
9 | }
10 | public ICollection Entities10 { get; set; }
11 | public ICollection Entities8 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO22.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO22 : BaseEntity
4 | {
5 | public EntityDTO22()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities24 = new List();
9 | }
10 | public ICollection Entities20 { get; set; }
11 | public ICollection Entities24 { get; set; }
12 | }
13 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity6.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity6 : BaseEntity
4 | {
5 | public Entity6()
6 | {
7 | this.Entities12 = new Entity12();
8 | }
9 |
10 | public Guid Entity5Id { get; set; }
11 | public Entity5 Entity5 { get; set; }
12 | public Guid Entity20Id { get; set; }
13 | public Entity20 Entity20 { get; set; }
14 | public Entity12 Entities12 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity25.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity25 : BaseEntity
4 | {
5 | public Entity25()
6 | {
7 | this.Entities19 = new Entity19();
8 | }
9 |
10 | public Entity19 Entities19 { get; set; }
11 | public Guid? Entity8Id { get; set; }
12 | public Entity8 Entity8 { get; set; }
13 | public Guid? Entity17Id { get; set; }
14 | public Entity17 Entity17 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity12.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity12 : BaseEntity
4 | {
5 | public Entity12()
6 | {
7 | //this.Entities20 = new Entity20();
8 | //this.Entities14 = new Entity14();
9 | //this.Entities16 = new Entity16();
10 | }
11 | public Entity20 Entities20 { get; set; }
12 | public Entity16 Entities16 { get; set; }
13 | public Entity14 Entities14 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/docs/source/9.0-Upgrade-Guide.md:
--------------------------------------------------------------------------------
1 | # 9.0 Upgrade Guide
2 |
3 | ## The static API was removed
4 |
5 | Switch to the instance based API, preferably using dependency injection.
6 | See [here](Setup.html) and [here](Dependency-injection.html).
7 |
8 | ## AutoMapper no longer creates maps automatically (CreateMissingTypeMaps and conventions)
9 |
10 | You will need to explicitly configure maps, manually or using reflection. Also consider [attribute mapping](Attribute-mapping.html).
--------------------------------------------------------------------------------
/src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Internal.Mappers;
2 |
3 | public class UnderlyingTypeEnumMapper : IObjectMapper
4 | {
5 | public bool IsMatch(TypePair context) => context.IsEnumToUnderlyingType() || context.IsUnderlyingTypeToEnum();
6 | public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap,
7 | MemberMap memberMap, Expression sourceExpression, Expression destExpression) => sourceExpression;
8 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO6.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO6 : BaseEntity
4 | {
5 | public EntityDTO6()
6 | {
7 | //this.Entities12 = new EntityDTO12();
8 | }
9 |
10 | public Guid Entity5Id { get; set; }
11 | public EntityDTO5 Entity5 { get; set; }
12 | public Guid Entity20Id { get; set; }
13 | public EntityDTO20 Entity20 { get; set; }
14 | public EntityDTO12 Entities12 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO25.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO25 : BaseEntity
4 | {
5 | public EntityDTO25()
6 | {
7 | this.Entities19 = new EntityDTO19();
8 | }
9 |
10 | public EntityDTO19 Entities19 { get; set; }
11 | public Guid? Entity8Id { get; set; }
12 | public EntityDTO8 Entity8 { get; set; }
13 | public Guid? Entity17Id { get; set; }
14 | public EntityDTO17 Entity17 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity11.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity11 : BaseEntity
4 | {
5 | public Entity11()
6 | {
7 | this.Entities10 = new List();
8 | this.Entities8 = new List();
9 | }
10 | public ICollection Entities10 { get; set; }
11 | public ICollection Entities8 { get; set; }
12 | public Entity8 Entity8 { get; set; }
13 | }
14 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO12.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO12 : BaseEntity
4 | {
5 | public EntityDTO12()
6 | {
7 | //this.Entities20 = new EntityDTO20();
8 | //this.Entities14 = new EntityDTO14();
9 | //Entities16 = new EntityDTO16();
10 | }
11 | public EntityDTO20 Entities20 { get; set; }
12 | public EntityDTO16 Entities16 { get; set; }
13 | public EntityDTO14 Entities14 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO14.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO14 : BaseEntity
4 | {
5 | public EntityDTO14()
6 | {
7 | this.Entities12 = new List();
8 | this.Entities1 = new List();
9 | }
10 |
11 | //public Address Address { get; set; }
12 | public ICollection Entities12 { get; set; }
13 | public ICollection Entities1 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity6.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity6 : BaseEntity
4 | {
5 | public Entity6()
6 | {
7 | this.Entities12 = new List();
8 | }
9 |
10 | public Guid Entity5Id { get; set; }
11 | public Entity5 Entity5 { get; set; }
12 | public Guid Entity20Id { get; set; }
13 | public Entity20 Entity20 { get; set; }
14 | public ICollection Entities12 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | release/
3 | scripts/
4 | artifacts/
5 | .dotnet
6 | TestResults/
7 | *.suo
8 | *.user
9 | bin
10 | Bin
11 | obj
12 | _ReSharper*
13 | *.csproj.user
14 | *.resharper.user
15 | *.suo
16 | *.cache
17 | TestResult.xml
18 | AppPackages/
19 | *.bak
20 | packages
21 | *.orig
22 | *.DotSettings
23 | *.ide/
24 | .nuget
25 | project.lock.json
26 | .vs
27 |
28 | # JetBrains Rider
29 | .idea/
30 | *.sln.iml
31 |
32 | # Read the Docs
33 | docs/_build
34 | /src/LastMajorVersionBinary
35 | *.diagsession
36 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity25.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity25 : BaseEntity
4 | {
5 | public Entity25()
6 | {
7 | this.Entities19 = new List();
8 | }
9 |
10 | public ICollection Entities19 { get; set; }
11 | public Guid? Entity8Id { get; set; }
12 | public Entity8 Entity8 { get; set; }
13 | public Guid? Entity17Id { get; set; }
14 | public Entity17 Entity17 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO6.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO6 : BaseEntity
4 | {
5 | public EntityDTO6()
6 | {
7 | this.Entities12 = new List();
8 | }
9 |
10 | public Guid Entity5Id { get; set; }
11 | public EntityDTO5 Entity5 { get; set; }
12 | public Guid Entity20Id { get; set; }
13 | public EntityDTO20 Entity20 { get; set; }
14 | public ICollection Entities12 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.doc diff=astextplain
2 | *.DOC diff=astextplain
3 | *.docx diff=astextplain
4 | *.DOCX diff=astextplain
5 | *.dot diff=astextplain
6 | *.DOT diff=astextplain
7 | *.pdf diff=astextplain
8 | *.PDF diff=astextplain
9 | *.rtf diff=astextplain
10 | *.RTF diff=astextplain
11 |
12 | *.jpg binary
13 | *.png binary
14 | *.gif binary
15 |
16 | core.eol crlf
17 |
18 | *.cs diff=csharp
19 |
20 | *.csproj merge=union
21 | *.vbproj merge=union
22 | *.fsproj merge=union
23 | *.dbproj merge=union
24 | *.sln merge=union
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO25.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO25 : BaseEntity
4 | {
5 | public EntityDTO25()
6 | {
7 | this.Entities19 = new List();
8 | }
9 |
10 | public ICollection Entities19 { get; set; }
11 | public Guid? Entity8Id { get; set; }
12 | public EntityDTO8 Entity8 { get; set; }
13 | public Guid? Entity17Id { get; set; }
14 | public EntityDTO17 Entity17 { get; set; }
15 | }
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/NonExistingProperty.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class NonExistingProperty : NonValidatingSpecBase
4 | {
5 | public class Source
6 | {
7 | }
8 |
9 | public class Destination
10 | {
11 | }
12 |
13 | [Fact]
14 | public void Should_report_missing_property()
15 | {
16 | new Action(() => new MapperConfiguration(cfg => cfg.CreateMap().ForMember("X", s => { }))).ShouldThrow();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/AutoMapper/QueryableExtensions/ProjectionMappers/StringProjectionMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.QueryableExtensions.Impl;
2 |
3 | [EditorBrowsable(EditorBrowsableState.Never)]
4 | public class StringProjectionMapper : IProjectionMapper
5 | {
6 | public bool IsMatch(TypePair context) => context.DestinationType == typeof(string);
7 | public Expression Project(IGlobalConfiguration configuration, in ProjectionRequest request, Expression resolvedSource, LetPropertyMaps letPropertyMaps)
8 | => Call(resolvedSource, ObjectToString);
9 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/CaseSensitivityBug.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 | public class CaseSensitivityBug : AutoMapperSpecBase
3 | {
4 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
5 | {
6 | cfg.CreateMap();
7 | });
8 | public class Foo
9 | {
10 | public int ID { get; set; }
11 | }
12 |
13 | public class Bar
14 | {
15 | public int id { get; set; }
16 | }
17 | [Fact]
18 | public void Validate() => AssertConfigurationIsValid();
19 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity12.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity12 : BaseEntity
4 | {
5 | public Entity12()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities14 = new List();
9 | this.Entities16 = new List();
10 | }
11 | public ICollection Entities20 { get; set; }
12 | public ICollection Entities16 { get; set; }
13 | public ICollection Entities14 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/NullablePropertiesBug.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class NullablePropertiesBug
4 | {
5 | public class Source { public int? A { get; set; } }
6 | public class Target { public int? A { get; set; } }
7 |
8 | [Fact]
9 | public void Example()
10 | {
11 |
12 | var config = new MapperConfiguration(cfg => cfg.CreateMap());
13 |
14 | var d = config.CreateMapper().Map(new Source { A = null }, new Target { A = 10 });
15 |
16 | d.A.ShouldBeNull();
17 | }
18 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity17.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity17 :BaseEntity
4 | {
5 | public Entity17()
6 | {
7 | //this.Entities20 = new Entity20();
8 | this.Entities8 = new Entity8();
9 | this.Entities5 = new Entity5();
10 | this.Entities18 = new Entity18();
11 | }
12 |
13 | public Entity20 Entities20 { get; set; }
14 | public Entity8 Entities8 { get; set; }
15 | public Entity5 Entities5 { get; set; }
16 | public Entity18 Entities18 { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/UnitTests/Mappers/ConstructorMapperTests.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Mappers;
2 |
3 | public class ConstructorMapperTests : AutoMapperSpecBase
4 | {
5 | class Destination
6 | {
7 | public Destination(string value)
8 | {
9 | Value = value;
10 | }
11 | public string Value { get; }
12 | }
13 | protected override MapperConfiguration CreateConfiguration() => new(_=> { });
14 | [Fact]
15 | public void Should_use_constructor() => Mapper.Map("value").Value.ShouldBe("value");
16 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO12.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO12 : BaseEntity
4 | {
5 | public EntityDTO12()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities14 = new List();
9 | Entities16 = new List();
10 | }
11 | public ICollection Entities20 { get; set; }
12 | public ICollection Entities16 { get; set; }
13 | public ICollection Entities14 { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/AutoMapper/QueryableExtensions/ProjectionMappers/AssignableProjectionMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.QueryableExtensions.Impl;
2 | [EditorBrowsable(EditorBrowsableState.Never)]
3 | public class AssignableProjectionMapper : IProjectionMapper
4 | {
5 | public bool IsMatch(TypePair context) => context.DestinationType.IsAssignableFrom(context.SourceType);
6 | public Expression Project(IGlobalConfiguration configuration, in ProjectionRequest request, Expression resolvedSource, LetPropertyMaps letPropertyMaps)
7 | => ToType(resolvedSource, request.DestinationType);
8 | }
--------------------------------------------------------------------------------
/src/AutoMapper/ApiCompat/PreBuild.ps1:
--------------------------------------------------------------------------------
1 | param([string]$version)
2 | echo $version
3 | $versionNumbers = $version.Split(".")
4 | if($versionNumbers[1] -eq "0" -AND $versionNumbers[2] -eq "0")
5 | {
6 | $oldVersion = $versionNumbers[0] - 1
7 | }else{
8 | $oldVersion = $versionNumbers[0]
9 | }
10 | $oldVersion = $oldVersion.ToString() +".0.0"
11 | echo $oldVersion
12 | & ..\..\nuget install AutoMapper -Version $oldVersion -OutputDirectory ..\LastMajorVersionBinary
13 | & copy ..\LastMajorVersionBinary\AutoMapper.$oldVersion\lib\net6.0\AutoMapper.dll ..\LastMajorVersionBinary
14 |
--------------------------------------------------------------------------------
/Push.ps1:
--------------------------------------------------------------------------------
1 | $scriptName = $MyInvocation.MyCommand.Name
2 | $artifacts = "./artifacts"
3 |
4 | if ([string]::IsNullOrEmpty($Env:NUGET_API_KEY)) {
5 | Write-Host "${scriptName}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
6 | } else {
7 | Get-ChildItem $artifacts -Filter "*.nupkg" | ForEach-Object {
8 | Write-Host "$($scriptName): Pushing $($_.Name)"
9 | dotnet nuget push $_ --source $Env:NUGET_URL --api-key $Env:NUGET_API_KEY
10 | if ($lastexitcode -ne 0) {
11 | throw ("Exec: " + $errorMessage)
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/UnitTests/MappingInheritance/IncludeBaseShouldValidateTypes.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 |
3 | public class IncludeBaseShouldValidateTypes
4 | {
5 | [Fact]
6 | public void Should_throw()
7 | {
8 | new Action(() =>
9 | {
10 | var c = new MapperConfiguration(cfg => cfg.CreateMap().IncludeBase());
11 | }).ShouldThrowException(ex =>
12 | {
13 | ex.Message.ShouldStartWith($"{typeof(string)} is not derived from {typeof(int)}.");
14 | });
15 | }
16 | }
--------------------------------------------------------------------------------
/src/AutoMapper/QueryableExtensions/ProjectionMappers/EnumProjectionMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.QueryableExtensions.Impl;
2 | [EditorBrowsable(EditorBrowsableState.Never)]
3 | public class EnumProjectionMapper : IProjectionMapper
4 | {
5 | public Expression Project(IGlobalConfiguration configuration, in ProjectionRequest request, Expression resolvedSource, LetPropertyMaps letPropertyMaps)
6 | => Convert(resolvedSource, request.DestinationType);
7 | public bool IsMatch(TypePair context) => context.IsEnumToEnum() || context.IsUnderlyingTypeToEnum() || context.IsEnumToUnderlyingType();
8 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO17.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO17 :BaseEntity
4 | {
5 | public EntityDTO17()
6 | {
7 | //this.Entities20 = new EntityDTO20();
8 | //this.Entities8 = new EntityDTO8();
9 | //this.Entities5 = new EntityDTO5();
10 | //this.Entities18 = new EntityDTO18();
11 | }
12 |
13 | public EntityDTO20 Entities20 { get; set; }
14 | public EntityDTO8 Entities8 { get; set; }
15 | public EntityDTO5 Entities5 { get; set; }
16 | public EntityDTO18 Entities18 { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/UnitTests/Internal/MapperTests.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Tests;
2 |
3 | public class MapperTests : NonValidatingSpecBase
4 | {
5 | public class Source
6 | {
7 |
8 | }
9 |
10 | public class Destination
11 | {
12 |
13 | }
14 |
15 | [Fact]
16 | public void Should_find_configured_type_map_when_two_types_are_configured()
17 | {
18 | var config = new MapperConfiguration(cfg => cfg.CreateMap());
19 |
20 | config.FindTypeMapFor().ShouldNotBeNull();
21 | }
22 | }
--------------------------------------------------------------------------------
/src/UnitTests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/AssertConfigurationIsValidNullables.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class AssertConfigurationIsValidNullables : AutoMapperSpecBase
4 | {
5 | class Source
6 | {
7 | public int? Number { get; set; }
8 | }
9 | class Destination
10 | {
11 | public decimal? Number { get; set; }
12 | }
13 |
14 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
15 | {
16 | cfg.CreateMap();
17 | });
18 | [Fact]
19 | public void Validate() => AssertConfigurationIsValid();
20 | }
--------------------------------------------------------------------------------
/src/AutoMapper/QueryableExtensions/ProjectionMappers/NullableSourceProjectionMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.QueryableExtensions.Impl;
2 | internal class NullableSourceProjectionMapper : IProjectionMapper
3 | {
4 | public Expression Project(IGlobalConfiguration configuration, in ProjectionRequest request, Expression resolvedSource, LetPropertyMaps letPropertyMaps) =>
5 | Coalesce(resolvedSource, New(request.DestinationType));
6 | public bool IsMatch(TypePair context) =>
7 | context.DestinationType.IsValueType && !context.DestinationType.IsNullableType() && context.SourceType.IsNullableType();
8 | }
--------------------------------------------------------------------------------
/src/AutoMapper/Internal/LockingConcurrentDictionary.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | namespace AutoMapper.Internal;
3 | public readonly struct LockingConcurrentDictionary(Func valueFactory, int capacity = 31)
4 | {
5 | private readonly Func> _valueFactory = key => new(() => valueFactory(key));
6 | private readonly ConcurrentDictionary> _dictionary = new(Environment.ProcessorCount, capacity);
7 | public TValue GetOrAdd(in TKey key) => _dictionary.GetOrAdd(key, _valueFactory).Value;
8 | public bool IsDefault => _dictionary == null;
9 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MissingMapping.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 | public class MissingMapping : AutoMapperSpecBase
3 | {
4 | public class Source
5 | {
6 | public int Value { get; set; }
7 | }
8 |
9 | public class Dest
10 | {
11 | public int Value { get; set; }
12 | }
13 |
14 | protected override MapperConfiguration CreateConfiguration() => new(c => { });
15 |
16 | [Fact]
17 | public void Can_not_map_unmapped_type()
18 | {
19 | new Action(() => Mapper.Map(new Source())).ShouldThrow();
20 | }
21 | }
--------------------------------------------------------------------------------
/docs/source/API-Changes.md:
--------------------------------------------------------------------------------
1 | # API Changes
2 |
3 | Starting with version 9.0, you can find out [what changed](https://raw.githubusercontent.com/AutoMapper/AutoMapper/master/src/AutoMapper/ApiCompatBaseline.txt) in the public API from the last major version release.
4 | From the [releases page](https://github.com/AutoMapper/AutoMapper/releases) you can reach the source code for that release and the version of ApiCompatBaseline.txt in that tree will tell you what changed.
5 | A major version release is compared with the previous major version release (so 9.0.0 with 8.0.0) and a minor version release with the current major version release (so 9.1.1 with 9.0.0).
--------------------------------------------------------------------------------
/src/AutoMapper/Mappers/ParseStringMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Internal.Mappers;
2 |
3 | public class ParseStringMapper : IObjectMapper
4 | {
5 | public bool IsMatch(TypePair context) => context.SourceType == typeof(string) && HasParse(context.DestinationType);
6 | static bool HasParse(Type type) => type == typeof(Guid) || type == typeof(TimeSpan) || type == typeof(DateTimeOffset);
7 | public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) =>
8 | Call(destExpression.Type.GetMethod("Parse", [typeof(string)]), sourceExpression);
9 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/Entity17.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3WithCollections;
2 |
3 | public class Entity17 :BaseEntity
4 | {
5 | public Entity17()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities8 = new List();
9 | this.Entities5 = new List();
10 | this.Entities18 = new List();
11 | }
12 |
13 | public ICollection Entities20 { get; set; }
14 | public ICollection Entities8 { get; set; }
15 | public ICollection Entities5 { get; set; }
16 | public ICollection Entities18 { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/NullableEnums.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class NullableEnums : AutoMapperSpecBase
4 | {
5 | public class Src { public EnumType? A { get; set; } }
6 | public class Dst { public EnumType? A { get; set; } }
7 |
8 | public enum EnumType { One, Two }
9 |
10 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
11 | {
12 | cfg.CreateMap();
13 | });
14 |
15 | [Fact]
16 | public void TestNullableEnum()
17 | {
18 | var d = Mapper.Map(new Src { A = null }, new Dst { A = EnumType.One });
19 |
20 | d.A.ShouldBeNull();
21 | }
22 | }
--------------------------------------------------------------------------------
/src/UnitTests/ExplicitMapperCreation.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 | public class ExplicitMapperCreation : AutoMapperSpecBase
3 | {
4 | protected override MapperConfiguration CreateConfiguration() =>new(cfg => cfg.CreateMap());
5 | public class Source
6 | {
7 | public int Value { get; set; }
8 | }
9 | public class Dest
10 | {
11 | public int Value { get; set; }
12 | }
13 | [Fact]
14 | public void Should_map()
15 | {
16 | var source = new Source {Value = 10};
17 | var dest = Mapper.Map(source);
18 | dest.Value.ShouldBe(source.Value);
19 | }
20 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity8.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity8 : BaseEntity
4 | {
5 | public Entity8()
6 | {
7 | //this.Entities20 = new Entity20();
8 | //this.Entities22 = new Entity22();
9 | //this.Entities3 = new Entity3();
10 | //this.Entities11 = new Entity11();
11 | //this.Entities17 = new Entity17();
12 | }
13 |
14 | public Entity20 Entities20 { get; set; }
15 | public Entity17 Entities17 { get; set; }
16 | public Entity22 Entities22 { get; set; }
17 | public Entity3 Entities3 { get; set; }
18 | public Entity11 Entities11 { get; set; }
19 | }
20 |
--------------------------------------------------------------------------------
/src/AutoMapper/Configuration/Annotations/IgnoreAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Configuration.Annotations;
2 |
3 | ///
4 | /// Ignore this member for configuration validation and skip during mapping.
5 | ///
6 | ///
7 | /// Must be used in combination with
8 | ///
9 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
10 | public sealed class IgnoreAttribute : Attribute, IMemberConfigurationProvider
11 | {
12 | public void ApplyConfiguration(IMemberConfigurationExpression memberConfigurationExpression)
13 | {
14 | memberConfigurationExpression.Ignore();
15 | }
16 | }
--------------------------------------------------------------------------------
/src/AutoMapper/Mappers/ToStringMapper.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Internal.Mappers;
2 | public class ToStringMapper : IObjectMapper
3 | {
4 | public bool IsMatch(TypePair context) => context.DestinationType == typeof(string);
5 | public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression)
6 | {
7 | var sourceType = sourceExpression.Type;
8 | var toStringCall = Call(sourceExpression, ObjectToString);
9 | return sourceType.IsEnum ? StringToEnumMapper.CheckEnumMember(sourceExpression, sourceType, toStringCall) : toStringCall;
10 | }
11 | }
--------------------------------------------------------------------------------
/src/AutoMapper/ApiCompat/PreBuild.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | version=$1
3 | echo $version
4 | readarray -d . -t versionNumbers <<< $version
5 | if [[ ${versionNumbers[1]} -eq "0" && ${versionNumbers[2]} -eq "0" ]]
6 | then
7 | oldVersion=$(({versionNumbers[0]} - 1))
8 | else
9 | oldVersion=${versionNumbers[0]}
10 | fi
11 | oldVersion="$oldVersion.0.0"
12 | echo $oldVersion
13 | rm -rf ../LastMajorVersionBinary
14 | curl https://globalcdn.nuget.org/packages/automapper.$oldVersion.nupkg --create-dirs -o ../LastMajorVersionBinary/automapper.$oldVersion.nupkg
15 | unzip -j ../LastMajorVersionBinary/automapper.$oldVersion.nupkg lib/netstandard2.1/AutoMapper.dll -d ../LastMajorVersionBinary
16 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO8.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO8 : BaseEntity
4 | {
5 | public EntityDTO8()
6 | {
7 | this.Entities20 = new EntityDTO20();
8 | this.Entities22 = new EntityDTO22();
9 | this.Entities3 = new EntityDTO3();
10 | this.Entities11 = new EntityDTO11();
11 | this.Entities17 = new EntityDTO17();
12 | }
13 |
14 | public EntityDTO20 Entities20 { get; set; }
15 | public EntityDTO17 Entities17 { get; set; }
16 | public EntityDTO22 Entities22 { get; set; }
17 | public EntityDTO3 Entities3 { get; set; }
18 | public EntityDTO11 Entities11 { get; set; }
19 | }
20 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntimeWithCollections/EntityDTO17.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3WithCollections;
2 |
3 | public class EntityDTO17 :BaseEntity
4 | {
5 | public EntityDTO17()
6 | {
7 | this.Entities20 = new List();
8 | this.Entities8 = new List();
9 | this.Entities5 = new List();
10 | this.Entities18 = new List();
11 | }
12 |
13 | public ICollection Entities20 { get; set; }
14 | public ICollection Entities8 { get; set; }
15 | public ICollection Entities5 { get; set; }
16 | public ICollection Entities18 { get; set; }
17 | }
18 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/PropertyNamedType.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class PropertyNamedType
4 | {
5 | class Source
6 | {
7 | public int Number { get; set; }
8 | }
9 | class Destination
10 | {
11 | public int Type { get; set; }
12 | }
13 |
14 | [Fact]
15 | public void Should_detect_unmapped_destination_property_named_type()
16 | {
17 | var config = new MapperConfiguration(c=>c.CreateMap());
18 | new Action(config.AssertConfigurationIsValid).ShouldThrowException(
19 | ex=>ex.Errors[0].UnmappedPropertyNames[0].ShouldBe("Type"));
20 | }
21 | }
--------------------------------------------------------------------------------
/docs/source/8.1.1-Upgrade-Guide.md:
--------------------------------------------------------------------------------
1 | # 8.1.1 Upgrade Guide
2 |
3 | The purpose of this release is to allow you to upgrade to 9.0 gradually.
4 |
5 | ## AutoMapper no longer creates maps automatically by default
6 |
7 | `CreateMissingTypeMaps` was deprecated and its default value changed to `false`. If you were relying on this, your app will no longer work by default.
8 |
9 | If you're not interested in upgrading to 9.0, where dynamic mapping was removed, you should stick with 8.1.
10 |
11 | Otherwise you can port your app gradually to 9.0 by creating the needed maps. Setting `CreateMissingTypeMaps` to `false` will get you the 9.0 behavior and setting it to `true` will revert to the 8.1 behavior.
12 |
--------------------------------------------------------------------------------
/src/UnitTests/Bug/RemovePrefixes.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class RemovePrefixes : NonValidatingSpecBase
4 | {
5 | class Source
6 | {
7 | public int GetNumber { get; set; }
8 | }
9 | class Destination
10 | {
11 | public int Number { get; set; }
12 | }
13 |
14 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
15 | {
16 | cfg.ClearPrefixes();
17 | cfg.CreateMap();
18 | });
19 |
20 | [Fact]
21 | public void Should_not_map_with_default_postfix()
22 | {
23 | new Action(AssertConfigurationIsValid).ShouldThrow();
24 | }
25 | }
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Jimmy Bogard
5 | latest
6 | $(NoWarn);CS1701;CS1702;CS1591
7 | true
8 | strict
9 | enable
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/source/Value-transformers.md:
--------------------------------------------------------------------------------
1 | # Value Transformers
2 |
3 | Value transformers apply an additional transformation to a single type. Before assigning the value, AutoMapper will check to see if the value to be set has any value transformations associated, and will apply them before setting.
4 |
5 | You can create value transformers at several different levels:
6 |
7 | - Globally
8 | - Profile
9 | - Map
10 | - Member
11 |
12 | ```c#
13 | var configuration = new MapperConfiguration(cfg => {
14 | cfg.ValueTransformers.Add(val => val + "!!!");
15 | });
16 |
17 | var source = new Source { Value = "Hello" };
18 | var dest = mapper.Map(source);
19 |
20 | dest.Value.ShouldBe("Hello!!!");
21 | ```
22 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/src/AutoMapper/Configuration/Annotations/UseExistingValueAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Configuration.Annotations;
2 |
3 | ///
4 | /// Use the destination value instead of mapping from the source value or creating a new instance
5 | ///
6 | ///
7 | /// Must be used in combination with
8 | ///
9 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
10 | public sealed class UseExistingValueAttribute : Attribute, IMemberConfigurationProvider
11 | {
12 | public void ApplyConfiguration(IMemberConfigurationExpression memberConfigurationExpression)
13 | {
14 | memberConfigurationExpression.UseDestinationValue();
15 | }
16 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/Entity5.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDatabaseModel3;
2 |
3 | public class Entity5 : BaseEntity
4 | {
5 | public Entity5()
6 | {
7 | //this.Entities6 = new Entity6();
8 | //this.TimeSlots = new Entity23();
9 | //this.Entities5 = new Entity5();
10 | }
11 |
12 | public Guid? Entity8Id { get; set; }
13 | public Entity8 Entity8 { get; set; }
14 | public Guid? Entity17Id { get; set; }
15 | public Entity17 Entity17 { get; set; }
16 | public Guid? Entity5Id { get; set; }
17 | public Entity5 Entity5Exception { get; set; }
18 | public Entity5 Entities5 { get; set; }
19 | public Entity6 Entities6 { get; set; }
20 | public Entity23 TimeSlots { get; set; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/AutoMapper/Configuration/Annotations/MapAtRuntimeAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Configuration.Annotations;
2 |
3 | ///
4 | /// Do not precompute the execution plan for this member, just map it at runtime.
5 | /// Simplifies the execution plan by not inlining.
6 | ///
7 | ///
8 | /// Must be used in combination with
9 | ///
10 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
11 | public sealed class MapAtRuntimeAttribute : Attribute, IMemberConfigurationProvider
12 | {
13 | public void ApplyConfiguration(IMemberConfigurationExpression memberConfigurationExpression)
14 | {
15 | memberConfigurationExpression.MapAtRuntime();
16 | }
17 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/ReadOnlyCollectionMappingBug.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | // Bug #511
4 | // https://github.com/AutoMapper/AutoMapper/issues/511
5 | public class ReadOnlyCollectionMappingBug
6 | {
7 | class Source { public int X { get; set; } }
8 | class Target { public int X { get; set; } }
9 |
10 | [Fact]
11 | public void Example()
12 | {
13 | var config = new MapperConfiguration(cfg => cfg.CreateMap());
14 |
15 | var source = new List { new Source { X = 42 } };
16 | var target = config.CreateMapper().Map>(source);
17 |
18 | target.Count.ShouldBe(source.Count);
19 | target[0].X.ShouldBe(source[0].X);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/AutoMapper/Configuration/Annotations/MappingOrderAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.Configuration.Annotations;
2 |
3 | ///
4 | /// Supply a custom mapping order instead of what the .NET runtime returns
5 | ///
6 | ///
7 | /// Must be used in combination with
8 | ///
9 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
10 | public sealed class MappingOrderAttribute(int value) : Attribute, IMemberConfigurationProvider
11 | {
12 | public int Value { get; } = value;
13 |
14 | public void ApplyConfiguration(IMemberConfigurationExpression memberConfigurationExpression)
15 | {
16 | memberConfigurationExpression.SetMappingOrder(Value);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/NullableToInvalid.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Bug;
2 |
3 | public class NullableToInvalid : NonValidatingSpecBase
4 | {
5 | public class Source
6 | {
7 | public int? Value { get; set; }
8 | }
9 |
10 | public class Destination
11 | {
12 | public SomeObject Value { get; set; }
13 | }
14 |
15 | public class SomeObject
16 | {
17 | }
18 |
19 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
20 | {
21 | cfg.CreateMap();
22 | });
23 |
24 | [Fact]
25 | public void Should_not_validate()
26 | {
27 | new Action(AssertConfigurationIsValid).ShouldThrow();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/UnitTests/ConfigCompilation.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 | public class ConfigCompilation : NonValidatingSpecBase
3 | {
4 | public class Source { }
5 | public class Dest { }
6 | public class Source2 { }
7 | public class Dest2 { }
8 |
9 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
10 | {
11 | cfg.CreateMap();
12 | cfg.CreateMap();
13 | cfg.CreateMap(typeof(IEnumerable<>), typeof(IEnumerable<>)).ConvertUsing(s => s);
14 | });
15 |
16 | [Fact]
17 | public void Should_compile_mappings()
18 | {
19 | Configuration.CompileMappings();
20 |
21 | Mapper.Map(new Source()).ShouldNotBeNull();
22 | }
23 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapExpandoObjectProperty.cs:
--------------------------------------------------------------------------------
1 | using System.Dynamic;
2 |
3 | namespace AutoMapper.UnitTests.Bug;
4 |
5 | public class MapExpandoObjectProperty : AutoMapperSpecBase
6 | {
7 |
8 | class From
9 | {
10 | public ExpandoObject ExpandoObject { get; set; }
11 | }
12 |
13 | class To
14 | {
15 | public ExpandoObject ExpandoObject { get; set; }
16 | }
17 |
18 | protected override MapperConfiguration CreateConfiguration() => new(cfg =>
19 | {
20 | cfg.CreateMap();
21 | });
22 | [Fact]
23 | public void Should_work()
24 | {
25 | dynamic baseSettings = new ExpandoObject();
26 | var settings = Mapper.Map(new From { ExpandoObject = baseSettings});
27 | }
28 | }
--------------------------------------------------------------------------------
/src/UnitTests/Internal/ObjectFactoryTests.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 |
3 | using Execution;
4 | public class ObjectFactoryTests
5 | {
6 | [Fact]
7 | public void Test_with_create_ctor() => ObjectFactory.CreateInstance(typeof(ObjectFactoryTests)).ShouldBeOfType();
8 | [Fact]
9 | public void Test_with_value_object_create_ctor() => ObjectFactory.CreateInstance(typeof(DateTimeOffset)).ShouldBeOfType();
10 | [Fact]
11 | public void Create_ctor_should_throw_when_default_constructor_is_missing() =>
12 | new Action(() => ObjectFactory.CreateInstance(typeof(AssemblyLoadEventArgs)))
13 | .ShouldThrow().Message.ShouldStartWith(typeof(AssemblyLoadEventArgs).FullName);
14 | }
--------------------------------------------------------------------------------
/src/UnitTests/AddProfiles.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 |
3 | public class AddProfiles : AutoMapperSpecBase
4 | {
5 | public class Source { }
6 | public class Dest { }
7 | public class ForwardProfile : Profile
8 | {
9 | public ForwardProfile() => CreateMap();
10 | }
11 | public class ReverseProfile : Profile
12 | {
13 | public ReverseProfile() => CreateMap();
14 | }
15 | protected override MapperConfiguration CreateConfiguration() => new(c => c.AddProfiles(new Profile[] { new ForwardProfile(), new ReverseProfile() }));
16 | [Fact]
17 | public void Should_not_throw_when_loading_multiple_profiles() => GetProfiles().Count().ShouldBe(3); // default plus two specifically added
18 | }
--------------------------------------------------------------------------------
/src/Benchmark/BenchEngine.cs:
--------------------------------------------------------------------------------
1 | namespace Benchmark;
2 |
3 | public class BenchEngine
4 | {
5 | private readonly IObjectToObjectMapper _mapper;
6 | private readonly string _mode;
7 |
8 | public BenchEngine(IObjectToObjectMapper mapper, string mode)
9 | {
10 | _mapper = mapper;
11 | _mode = mode;
12 | }
13 |
14 | public void Start()
15 | {
16 | _mapper.Initialize();
17 | _mapper.Map();
18 |
19 | var timer = Stopwatch.StartNew();
20 |
21 | for(int i = 0; i < 1_000_000; i++)
22 | {
23 | _mapper.Map();
24 | }
25 |
26 | timer.Stop();
27 |
28 | Console.WriteLine("{2:D3} ms {0}: - {1}", _mapper.Name, _mode, (int)timer.Elapsed.TotalMilliseconds);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/UnitTests/Bug/MapAtRuntime/EntityDTO5.cs:
--------------------------------------------------------------------------------
1 | namespace OmmitedDTOModel3;
2 |
3 | public class EntityDTO5 : BaseEntity
4 | {
5 | public EntityDTO5()
6 | {
7 | //this.Entities6 = new EntityDTO6();
8 | //this.TimeSlots = new EntityDTO23();
9 | //this.Entities5 = new EntityDTO5();
10 | }
11 |
12 | public Guid? Entity8Id { get; set; }
13 | public EntityDTO8 Entity8 { get; set; }
14 | public Guid? Entity17Id { get; set; }
15 | public EntityDTO17 Entity17 { get; set; }
16 | public Guid? Entity5Id { get; set; }
17 | public EntityDTO5 Entity5Exception { get; set; }
18 | public EntityDTO5 Entities5 { get; set; }
19 | public EntityDTO6 Entities6 { get; set; }
20 | public EntityDTO23 TimeSlots { get; set; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/UnitTests/TypeExtensionsTests.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests;
2 | public class TypeExtensionsTests
3 | {
4 | public class Foo
5 | {
6 | public Foo()
7 | {
8 | Value2 = "adsf";
9 | Value4 = "Fasdfadsf";
10 | }
11 |
12 | public string Value1 { get; set; }
13 | public string Value2 { get; private set; }
14 | protected string Value3 { get; set; }
15 | private string Value4 { get; set; }
16 | public string Value5 => "ASDf";
17 | public string Value6 { set { Value4 = value; } }
18 |
19 | [Fact]
20 | public void Should_recognize_public_members()
21 | {
22 | // typeof(Foo).GetProperties().Length.ShouldBe(4);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/UnitTests/Mappers/TypeHelperTests.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapper.UnitTests.Mappers;
2 |
3 | public class TypeHelperTests
4 | {
5 | [Fact]
6 | public void CanReturnElementTypeOnCollectionThatImplementsTheSameGenericInterfaceMultipleTimes()
7 | {
8 | Type myType = typeof(ChargeCollection);
9 |
10 | Type elementType = ReflectionHelper.GetElementType(myType);
11 |
12 | elementType.ShouldNotBeNull();
13 | }
14 |
15 | public class Charge { }
16 |
17 | public interface IChargeCollection : IEnumerable