- Upgrade AutoMapper from 12.0.1 to 16.2.0
- Remove deprecated AutoMapper.Extensions.Microsoft.DependencyInjection v12.0.1
(deprecated 25 May 2023, DI moved to main package in v13.0+)
- Update DI registration: AddAutoMapper(cfg => {}, typeof(MappingProfile))
(v13.0+ requires Action<IMapperConfigurationExpression> + marker type)
Security fix:
- Resolves NU1903 vulnerability (GHSA-rvv3-g6hj-g44x DoS in v12.0.1)
Result: AutoMapper v16.2.0, 0 security warnings, all tests passing
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using FluentValidation;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace DocumentOperator.Application;
|
|
|
|
/// <summary>
|
|
/// Dependency Injection configuration for Application Layer
|
|
/// </summary>
|
|
public static class DependencyInjection
|
|
{
|
|
/// <summary>
|
|
/// Registers Application Layer services (MediatR, FluentValidation, AutoMapper, Behaviors)
|
|
/// </summary>
|
|
public static IServiceCollection AddApplication(this IServiceCollection services)
|
|
{
|
|
var assembly = typeof(DependencyInjection).Assembly;
|
|
|
|
// Register MediatR (scannt Assembly nach Handlers)
|
|
services.AddMediatR(config =>
|
|
{
|
|
config.RegisterServicesFromAssembly(assembly);
|
|
|
|
// Pipeline Behaviors (Reihenfolge wichtig!)
|
|
config.AddOpenBehavior(typeof(Common.Behaviors.ValidationBehavior<,>));
|
|
config.AddOpenBehavior(typeof(Common.Behaviors.LoggingBehavior<,>));
|
|
});
|
|
|
|
// Register FluentValidation (scannt Assembly nach Validators)
|
|
services.AddValidatorsFromAssembly(assembly);
|
|
|
|
// Register AutoMapper (scannt Assembly nach Profiles)
|
|
services.AddAutoMapper(cfg => { }, typeof(Common.Mapping.MappingProfile));
|
|
|
|
return services;
|
|
}
|
|
}
|