Skip to content

Commit

Permalink
v5.14.1 (#251)
Browse files Browse the repository at this point in the history
* v5.14.1
- *Fixed:* Fixed the manager code-generation to reference parameter `value` as `v`, and output `ThenAsAsync`, correctly.
- *Fixed:* Added `ManagerCtorCustom`, `DataSvcCtorCustom` and `DataCtorCustom` to allow the constructor to be implemented as custom, non-generated, by the consuming developer.

* Re-gen sample to pass test.

* Additional fixes identified during testing.

* AdjustsAsync for identifier.
  • Loading branch information
chullybun authored Aug 1, 2024
1 parent df0b999 commit e0f97ec
Show file tree
Hide file tree
Showing 54 changed files with 351 additions and 96 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Represents the **NuGet** versions.

## v5.14.1
- *Fixed:* Fixed the manager code-generation to reference parameter `value` as `v`, and output `ThenAsAsync`, correctly.
- *Fixed:* Fixed the manager code-generation to use the new `Result<T>.Adjusts` to avoid unintended compiler identified casting when using `Then`.
- *Fixed:* Fixed the manager, data service and data code-generation to not output a constructor where there are no constructor parameters; i.e. is not required.
- *Fixed:* Added `ManagerCtorCustom`, `DataSvcCtorCustom` and `DataCtorCustom` to allow the constructor to be implemented as custom, non-generated, by the consuming developer.

## v5.14.0
- *Enhancement:* `Operation.DataSvcCustom` changed from boolean to an option that indicates the level of `DataSvc` customization (invokes `*OnImplementationAsync` method) vs code-generation (automatically invokes data-layer).
- Valid values are:
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>5.14.0</Version>
<Version>5.14.1</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
5 changes: 5 additions & 0 deletions docs/Entity-Entity-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ Provides the _Manager-layer_ configuration.

Property | Description
-|-
**`managerCustom`** | Indicates whether the `Manager` logic is a custom implementation; i.e. no auto-`DataSvc` invocation logic is to be generated.
`managerCtor` | The access modifier for the generated `Manager` constructor. Valid options are: `Public`, `Private`, `Protected`.<br/>&dagger; Defaults to `Public`.
`managerCtorCustom` | Indicates whether the `Manager` constructor will be implemented as custom; i.e. not generated.
**`managerCtorParams`** | The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated `Manager` constructor.<br/>&dagger; Each constructor parameter should be formatted as `Type` + `^` + `Name`; e.g. `IConfiguration^Config`. Where the `Name` portion is not specified it will be inferred. Where the `Type` matches an already inferred value it will be ignored.
`managerExtensions` | Indicates whether the `Manager` extensions logic should be generated.<br/>&dagger; This can be overridden using `Operation.ManagerExtensions`.
**`validator`** | The name of the .NET implementing `Type` or interface `Type` that will perform the validation.<br/>&dagger; Only used for defaulting the `Create` and `Update` operation types (`Operation.Type`) where not specified explicitly.
Expand All @@ -190,6 +192,8 @@ Property | Description
-|-
`dataSvcCaching` | Indicates whether request-based `IRequestCache` caching is to be performed at the `DataSvc` layer to improve performance (i.e. reduce chattiness).<br/>&dagger; Defaults to `true`.
`dataSvcCtor` | The access modifier for the generated `DataSvc` constructor. Valid options are: `Public`, `Private`, `Protected`.<br/>&dagger; Defaults to `Public`.
**`dataSvcCustom`** | The option that indicates the level of `DataSvc` customization (invokes `*OnImplementationAsync` method) vs code-generation (automatically invokes data-layer). Valid options are: `Full`, `Partial`, `None`.<br/>&dagger; `Full` indicates the logic is fully customized (only invocation is code-generated). `Partial` indicates combination of surrounding code-generation with final custom invocation versus data-layer. `None` indicates data-layer invocation with _no_ custom invocation (default).
`dataSvcCtorCustom` | Indicates whether the `DataSvc` constructor will be implemented as custom; i.e. not generated.
`dataSvcCtorParams` | The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated `DataSvc` constructor.<br/>&dagger; Each constructor parameter should be formatted as `Type` + `^` + `Name`; e.g. `IConfiguration^Config`. Where the `Name` portion is not specified it will be inferred. Where the `Type` matches an already inferred value it will be ignored.
`dataSvcExtensions` | Indicates whether the `DataSvc` extensions logic should be generated.<br/>&dagger; This can be overridden using `Operation.DataSvcExtensions`.

Expand All @@ -202,6 +206,7 @@ Property | Description
-|-
**`autoImplement`** | The data source auto-implementation option. Valid options are: `Database`, `EntityFramework`, `Cosmos`, `OData`, `HttpAgent`, `None`.<br/>&dagger; Defaults to `CodeGeneration.AutoImplement` (where `RefDataType` or `EntityFrameworkModel` or `CosmosModel` or `HttpAgent` is not null; otherwise, `None`. Indicates that the implementation for the underlying `Operations` will be auto-implemented using the selected data source (unless explicitly overridden). When selected some of the related attributes will also be required (as documented). Additionally, the `AutoImplement` can be further specified/overridden per `Operation`.
`dataCtor` | The access modifier for the generated `Data` constructor. Valid options are: `Public`, `Private`, `Protected`.<br/>&dagger; Defaults to `Public`.
`dataCtorCustom` | Indicates whether the `Data` constructor will be implemented as custom; i.e. not generated.
`dataCtorParams` | The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated `Data` constructor.<br/>&dagger; Each constructor parameter should be formatted as `Type` + `^` + `Name`; e.g. `IConfiguration^Config`. Where the `Name` portion is not specified it will be inferred. Where the `Type` matches an already inferred value it will be ignored.
`dataExtensions` | Indicates whether the `Data` extensions logic should be generated.<br/>&dagger; This can be overridden using `Operation.DataExtensions`.

Expand Down
4 changes: 2 additions & 2 deletions samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Cdr.Banking.Business\Cdr.Banking.Business.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Folder Include="DataSvc\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.2" />
<PackageReference Include="CoreEx.Validation" Version="3.23.2" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.4" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.4" />
<PackageReference Include="CoreEx.Validation" Version="3.23.4" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<Folder Include="Entities\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.2" />
<PackageReference Include="CoreEx" Version="3.23.4" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.23.2" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.23.4" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.6.2" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.2" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.2" />
<PackageReference Include="CoreEx.Database" Version="3.23.2" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.23.2" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.23.2" />
<PackageReference Include="CoreEx.Validation" Version="3.23.2" />
<PackageReference Include="CoreEx.FluentValidation" Version="3.23.2" />
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.4" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.4" />
<PackageReference Include="CoreEx.Database" Version="3.23.4" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.23.4" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.23.4" />
<PackageReference Include="CoreEx.Validation" Version="3.23.4" />
<PackageReference Include="CoreEx.FluentValidation" Version="3.23.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.20" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business.Data;

/// <summary>
/// Defines the <see cref="SpecialSauce"/> data access.
/// </summary>
public partial interface ISpecialSauceData
{
/// <summary>
/// Pour.
/// </summary>
Task PourAsync();
}

#pragma warning restore
#nullable restore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static IServiceCollection AddGeneratedDataServices(this IServiceCollectio
return services.AddScoped<IPersonData, PersonData>()
.AddScoped<IRobotData, RobotData>()
.AddScoped<IPostalInfoData, PostalInfoData>()
.AddScoped<ISpecialSauceData, SpecialSauceData>()
.AddScoped<IContactData, ContactData>();
}
}
Expand Down
20 changes: 20 additions & 0 deletions samples/Demo/Beef.Demo.Business/Data/Generated/SpecialSauceData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business.Data;

