diff --git a/appveyor.yml b/appveyor.yml
index 1ff9636..2e7415a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -4,6 +4,9 @@ image: Visual Studio 2017
pull_requests:
do_not_increment_build_number: true
+init:
+ - git config --global core.autocrlf input
+
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
diff --git a/common.props b/common.props
index 3563277..5d4dd83 100644
--- a/common.props
+++ b/common.props
@@ -1,6 +1,6 @@
- 1.0.2
+ 1.0.3
$(NoWarn);CS1591
https://raw.githubusercontent.com/osoykan/Stove/master/stove.png
https://github.com/osoykan/Stove
@@ -18,4 +18,9 @@
false
false
+
+
+
+
+
\ No newline at end of file
diff --git a/nupkg/packs.ps1 b/nupkg/packs.ps1
index 2b0eb0a..110a665 100644
--- a/nupkg/packs.ps1
+++ b/nupkg/packs.ps1
@@ -19,7 +19,7 @@ $projects = (
# Rebuild solution
Set-Location $slnPath
-& dotnet msbuild /t:Rebuild /p:Configuration=Release
+& dotnet restore
# Copy all nuget packages to the pack folder
foreach($project in $projects) {
@@ -28,7 +28,8 @@ foreach($project in $projects) {
# Create nuget pack
Set-Location $projectFolder
- & dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true
+# Remove-Item -Recurse (Join-Path $projectFolder "bin/Release")
+ & dotnet msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true /p:SourceLinkCreate=true
# Copy nuget package
$projectPackPath = Join-Path $projectFolder ("/bin/Release/" + $project + ".*.nupkg")
diff --git a/src/Stove.Mapster/Mapster/MapsterObjectMapper.cs b/src/Stove.Mapster/Mapster/MapsterObjectMapper.cs
index 1b72f30..578b422 100644
--- a/src/Stove.Mapster/Mapster/MapsterObjectMapper.cs
+++ b/src/Stove.Mapster/Mapster/MapsterObjectMapper.cs
@@ -1,4 +1,6 @@
-using Mapster;
+using System;
+
+using Mapster;
using Stove.ObjectMapping;
@@ -10,12 +12,16 @@ public class MapsterObjectMapper : IObjectMapper
public MapsterObjectMapper(IStoveMapsterConfiguration mapsterConfiguration)
{
- this._mapsterConfiguration = mapsterConfiguration;
+ _mapsterConfiguration = mapsterConfiguration;
}
public TDestination Map(object source)
{
- return source.Adapt(_mapsterConfiguration.Configuration);
+ Type sourceType = source.GetType().Namespace == "System.Data.Entity.DynamicProxies"
+ ? source.GetType().BaseType
+ : source.GetType();
+
+ return (TDestination)source.Adapt(sourceType, typeof(TDestination), _mapsterConfiguration.Configuration);
}
public TDestination Map(TSource source, TDestination destination)
diff --git a/src/Stove/Stove.csproj b/src/Stove/Stove.csproj
index 18e0df8..b3cebc0 100644
--- a/src/Stove/Stove.csproj
+++ b/src/Stove/Stove.csproj
@@ -18,9 +18,9 @@
-
-
-
+
+
+
diff --git a/test/Stove.Demo.ConsoleApp.Nh/Stove.Demo.ConsoleApp.Nh.csproj b/test/Stove.Demo.ConsoleApp.Nh/Stove.Demo.ConsoleApp.Nh.csproj
index 70f9b8b..01dc97b 100644
--- a/test/Stove.Demo.ConsoleApp.Nh/Stove.Demo.ConsoleApp.Nh.csproj
+++ b/test/Stove.Demo.ConsoleApp.Nh/Stove.Demo.ConsoleApp.Nh.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj
index 99be9c9..47feb4a 100644
--- a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj
+++ b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj
@@ -43,7 +43,7 @@
-
+
diff --git a/test/Stove.Demo.WebApi/Stove.Demo.WebApi.csproj b/test/Stove.Demo.WebApi/Stove.Demo.WebApi.csproj
index 9fa8284..4b4bdec 100644
--- a/test/Stove.Demo.WebApi/Stove.Demo.WebApi.csproj
+++ b/test/Stove.Demo.WebApi/Stove.Demo.WebApi.csproj
@@ -31,7 +31,7 @@
-
+
diff --git a/test/Stove.NHibernate.Tests/Stove.NHibernate.Tests.csproj b/test/Stove.NHibernate.Tests/Stove.NHibernate.Tests.csproj
index 0e88469..bdd1d6a 100644
--- a/test/Stove.NHibernate.Tests/Stove.NHibernate.Tests.csproj
+++ b/test/Stove.NHibernate.Tests/Stove.NHibernate.Tests.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/test/Stove.TestBase/Stove.TestBase.csproj b/test/Stove.TestBase/Stove.TestBase.csproj
index eec3cef..953dd95 100644
--- a/test/Stove.TestBase/Stove.TestBase.csproj
+++ b/test/Stove.TestBase/Stove.TestBase.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs b/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs
index e0f4843..f3b467c 100644
--- a/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs
+++ b/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs
@@ -1,7 +1,17 @@
-using Shouldly;
+using System.Collections.Generic;
+using System.Data.Entity.Core.Objects;
+using System.Data.Entity.Core.Objects.Internal;
+using Shouldly;
+
+using Stove.Configuration;
+using Stove.Domain.Repositories;
+using Stove.Domain.Uow;
+using Stove.Mapster;
using Stove.ObjectMapping;
+using Stove.Tests.SampleApplication.Domain.Entities;
using Stove.Tests.SampleApplication.Dtos;
+using Stove.Timing;
using Xunit;
@@ -24,5 +34,47 @@ public void auto_object_mapping_should_work()
personDto.ShouldNotBeNull();
personEntity.ShouldNotBeNull();
}
+
+ [Fact]
+ public void proxied_object_can_mapped_through_objectmapper_with_required_explicit_mapping()
+ {
+ Building(builder => { }).Ok();
+
+ The().StoveMapster().Configuration.RequireExplicitMapping = true;
+
+ var mapper = The();
+
+ using (IUnitOfWorkCompleteHandle uow = The().Begin())
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ User user = The>().Insert(new User()
+ {
+ CreationTime = Clock.Now,
+ Name = $"Oğuzhan{i}",
+ Surname = $"Soykan{i}",
+ Email = $"oguzhansoykan@outlook.com{i}"
+ });
+
+ var userDto = mapper.Map(user);
+ userDto.ShouldNotBeNull();
+ }
+
+ uow.Complete();
+ }
+
+ using (IUnitOfWorkCompleteHandle uow = The().Begin())
+ {
+ List users = The>().GetAllList();
+
+ users.ForEach(user =>
+ {
+ var userDto = mapper.Map(user);
+ userDto.ShouldNotBeNull();
+ });
+
+ uow.Complete();
+ }
+ }
}
}
diff --git a/test/Stove.Tests.SampleApplication/Domain/Entities/User.cs b/test/Stove.Tests.SampleApplication/Domain/Entities/User.cs
index ae42b1d..359abd6 100644
--- a/test/Stove.Tests.SampleApplication/Domain/Entities/User.cs
+++ b/test/Stove.Tests.SampleApplication/Domain/Entities/User.cs
@@ -4,10 +4,13 @@
using Stove.Domain.Entities;
using Stove.Domain.Entities.Auditing;
+using Stove.Mapster;
+using Stove.Tests.SampleApplication.Dtos;
namespace Stove.Tests.SampleApplication.Domain.Entities
{
[Table(nameof(User))]
+ [AutoMapFrom(typeof(UserDto))]
public class User : AggregateRoot, IHasCreationTime
{
[Required]
diff --git a/test/Stove.Tests.SampleApplication/Dtos/UserDto.cs b/test/Stove.Tests.SampleApplication/Dtos/UserDto.cs
new file mode 100644
index 0000000..f291b94
--- /dev/null
+++ b/test/Stove.Tests.SampleApplication/Dtos/UserDto.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Stove.Tests.SampleApplication.Dtos
+{
+ public class UserDto
+ {
+ public virtual string Name { get; set; }
+
+ public virtual string Surname { get; set; }
+
+ public virtual string Email { get; set; }
+
+ public virtual DateTime CreationTime { get; set; }
+ }
+}