Skip to content

Commit

Permalink
Merge pull request #96 from gpproton/packages-dependencies-trimming
Browse files Browse the repository at this point in the history
Packages dependencies trimming
  • Loading branch information
gpproton authored Jan 22, 2024
2 parents 00534f5 + 85693ab commit d276278
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 127 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Title>Axolotl</Title>
<Version>8.0.2</Version>
<Version>8.0.5</Version>
<Authors>radioActive DROID</Authors>
<Description>Personal shared utility library</Description>
<RepositoryType>git</RepositoryType>
Expand Down
7 changes: 1 addition & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@

<!-- Shared packages -->
<ItemGroup>
<PackageVersion Include="Ardalis.SmartEnum" Version="$(ArdalisVersion)" />
<PackageVersion Include="Ardalis.SmartEnum.SystemTextJson" Version="$(ArdalisVersion)" />
<PackageVersion Include="Ardalis.Specification" Version="$(ArdalisVersion)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(DotnetVersion)" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="$(DotnetVersion)" />
<PackageVersion Include="System.Net.Http.Json" Version="$(DotnetVersion)" />
<PackageVersion Include="Nextended.Core" Version="$(NextendedVersion)" />
<PackageVersion Include="Mapster" Version="7.4.0" />
</ItemGroup>

<!-- EFCore packages -->
<ItemGroup>
<PackageVersion Include="Ardalis.SmartEnum.EFCore" Version="$(ArdalisVersion)" />
<PackageVersion Include="Ardalis.Specification.EntityFrameworkCore" Version="$(ArdalisVersion)" />
<PackageVersion Include="EFCore.BulkExtensions" Version="$(BulkExtensions)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(EfcoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Abstractions" Version="$(EfcoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="$(EfcoreVersion)" />
Expand Down
3 changes: 1 addition & 2 deletions src/aspnet/Axolotl.AspNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<ProjectReference Include="..\efcore\Axolotl.EFCore.csproj" />
<ProjectReference Include="..\standard\Axolotl.csproj" />
<PackageReference Include="Ardalis.Specification" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Mapster" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/aspnet/Feature/GenericFeature.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected static IEndpointRouteBuilder SetupGroup<TAFeature, TEntity, TResponse>
var name = options.Name ?? type.Name.ToLower();
var url = options.Path ?? $"{root}/{name}";
var instance = new TFeature() as TAFeature;
var group = endpoints.MapGroup(url).WithTags(name.Capitalize());
var group = endpoints.MapGroup(url).WithTags(name);
if (instance! == null) throw new Exception("Feature instance not initialized.");
instance.Endpoints = group;

Expand Down
11 changes: 0 additions & 11 deletions src/aspnet/Globals.cs

This file was deleted.

25 changes: 13 additions & 12 deletions src/aspnet/Service/GenericService.Extended.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Axolotl.Filters;
using Axolotl.Interfaces;
using Axolotl.Response;
using Mapster;

namespace Axolotl.AspNet.Service;

