Skip to content

Commit bdb8eec

Browse files
authored
Merge pull request #2938 from AutoMapper/single-automap-attribute
Assume single automap attribute
2 parents d8e77bd + 8431c50 commit bdb8eec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/AutoMapper/Configuration/MapperConfigurationExpression.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ private void AddMapsCore(IEnumerable<Assembly> assembliesToScan)
9494
{
9595
AddProfile(type.AsType());
9696
}
97-
foreach (var autoMapAttribute in type.GetCustomAttributes<AutoMapAttribute>())
97+
98+
var autoMapAttribute = type.GetCustomAttribute<AutoMapAttribute>();
99+
if (autoMapAttribute != null)
98100
{
99101
var mappingExpression = autoMapAttributeProfile.CreateMap(autoMapAttribute.SourceType, type);
100102
autoMapAttribute.ApplyConfiguration(mappingExpression);

0 commit comments

Comments
 (0)