Skip to content

Commit

Permalink
Changelog fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xriuk committed Nov 5, 2024
1 parent b7eb889 commit 9131e2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
25 changes: 11 additions & 14 deletions src/NeatMapper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Removed

- `IServiceProvider` parameter from `MergeCollectionMapper` and `AsyncMergeCollectionMapper` constructors.
- `IServiceProvider` parameter from `CollectionMapper` and `AsyncCollectionMapper` constructors because `MergeCollectionsMappingOptions.Matcher`, is now a full `IMatcher` and has its own service provider.
- Some ambiguous `params object[]` overloads for `IMapper` `Map` extension methods.

### Changed
Expand All @@ -13,33 +13,30 @@
- New and Merge mappers (normal, collection and async ones) were merged together into a custom one.
- `IMapperCanMap`/`IAsyncMapperCanMap`/`IMatcherCanMatch`/`IProjectorCanProject` interfaces were integrated into their parent interfaces (`IMapper`/`IAsyncMapper`/`IMatcher`/`IProjector`) and removed, all implementing classes and extension methods were adjusted.
- `IAsyncMapper` `CanMapAsync*` methods now return `bool` instead of `Task<bool>` and the `CancellationToken` parameter has been removed.
- `CanMap*`/`CanMapAsync*`/`CanMatch`/`CanProject` methods now should never throw, if an interface type can be mapped true will be returned, and if the object provided does not respect expectations (eg: passing a readonly collection) a mapping exception will be thrown.
- `CanMap*`/`CanMapAsync*`/`CanMatch`/`CanProject` methods now should never throw, if an interface type can be mapped true will be returned, and if the object provided does not respect expectations (eg: passing a readonly collection) a `MappingException`/`MatchingException`/`ProjectionException` will be thrown.
- `DelegateMatcher` constructor was made private and it now can be created only via the type-safe static method `Create`.
- `MergeCollectionsMappingOptions` Matcher was changed from `MatchMapDelegate` to the safer `IMatcher` (which can also be a `CompositeMatcher` to support multiple maps). `IMapper`/`IAsyncMapper` extensions were updated.
- Extension method `Predicate` for `IMatchMapFactory`/`MatchMapFactory<TSource, TDestination>` now have an optional parameter which allows to dispose the provided factory together with the returned one (or in case of exceptions), this allows to create factories from other factories directly. The parameter is true by default, meaning that the provided factory will be disposed.
- Extension method `Predicate` for `IMatchMapFactory`/`MatchMapFactory<TSource, TDestination>` now has an optional parameter which allows to dispose the provided factory together with the returned one (or in case of exceptions), this allows to create factories from other factories directly. The parameter is true by default, meaning that the provided factory will be disposed.
- Improved and cleanup extension method `Predicate` for `IMatcher`.
- Extension method `Predicate` for `IMatcher`/`IMatchMapFactory`/`MatchMapFactory<TSource, TDestination>` now return `IPredicateFactory`/`PredicateFactory<T>`.
- `CompositeMapper` now returns both new factories and merge factories for `MapNewFactory()` (like `CompositeMatcher` does for exact and reverse maps), the same applies to `AsyncCompositeMapper` too.
- Refactored internal reflection usage to create and cache delegates instead of direct invocations for increased performance.
- All delegates and interfaces (where applicable) now have the correct co/contra-variance specified on their parameters.
- One-liner extension methods should now be inlined.
- `AsyncCollectionMappersMappingOptions` `MaxParallelMappings` are now also supported for `IAsyncEnumerable` too.
- `AsyncMergeCollectionMapper` does not support anymore `AsyncCollectionMappersMappingOptions` `MaxParallelMappings`, constructor has been updated to remove the parameter.
- `MapNotFoundException` can no longer be thrown from mapper/maps on its own, a map cannot refuse itself based on provided objects.
- `CompositeMapper` and `AsyncCompositeMapper` will not try following mappers anymore on `MapNotFoundException`s.
- `CompositeMapperOptions` collection mapper has been moved to `PostConfigure()`.
- `AsyncCompositeMapperOptions` collection mapper has been moved to `PostConfigure()`.
- `CompositeProjectorOptions` collection projector has been moved to `PostConfigure()`.
- `AsyncCollectionMappersMappingOptions.MaxParallelMappings` are now also supported for `IAsyncEnumerable` too (parallelization is applied to the mapping, since the enumeration itself cannot be parallelized).
- `AsyncCollectionMapper` does not support anymore `AsyncCollectionMappersMappingOptions.MaxParallelMappings` for merge maps.
- `MapNotFoundException` can no longer be thrown to refuse mapping based on provided objects but only based on the types and `MappingOptions`, `CompositeMapper` and `AsyncCompositeMapper` will not try following mappers anymore on `MapNotFoundException`s but will wrap them in `MappingException`s.
- Collection mappers/projectors for `CompositeMapperOptions`/`AsyncCompositeMapperOptions`/`CompositeProjectorOptions` have been moved to `PostConfigure()`.

### Added