Expand All @@ -35,7 +36,7 @@ public async Task<PagedResponse<TResponse>> PageFilter(ISpecification<TEntity> s
var count = await repo.Query(cancellationToken).WithSpecification(specification).CountAsync(cancellationToken);
var take = (page - 1) * size;
var result = await repo.Query(cancellationToken).WithSpecification(specification).Take(size).Skip(take).ToListAsync(cancellationToken);
var output = result.MapTo<List<TResponse>>();
var output = result.Adapt<List<TResponse>>();

return new PagedResponse<TResponse>(output, page, size, count);
}
Expand All @@ -52,7 +53,7 @@ public async Task<PagedResponse<TResponse>> GetAllAsync(IPageFilter? filter, Typ

public async Task<Response<TResponse?>> GetByIdAsync(TKey id, CancellationToken cancellationToken = default) {
var result = await repo.GetByIdAsync(id, cancellationToken);
var output = result.MapTo<TResponse?>();
var output = result.Adapt<TResponse?>();

return new Response<TResponse?>(output);
}
Expand All @@ -64,38 +65,38 @@ public async Task<PagedResponse<TResponse>> GetBySpec<TOption>(Type spec, TOptio
}

public async Task<Response<TResponse>> CreateAsync(IResponse value, CancellationToken cancellationToken = default) {
var result = await repo.AddAsync(value.MapTo<TEntity>(), cancellationToken);
var output = result.MapTo<TResponse>();
var result = await repo.AddAsync(value.Adapt<TEntity>(), cancellationToken);
var output = result.Adapt<TResponse>();

return new Response<TResponse>(output);
}

public async Task<PagedResponse<TResponse>> CreateRangeAsync(IEnumerable<IResponse> values, CancellationToken cancellationToken = default) {
var converted = values.MapTo<IEnumerable<TEntity>>().ToList();
var converted = values.Adapt<IEnumerable<TEntity>>().ToList();
var result = await repo.AddRangeAsync(converted, cancellationToken);
var output = result.MapTo<IEnumerable<TResponse>>();
var output = result.Adapt<IEnumerable<TResponse>>();

return new PagedResponse<TResponse>(output);
}

public async Task<Response<TResponse>> UpdateAsync(IResponse value, CancellationToken cancellationToken = default) {
var result = await repo.UpdateAsync(value.MapTo<TEntity>(), cancellationToken);
var output = result.MapTo<TResponse>();
var result = await repo.UpdateAsync(value.Adapt<TEntity>(), cancellationToken);
var output = result.Adapt<TResponse>();

return new Response<TResponse>(output);
}

public async Task<PagedResponse<TResponse>> UpdateRangeAsync(IEnumerable<IResponse> values, CancellationToken cancellationToken = default) {
var converted = values.MapTo<IEnumerable<TEntity>>().ToList();
var converted = values.Adapt<IEnumerable<TEntity>>().ToList();
var result = await repo.UpdateRangeAsync(converted, cancellationToken);
var output = result.MapTo<IEnumerable<TResponse>>();
var output = result.Adapt<IEnumerable<TResponse>>();

return new PagedResponse<TResponse>(output);
}

public async Task<Response<TResponse?>> DeleteAsync(TKey id, CancellationToken cancellationToken = default) {
var result = await repo.DeleteAsync(id, cancellationToken);
var output = result.MapTo<TResponse?>();
var output = result.Adapt<TResponse?>();

return new Response<TResponse?>(output, "", result != null);
}
Expand All @@ -109,7 +110,7 @@ public async Task<Response<int>> DeleteRangeAsync(IEnumerable<TKey> ids, Cancell
public async Task<PagedResponse<TResponse>> DeleteBySpec<TOption>(Type spec, TOption option, CancellationToken cancellationToken = default) where TOption : class {
var specification = GenerateSpec.Build<TEntity>(spec, option);
var result = await repo.DeleteBySpec(specification, cancellationToken);
var output = result.MapTo<IEnumerable<TResponse>>();
var output = result.Adapt<IEnumerable<TResponse>>();

return new PagedResponse<TResponse>(output);
}
Expand Down
2 changes: 1 addition & 1 deletion src/efcore/Axolotl.EFCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<ItemGroup>
<ProjectReference Include="..\standard\Axolotl.csproj" />
<PackageReference Include="Ardalis.Specification" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" />
</ItemGroup>

Expand Down
31 changes: 0 additions & 31 deletions src/efcore/Context/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// limitations under the License.

using System.Reflection;
using Axolotl.EFCore.Converters;
using Microsoft.EntityFrameworkCore;
using Axolotl.EFCore.Interfaces;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
Expand All @@ -33,36 +32,6 @@ public static void RegisterSoftDeleteFilter(this ModelBuilder modelBuilder) {
entityType.AddSoftDeleteQueryFilter();
}

public static void RegisterEnumConverters<TEnum>(this ModelBuilder modelBuilder, Type type)
where TEnum : Enum
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) {
var properties = entityType.ClrType.GetProperties()
.Where(p => p.PropertyType == type);
foreach (var property in properties)
modelBuilder
.Entity(entityType.Name)
.Property(property.Name)
.HasConversion(new EnumCollectionJsonValueConverter<TEnum>())
.Metadata.SetValueComparer(new CollectionValueComparer<TEnum>());
}
}

public static void RegisterObjectConverters<TObject>(this ModelBuilder modelBuilder, Type type)
where TObject : Enum
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) {
var properties = entityType.ClrType.GetProperties()
.Where(p => p.PropertyType == type);
foreach (var property in properties)
modelBuilder
.Entity(entityType.Name)
.Property(property.Name)
.HasConversion(new JsonValueConverter<TObject>())
.Metadata.SetValueComparer(new CollectionValueComparer<TObject>());
}
}

public static void DateTimeOffsetToBinary(this ModelBuilder modelBuilder) {
foreach (var entityType in modelBuilder.Model.GetEntityTypes()) {
var properties = entityType.ClrType.GetProperties()
Expand Down
19 changes: 0 additions & 19 deletions src/efcore/Converters/CollectionValueComparer.cs

This file was deleted.

23 changes: 0 additions & 23 deletions src/efcore/Converters/EnumCollectionJsonValueConverter.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/efcore/Converters/JsonValueConverter.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/standard/Axolotl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Nextended.Core" />
<PackageReference Include="System.Net.Http.Json" />
</ItemGroup>

Expand Down

0 comments on commit d276278

Please sign in to comment.