Skip to content

Commit 0f8b6ed

Browse files
gdlcf88claude
andauthored
refactor: migrate object mapping from AutoMapper to Mapperly (#10)
Replace Volo.Abp.AutoMapper with Volo.Abp.Mapperly and convert the AutoMapper profiles into Mapperly mappers. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2a6e750 commit 0f8b6ed

12 files changed

Lines changed: 66 additions & 90 deletions

samples/PhoneNumberLoginSample/src/PhoneNumberLoginSample.Application/PhoneNumberLoginSampleApplicationAutoMapperProfile.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

samples/PhoneNumberLoginSample/src/PhoneNumberLoginSample.Application/PhoneNumberLoginSampleApplicationModule.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using EasyAbp.Abp.PhoneNumberLogin;
22
using Volo.Abp.Account;
3-
using Volo.Abp.AutoMapper;
43
using Volo.Abp.FeatureManagement;
54
using Volo.Abp.Identity;
65
using Volo.Abp.Modularity;
@@ -23,12 +22,5 @@ namespace PhoneNumberLoginSample
2322
)]
2423
public class PhoneNumberLoginSampleApplicationModule : AbpModule
2524
{
26-
public override void ConfigureServices(ServiceConfigurationContext context)
27-
{
28-
Configure<AbpAutoMapperOptions>(options =>
29-
{
30-
options.AddMaps<PhoneNumberLoginSampleApplicationModule>();
31-
});
32-
}
3325
}
3426
}

samples/PhoneNumberLoginSample/src/PhoneNumberLoginSample.Web/PhoneNumberLoginSampleWebAutoMapperProfile.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

samples/PhoneNumberLoginSample/src/PhoneNumberLoginSample.Web/PhoneNumberLoginSampleWebModule.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
2222
using Volo.Abp.AspNetCore.Serilog;
2323
using Volo.Abp.Autofac;
24-
using Volo.Abp.AutoMapper;
2524
using Volo.Abp.FeatureManagement;
2625
using Volo.Abp.Identity.Web;
2726
using Volo.Abp.Localization;
@@ -84,7 +83,6 @@ public override void ConfigureServices(ServiceConfigurationContext context)
8483

8584
ConfigureUrls(configuration);
8685
ConfigureAuthentication(context);
87-
ConfigureAutoMapper();
8886
ConfigureVirtualFileSystem(hostingEnvironment);
8987
ConfigureLocalizationServices();
9088
ConfigureNavigationServices();
@@ -106,11 +104,6 @@ private void ConfigureAuthentication(ServiceConfigurationContext context)
106104
.AuthenticationScheme);
107105
}
108106

109-
private void ConfigureAutoMapper()
110-
{
111-
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<PhoneNumberLoginSampleWebModule>(); });
112-
}
113-
114107
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
115108
{
116109
if (hostingEnvironment.IsDevelopment())

src/EasyAbp.Abp.PhoneNumberLogin.Application/EasyAbp.Abp.PhoneNumberLogin.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
11+
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
1212
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(AbpVersion)" />
1313
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="$(AbpVersion)" />
1414
<PackageReference Include="EasyAbp.Abp.VerificationCode" Version="$(EasyAbpAbpVerificationCodeModuleVersion)" />
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using EasyAbp.Abp.VerificationCode;
22
using Microsoft.Extensions.DependencyInjection;
3-
using Volo.Abp.AutoMapper;
3+
using Volo.Abp.Mapperly;
44
using Volo.Abp.Modularity;
55
using Volo.Abp.Application;
66
using Volo.Abp.Http.Client.IdentityModel;
@@ -11,19 +11,15 @@ namespace EasyAbp.Abp.PhoneNumberLogin
1111
typeof(AbpPhoneNumberLoginDomainModule),
1212
typeof(AbpPhoneNumberLoginApplicationContractsModule),
1313
typeof(AbpDddApplicationModule),
14-
typeof(AbpAutoMapperModule),
14+
typeof(AbpMapperlyModule),
1515
typeof(AbpVerificationCodeModule),
1616
typeof(AbpHttpClientIdentityModelModule)
1717
)]
1818
public class AbpPhoneNumberLoginApplicationModule : AbpModule
1919
{
2020
public override void ConfigureServices(ServiceConfigurationContext context)
2121
{
22-
context.Services.AddAutoMapperObjectMapper<AbpPhoneNumberLoginApplicationModule>();
23-
Configure<AbpAutoMapperOptions>(options =>
24-
{
25-
options.AddMaps<AbpPhoneNumberLoginApplicationModule>(validate: true);
26-
});
22+
context.Services.AddMapperlyObjectMapper<AbpPhoneNumberLoginApplicationModule>();
2723
}
2824
}
2925
}

src/EasyAbp.Abp.PhoneNumberLogin.Application/EasyAbp/Abp/PhoneNumberLogin/PhoneNumberLoginApplicationAutoMapperProfile.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Riok.Mapperly.Abstractions;
2+
using Volo.Abp.Identity;
3+
using Volo.Abp.Mapperly;
4+
using IdentityUser = Volo.Abp.Identity.IdentityUser;
5+
6+
namespace EasyAbp.Abp.PhoneNumberLogin
7+
{
8+
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
9+
[MapExtraProperties]
10+
public partial class IdentityUserToIdentityUserDtoMapper : MapperBase<IdentityUser, IdentityUserDto>
11+
{
12+
public override partial IdentityUserDto Map(IdentityUser source);
13+
public override partial void Map(IdentityUser source, IdentityUserDto destination);
14+
}
15+
}

src/EasyAbp.Abp.PhoneNumberLogin.Web/AbpPhoneNumberLoginWebModule.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Volo.Abp.Account.Web;
66
using Volo.Abp.AspNetCore.Mvc.Localization;
77
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
8-
using Volo.Abp.AutoMapper;
8+
using Volo.Abp.Mapperly;
99
using Volo.Abp.Modularity;
1010
using Volo.Abp.UI.Navigation;
1111
using Volo.Abp.VirtualFileSystem;
@@ -19,7 +19,7 @@ namespace EasyAbp.Abp.PhoneNumberLogin.Web
1919
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
2020
typeof(AbpAccountWebModule),
2121
typeof(AbpIdentityDomainSharedModule),
22-
typeof(AbpAutoMapperModule)
22+
typeof(AbpMapperlyModule)
2323
)]
2424
public class AbpPhoneNumberLoginWebModule : AbpModule
2525
{
@@ -48,11 +48,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
4848
options.FileSets.AddEmbedded<AbpPhoneNumberLoginWebModule>();
4949
});
5050

51-
context.Services.AddAutoMapperObjectMapper<AbpPhoneNumberLoginWebModule>();
52-
Configure<AbpAutoMapperOptions>(options =>
53-
{
54-
options.AddMaps<AbpPhoneNumberLoginWebModule>(validate: true);
55-
});
51+
context.Services.AddMapperlyObjectMapper<AbpPhoneNumberLoginWebModule>();
5652

5753
Configure<RazorPagesOptions>(options =>
5854
{

src/EasyAbp.Abp.PhoneNumberLogin.Web/EasyAbp.Abp.PhoneNumberLogin.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Volo.Abp.Account.Web" Version="$(AbpVersion)" />
16-
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
16+
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
1717
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared" Version="$(AbpVersion)" />
1818
<PackageReference Include="Volo.Abp.Identity.Domain.Shared" Version="$(AbpVersion)" />
1919
</ItemGroup>

0 commit comments

Comments
 (0)