/// <summary>
/// Provides the <see cref="SpecialSauce"/> data access.
/// </summary>
public partial class SpecialSauceData : ISpecialSauceData
{
/// <inheritdoc/>
public Task PourAsync() => PourOnImplementationAsync();
}

#pragma warning restore
#nullable restore
7 changes: 7 additions & 0 deletions samples/Demo/Beef.Demo.Business/Data/SpecialSauceData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Beef.Demo.Business.Data
{
public partial class SpecialSauceData
{
public static Task PourOnImplementationAsync() => Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business.DataSvc;

/// <summary>
/// Defines the <see cref="SpecialSauce"/> data repository services.
/// </summary>
public partial interface ISpecialSauceDataSvc
{
/// <summary>
/// Pour.
/// </summary>
Task PourAsync();
}

#pragma warning restore
#nullable restore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static IServiceCollection AddGeneratedDataSvcServices(this IServiceCollec
return services.AddScoped<IPersonDataSvc, PersonDataSvc>()
.AddScoped<IRobotDataSvc, RobotDataSvc>()
.AddScoped<IPostalInfoDataSvc, PostalInfoDataSvc>()
.AddScoped<ISpecialSauceDataSvc, SpecialSauceDataSvc>()
.AddScoped<IContactDataSvc, ContactDataSvc>();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business.DataSvc;

/// <summary>
/// Provides the <see cref="SpecialSauce"/> data repository services.
/// </summary>
public partial class SpecialSauceDataSvc : ISpecialSauceDataSvc
{
/// <inheritdoc/>
public Task PourAsync() => PourOnImplementationAsync();
}

#pragma warning restore
#nullable restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Beef.Demo.Business.DataSvc
{
public partial class SpecialSauceDataSvc(ISpecialSauceData data)
{
private readonly ISpecialSauceData _data = data.ThrowIfNull();

public Task PourOnImplementationAsync() => _data.PourAsync();
}
}
8 changes: 0 additions & 8 deletions samples/Demo/Beef.Demo.Business/Generated/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ namespace Beef.Demo.Business;
/// </summary>
public partial class ConfigManager : IConfigManager
{
/// <summary>
/// Initializes a new instance of the <see cref="ConfigManager"/> class.
/// </summary>
public ConfigManager()
{ ConfigManagerCtor(); }

partial void ConfigManagerCtor(); // Enables additional functionality to be added to the constructor.

/// <inheritdoc/>
public Task<System.Collections.IDictionary> GetEnvVarsAsync() => ManagerInvoker.Current.InvokeAsync(this, async (_, ct) =>
{
Expand Down
6 changes: 3 additions & 3 deletions samples/Demo/Beef.Demo.Business/Generated/GenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public GenderManager(IGenderDataSvc dataService)
public Task<Result<Gender>> CreateAsync(Gender value) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) =>
{
return Result.Go(value).Required()
.ThenAsAsync(v => _dataService.CreateAsync(value));
.ThenAsAsync(v => _dataService.CreateAsync(v));
}, InvokerArgs.Create);

/// <inheritdoc/>
public Task<Result<Gender>> UpdateAsync(Gender value, Guid id) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) =>
{
return Result.Go(value).Required().Requires(id).Then(v => v.Id = id)
.ThenAsAsync(v => _dataService.UpdateAsync(value));
return Result.Go(value).Required().Requires(id).Adjusts(v => v.Id = id)
.ThenAsAsync(v => _dataService.UpdateAsync(v));
}, InvokerArgs.Update);
}