- New optional interfaces `IMapperMaps`, `IAsyncMapperMaps` and `IProjectorMaps` which allows discovering types which can be mapped by a given `IMapper`/`IAsyncMapper`/`IProjector`.
- Extension methods `GetNewMaps` and `GetMergeMaps` for any `IMapper`, `GetAsyncNewMaps` and `GetAsyncMergeMaps` for any `IAsyncMapper` and `GetMaps` for any `IProjector` which will fallback to default `Enumerable.Empty<T>` if the corresponding interface (`IMapperMaps`/`IAsyncMapperMaps`/`IProjectorMaps`) is not implemented.
- `IMapper`/`IAsyncMapper` `Map`/`MapAsync` and `MapMergeFactory`/`MapAsyncMergeFactory` extension methods added overloads with `IEqualityComparer` parameter used as matcher when merging collections.
- All the optional interfaces (`IAsyncMapperFactory`, ...) are now also provided as services via DI.
- All the factory interfaces (`IAsyncMapperFactory`, ...) are now also provided as services via DI.
- `EqualityComparerMatcher` which allows using an `IEqualityComparer` to match two elements of the same type.
- `MappingOptions` extension method `AddMergeCollectionMatchers` which allows to Set/Add `IMatcher`s to be used in merge maps.
- `AsyncEnumerableExtensions`.`Project`'s `MappingOptions` `params object[]` parameter overload.
- `AsyncEnumerableExtensions.Project` `MappingOptions` `params object[]` parameter overload.
- `IdentityMapper` and `AsyncIdentityMapper` which always return the passed source (for both new and merge maps, provided that the mapped types are the same). Not added to composite mappers by default.
- `IMatchMapFactory` overloads to extension method `Predicate`.
- `MapNewFactory` extension methods for `IMergeMapFactory`/`MergeMapFactory<TSource, TDestination>` and its async counterpart `MapAsyncNewFactory` for `IAsyncMergeMapFactory`/`AsyncMergeMapFactory<TSource, TDestination>`, which allows to create a new factory from a merge factory by creating destination objects.
Expand All @@ -48,7 +45,7 @@
- `EquatableMatcher` which allows matching types implementing `IEquatable<T>`.
- `ObjectEqualsMatcher` as last matcher (via `PostConfigure()` of `CompositeMatcherOptions`) which allows matching via `object.Equals()`.
- `EqualityOperatorsMatcher` (.NET 7+) which allows matching types implementing `IEqualityOperators<TSelf, TOther, TResult>` (equality operator `==`).
- `NewMapFactory<TSource, TDestination>` implicit conversion to `Converter<TInput,TOutput>` delegate.
- `NewMapFactory<TSource, TDestination>` implicit conversion to `Converter<TInput, TOutput>` delegate.
- `TypeConverterMapper` which allows mapping types via `TypeConverter`s.
- `ConvertibleMapper` which allows mapping types implementing `IConvertible`.

Expand All @@ -58,7 +55,7 @@
- Some concurrent locks in `CompositeMapper`/`AsyncCompositeMapper` factories.
- `AsyncCompositeMapper` missing `IAsyncMapperFactory` interface.
- `Project` `IQueryable<T>` extension method `params object[]` overload nullability.
- `MergeCollectionMapper` and `AsyncMergeCollectionMapper` now correctly return the destination collection if source collection is null.
- `CollectionMapper` and `AsyncCollectionMapper` now correctly return the destination collection if source collection is null for merge maps.


## [4.0.0] - 2024-07-16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static IServiceCollection AddNeatMapper(this IServiceCollection services,
s => new CompositeMatcher(s.GetService<IOptionsSnapshot<CompositeMatcherOptions>>()?.Value ?? new CompositeMatcherOptions()),
matchersLifetime));

// IMatcher, IMatcherCanMatch, IMatcherFactory
// IMatcher, IMatcherFactory
services.Add(new ServiceDescriptor(typeof(IMatcher), s => s.GetRequiredService<CompositeMatcher>(), matchersLifetime));
services.Add(new ServiceDescriptor(typeof(IMatcherFactory), s => s.GetRequiredService<CompositeMatcher>(), matchersLifetime));
#endregion
Expand Down Expand Up @@ -185,7 +185,7 @@ public static IServiceCollection AddNeatMapper(this IServiceCollection services,
s => new CompositeMapper(s.GetService<IOptionsSnapshot<CompositeMapperOptions>>()?.Value.Mappers ?? Array.Empty<IMapper>()),
mappersLifetime));

// IMapper, IMapperCanMap, IMapperFactory
// IMapper, IMapperFactory
services.Add(new ServiceDescriptor(typeof(IMapper), s => s.GetRequiredService<CompositeMapper>(), mappersLifetime));
services.Add(new ServiceDescriptor(typeof(IMapperFactory), s => s.GetRequiredService<CompositeMapper>(), mappersLifetime));
#endregion
Expand Down Expand Up @@ -234,7 +234,7 @@ public static IServiceCollection AddNeatMapper(this IServiceCollection services,
s => new AsyncCompositeMapper(s.GetService<IOptionsSnapshot<AsyncCompositeMapperOptions>>()?.Value.Mappers ?? Array.Empty<IAsyncMapper>()),
asyncMappersLifetime));

// IAsyncMapper, IAsyncMapperCanMap, IAsyncMapperFactory
// IAsyncMapper, IAsyncMapperFactory
services.Add(new ServiceDescriptor(typeof(IAsyncMapper), s => s.GetRequiredService<AsyncCompositeMapper>(), asyncMappersLifetime));
services.Add(new ServiceDescriptor(typeof(IAsyncMapperFactory), s => s.GetRequiredService<AsyncCompositeMapper>(), asyncMappersLifetime));
#endregion
Expand Down Expand Up @@ -274,8 +274,8 @@ public static IServiceCollection AddNeatMapper(this IServiceCollection services,
s => new CompositeProjector(s.GetService<IOptionsSnapshot<CompositeProjectorOptions>>()?.Value.Projectors ?? Array.Empty<IProjector>()),
projectorsLifetime));

// IProjector, IProjectorCanProject
services.Add(new ServiceDescriptor(typeof(IProjector), s => s.GetRequiredService<CompositeProjector>(), projectorsLifetime));
// IProjector
services.Add(new ServiceDescriptor(typeof(IProjector), s => s.GetRequiredService<CompositeProjector>(), projectorsLifetime));
#endregion

return services;
Expand Down

0 comments on commit 9131e2c

Please sign in to comment.