Skip to content

Commit 200c487

Browse files
gdlcf88claude
andauthored
refactor: migrate object mapping from AutoMapper to Mapperly (#156)
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 dadce46 commit 200c487

19 files changed

Lines changed: 64 additions & 147 deletions

‎host/EasyAbp.FileManagement.Blazor.Host/FileManagementBlazorHostAutoMapperProfile.cs‎

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

‎host/EasyAbp.FileManagement.Blazor.Host/FileManagementBlazorHostModule.cs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
1212
using Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme;
1313
using Volo.Abp.Autofac.WebAssembly;
14-
using Volo.Abp.AutoMapper;
1514
using Volo.Abp.Identity.Blazor.WebAssembly;
1615
using Volo.Abp.Modularity;
1716
using Volo.Abp.SettingManagement.Blazor.WebAssembly;
@@ -42,7 +41,6 @@ public override void ConfigureServices(ServiceConfigurationContext context)
4241
ConfigureRouter(context);
4342
ConfigureUI(builder);
4443
ConfigureMenu(context);
45-
ConfigureAutoMapper(context);
4644
}
4745

4846
private void ConfigureRouter(ServiceConfigurationContext context)
@@ -90,12 +88,5 @@ private static void ConfigureHttpClient(ServiceConfigurationContext context, IWe
9088
});
9189
}
9290

93-
private void ConfigureAutoMapper(ServiceConfigurationContext context)
94-
{
95-
Configure<AbpAutoMapperOptions>(options =>
96-
{
97-
options.AddMaps<FileManagementBlazorHostModule>();
98-
});
99-
}
10091
}
10192
}

‎host/EasyAbp.FileManagement.Web.Host/FileManagementWebAutoMapperProfile.cs‎

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

‎host/EasyAbp.FileManagement.Web.Host/FileManagementWebHostModule.cs‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
3030
using Volo.Abp.AspNetCore.Serilog;
3131
using Volo.Abp.Autofac;
32-
using Volo.Abp.AutoMapper;
3332
using Volo.Abp.Caching;
3433
using Volo.Abp.Caching.StackExchangeRedis;
3534
using Volo.Abp.FeatureManagement;
@@ -100,7 +99,6 @@ public override void ConfigureServices(ServiceConfigurationContext context)
10099
ConfigureCache(configuration);
101100
ConfigureUrls(configuration);
102101
ConfigureAuthentication(context, configuration);
103-
ConfigureAutoMapper();
104102
ConfigureVirtualFileSystem(hostingEnvironment);
105103
ConfigureSwaggerServices(context.Services);
106104
ConfigureMultiTenancy();
@@ -169,14 +167,6 @@ private void ConfigureAuthentication(ServiceConfigurationContext context, IConfi
169167
});
170168
}
171169

172-
private void ConfigureAutoMapper()
173-
{
174-
Configure<AbpAutoMapperOptions>(options =>
175-
{
176-
options.AddMaps<FileManagementWebHostModule>();
177-
});
178-
}
179-
180170
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
181171
{
182172
if (hostingEnvironment.IsDevelopment())

‎src/EasyAbp.FileManagement.Application/EasyAbp.FileManagement.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
<ProjectReference Include="..\EasyAbp.FileManagement.Application.Contracts\EasyAbp.FileManagement.Application.Contracts.csproj" />
1414
<ProjectReference Include="..\EasyAbp.FileManagement.Domain.Core\EasyAbp.FileManagement.Domain.Core.csproj" />

‎src/EasyAbp.FileManagement.Application/EasyAbp/FileManagement/FileManagementApplicationAutoMapperProfile.cs‎

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using EasyAbp.FileManagement.Files;
2+
using EasyAbp.FileManagement.Files.Dtos;
3+
using Riok.Mapperly.Abstractions;
4+
using Volo.Abp.Mapperly;
5+
6+
namespace EasyAbp.FileManagement
7+
{
8+
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
9+
public partial class FileToFileInfoDtoMapper : MapperBase<File, FileInfoDto>
10+
{
11+
[MapperIgnoreTarget(nameof(FileInfoDto.Owner))]
12+
[MapperIgnoreTarget(nameof(FileInfoDto.Creator))]
13+
[MapperIgnoreTarget(nameof(FileInfoDto.LastModifier))]
14+
public override partial FileInfoDto Map(File source);
15+
16+
[MapperIgnoreTarget(nameof(FileInfoDto.Owner))]
17+
[MapperIgnoreTarget(nameof(FileInfoDto.Creator))]
18+
[MapperIgnoreTarget(nameof(FileInfoDto.LastModifier))]
19+
public override partial void Map(File source, FileInfoDto destination);
20+
}
21+
}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Microsoft.Extensions.DependencyInjection;
2-
using Volo.Abp.AutoMapper;
2+
using Volo.Abp.Mapperly;
33
using Volo.Abp.Modularity;
44
using Volo.Abp.Application;
55

@@ -9,17 +9,13 @@ namespace EasyAbp.FileManagement
99
typeof(FileManagementDomainCoreModule),
1010
typeof(FileManagementApplicationContractsModule),
1111
typeof(AbpDddApplicationModule),
12-
typeof(AbpAutoMapperModule)
12+
typeof(AbpMapperlyModule)
1313
)]
1414
public class FileManagementApplicationModule : AbpModule
1515
{
1616
public override void ConfigureServices(ServiceConfigurationContext context)
1717
{
18-
context.Services.AddAutoMapperObjectMapper<FileManagementApplicationModule>();
19-
Configure<AbpAutoMapperOptions>(options =>
20-
{
21-
options.AddMaps<FileManagementApplicationModule>(validate: true);
22-
});
18+
context.Services.AddMapperlyObjectMapper<FileManagementApplicationModule>();
2319
}
2420
}
2521
}

‎src/EasyAbp.FileManagement.Blazor/EasyAbp.FileManagement.Blazor.csproj‎

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

99
<ItemGroup>
10-
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(AbpVersion)" />
10+
<PackageReference Include="Volo.Abp.Mapperly" Version="$(AbpVersion)" />
1111
<PackageReference Include="Volo.Abp.AspNetCore.Components.Web.Theming" Version="$(AbpVersion)" />
1212
</ItemGroup>
1313

‎src/EasyAbp.FileManagement.Blazor/FileManagementBlazorAutoMapperProfile.cs‎

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

0 commit comments

Comments
 (0)