Expand Down
22 changes: 22 additions & 0 deletions samples/Demo/Beef.Demo.Business/Generated/ISpecialSauceManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business;

/// <summary>
/// Defines the <see cref="SpecialSauce"/> business functionality.
/// </summary>
public partial interface ISpecialSauceManager
{
/// <summary>
/// Pour.
/// </summary>
Task PourAsync();
}

#pragma warning restore
#nullable restore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Task<Result<PostalInfo>> CreatePostCodesAsync(PostalInfo value, RefDataNa
return Result.Go(value).Required().Requires(country).Requires(state).Requires(city)
.Then(v => Cleaner.CleanUp(v, country, state, city))
.ValidatesAsync(country, vc => vc.IsValid(), cancellationToken: ct)
.ThenAsAsync(v => _dataService.CreatePostCodesAsync(value, country, state, city));
.ThenAsAsync(v => _dataService.CreatePostCodesAsync(v, country, state, city));
}, InvokerArgs.Create);

/// <inheritdoc/>
Expand All @@ -47,7 +47,7 @@ public Task<Result<PostalInfo>> UpdatePostCodesAsync(PostalInfo value, RefDataNa
return Result.Go(value).Required().Requires(country).Requires(state).Requires(city)
.Then(v => Cleaner.CleanUp(v, country, state, city))
.ValidatesAsync(country, vc => vc.IsValid(), cancellationToken: ct)
.ThenAsAsync(v => _dataService.UpdatePostCodesAsync(value, country, state, city));
.ThenAsAsync(v => _dataService.UpdatePostCodesAsync(v, country, state, city));
}, InvokerArgs.Update);

/// <inheritdoc/>
Expand Down
8 changes: 4 additions & 4 deletions samples/Demo/Beef.Demo.Business/Generated/RobotManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public RobotManager(IRobotDataSvc dataService, IEventPublisher eventPublisher, I
public Task<Result<Robot>> CreateAsync(Robot value) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) =>
{
return Result.Go(value).Required()
.ThenAsync(async v => v.Id = await _identifierGenerator.GenerateIdentifierAsync<Guid, Robot>().ConfigureAwait(false))
.AdjustsAsync(async v => v.Id = await _identifierGenerator.GenerateIdentifierAsync<Guid, Robot>().ConfigureAwait(false))
.Then(v => Cleaner.CleanUp(v))
.ValidateAsync(vc => vc.Interop(() => FluentValidator.Create<RobotValidator>().Wrap()), cancellationToken: ct)
.ThenAsAsync(v => _dataService.CreateAsync(value));
.ThenAsAsync(v => _dataService.CreateAsync(v));
}, InvokerArgs.Create);

/// <inheritdoc/>
public Task<Result<Robot>> UpdateAsync(Robot value, Guid id) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) =>
{
return Result.Go(value).Required().Requires(id).Then(v => v.Id = id)
return Result.Go(value).Required().Requires(id).Adjusts(v => v.Id = id)
.Then(v => Cleaner.CleanUp(v))
.ValidateAsync(vc => vc.Interop(() => FluentValidator.Create<RobotValidator>().Wrap()), cancellationToken: ct)
.ThenAsAsync(v => _dataService.UpdateAsync(value));
.ThenAsAsync(v => _dataService.UpdateAsync(v));
}, InvokerArgs.Update);

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static IServiceCollection AddGeneratedManagerServices(this IServiceCollec
.AddScoped<IRobotManager, RobotManager>()
.AddScoped<IConfigManager, ConfigManager>()
.AddScoped<IPostalInfoManager, PostalInfoManager>()
.AddScoped<ISpecialSauceManager, SpecialSauceManager>()
.AddScoped<IContactManager, ContactManager>();
}
}
Expand Down
34 changes: 34 additions & 0 deletions samples/Demo/Beef.Demo.Business/Generated/SpecialSauceManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This file is automatically generated; any changes will be lost.
*/

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business;

/// <summary>
/// Provides the <see cref="SpecialSauce"/> business functionality.
/// </summary>
public partial class SpecialSauceManager : ISpecialSauceManager
{
private readonly ISpecialSauceDataSvc _dataService;

/// <summary>
/// Initializes a new instance of the <see cref="SpecialSauceManager"/> class.
/// </summary>
/// <param name="dataService">The <see cref="ISpecialSauceDataSvc"/>.</param>
public SpecialSauceManager(ISpecialSauceDataSvc dataService)
{ _dataService = dataService.ThrowIfNull(); SpecialSauceManagerCtor(); }

partial void SpecialSauceManagerCtor(); // Enables additional functionality to be added to the constructor.

/// <inheritdoc/>
public Task PourAsync() => ManagerInvoker.Current.InvokeAsync(this, async (_, ct) =>
{
await _dataService.PourAsync().ConfigureAwait(false);
}, InvokerArgs.Unspecified);
}

#pragma warning restore
#nullable restore
Loading

0 comments on commit e0f97ec

Please sign in to comment.