diff --git a/CHANGELOG.md b/CHANGELOG.md index 407cf6b9..f20b3fbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.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: diff --git a/Common.targets b/Common.targets index 01002210..fdd578ee 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@ - 5.14.0 + 5.14.1 preview Avanade Avanade diff --git a/docs/Entity-Entity-Config.md b/docs/Entity-Entity-Config.md index 2ce163c8..ebf54929 100644 --- a/docs/Entity-Entity-Config.md +++ b/docs/Entity-Entity-Config.md @@ -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`.
† 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.
† 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.
† This can be overridden using `Operation.ManagerExtensions`. **`validator`** | The name of the .NET implementing `Type` or interface `Type` that will perform the validation.
† Only used for defaulting the `Create` and `Update` operation types (`Operation.Type`) where not specified explicitly. @@ -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).
† Defaults to `true`. `dataSvcCtor` | The access modifier for the generated `DataSvc` constructor. Valid options are: `Public`, `Private`, `Protected`.
† 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`.
† `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.
† 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.
† This can be overridden using `Operation.DataSvcExtensions`. @@ -202,6 +206,7 @@ Property | Description -|- **`autoImplement`** | The data source auto-implementation option. Valid options are: `Database`, `EntityFramework`, `Cosmos`, `OData`, `HttpAgent`, `None`.
† 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`.
† 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.
† 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.
† This can be overridden using `Operation.DataExtensions`. diff --git a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj index 1d37b3e3..c8bd8416 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj @@ -5,8 +5,8 @@ true
- - + + diff --git a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj index d9dd7ecb..5de65064 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Business/Cdr.Banking.Business.csproj @@ -12,8 +12,8 @@ - - - + + +
\ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj index 70a8409f..28bdc708 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Common/Cdr.Banking.Common.csproj @@ -8,6 +8,6 @@ - + \ No newline at end of file diff --git a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj index 0cd3da44..956736c6 100644 --- a/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj +++ b/samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj @@ -39,7 +39,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj index cbeebb25..c0b60e54 100644 --- a/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj +++ b/samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj index 05610d2b..fc710ef7 100644 --- a/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj +++ b/samples/Demo/Beef.Demo.Business/Beef.Demo.Business.csproj @@ -16,14 +16,14 @@ - - - - - - - - + + + + + + + + diff --git a/samples/Demo/Beef.Demo.Business/Data/Generated/ISpecialSauceData.cs b/samples/Demo/Beef.Demo.Business/Data/Generated/ISpecialSauceData.cs new file mode 100644 index 00000000..fddf41d4 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/Data/Generated/ISpecialSauceData.cs @@ -0,0 +1,22 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business.Data; + +/// +/// Defines the data access. +/// +public partial interface ISpecialSauceData +{ + /// + /// Pour. + /// + Task PourAsync(); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/Data/Generated/ServiceCollectionExtensions.cs b/samples/Demo/Beef.Demo.Business/Data/Generated/ServiceCollectionExtensions.cs index f38c8f58..029cac27 100644 --- a/samples/Demo/Beef.Demo.Business/Data/Generated/ServiceCollectionExtensions.cs +++ b/samples/Demo/Beef.Demo.Business/Data/Generated/ServiceCollectionExtensions.cs @@ -22,6 +22,7 @@ public static IServiceCollection AddGeneratedDataServices(this IServiceCollectio return services.AddScoped() .AddScoped() .AddScoped() + .AddScoped() .AddScoped(); } } diff --git a/samples/Demo/Beef.Demo.Business/Data/Generated/SpecialSauceData.cs b/samples/Demo/Beef.Demo.Business/Data/Generated/SpecialSauceData.cs new file mode 100644 index 00000000..969925b7 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/Data/Generated/SpecialSauceData.cs @@ -0,0 +1,20 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business.Data; + +/// +/// Provides the data access. +/// +public partial class SpecialSauceData : ISpecialSauceData +{ + /// + public Task PourAsync() => PourOnImplementationAsync(); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/Data/SpecialSauceData.cs b/samples/Demo/Beef.Demo.Business/Data/SpecialSauceData.cs new file mode 100644 index 00000000..7ddb0c30 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/Data/SpecialSauceData.cs @@ -0,0 +1,7 @@ +namespace Beef.Demo.Business.Data +{ + public partial class SpecialSauceData + { + public static Task PourOnImplementationAsync() => Task.CompletedTask; + } +} diff --git a/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ISpecialSauceDataSvc.cs b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ISpecialSauceDataSvc.cs new file mode 100644 index 00000000..342d41d2 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ISpecialSauceDataSvc.cs @@ -0,0 +1,22 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business.DataSvc; + +/// +/// Defines the data repository services. +/// +public partial interface ISpecialSauceDataSvc +{ + /// + /// Pour. + /// + Task PourAsync(); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ServiceCollectionExtensions.cs b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ServiceCollectionExtensions.cs index 86f767cc..0f1d5f13 100644 --- a/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ServiceCollectionExtensions.cs +++ b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/ServiceCollectionExtensions.cs @@ -22,6 +22,7 @@ public static IServiceCollection AddGeneratedDataSvcServices(this IServiceCollec return services.AddScoped() .AddScoped() .AddScoped() + .AddScoped() .AddScoped(); } } diff --git a/samples/Demo/Beef.Demo.Business/DataSvc/Generated/SpecialSauceDataSvc.cs b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/SpecialSauceDataSvc.cs new file mode 100644 index 00000000..d5ba86a2 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/DataSvc/Generated/SpecialSauceDataSvc.cs @@ -0,0 +1,20 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business.DataSvc; + +/// +/// Provides the data repository services. +/// +public partial class SpecialSauceDataSvc : ISpecialSauceDataSvc +{ + /// + public Task PourAsync() => PourOnImplementationAsync(); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/DataSvc/SpecialSauceDataSvc.cs b/samples/Demo/Beef.Demo.Business/DataSvc/SpecialSauceDataSvc.cs new file mode 100644 index 00000000..dbd14a1d --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/DataSvc/SpecialSauceDataSvc.cs @@ -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(); + } +} \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/Generated/ConfigManager.cs b/samples/Demo/Beef.Demo.Business/Generated/ConfigManager.cs index 6634f4d6..8f7a5f16 100644 --- a/samples/Demo/Beef.Demo.Business/Generated/ConfigManager.cs +++ b/samples/Demo/Beef.Demo.Business/Generated/ConfigManager.cs @@ -12,14 +12,6 @@ namespace Beef.Demo.Business; /// public partial class ConfigManager : IConfigManager { - /// - /// Initializes a new instance of the class. - /// - public ConfigManager() - { ConfigManagerCtor(); } - - partial void ConfigManagerCtor(); // Enables additional functionality to be added to the constructor. - /// public Task GetEnvVarsAsync() => ManagerInvoker.Current.InvokeAsync(this, async (_, ct) => { diff --git a/samples/Demo/Beef.Demo.Business/Generated/GenderManager.cs b/samples/Demo/Beef.Demo.Business/Generated/GenderManager.cs index c55a9c7c..a8a88bae 100644 --- a/samples/Demo/Beef.Demo.Business/Generated/GenderManager.cs +++ b/samples/Demo/Beef.Demo.Business/Generated/GenderManager.cs @@ -34,14 +34,14 @@ public GenderManager(IGenderDataSvc dataService) public Task> 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); /// public Task> 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); } diff --git a/samples/Demo/Beef.Demo.Business/Generated/ISpecialSauceManager.cs b/samples/Demo/Beef.Demo.Business/Generated/ISpecialSauceManager.cs new file mode 100644 index 00000000..d95ee698 --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/Generated/ISpecialSauceManager.cs @@ -0,0 +1,22 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business; + +/// +/// Defines the business functionality. +/// +public partial interface ISpecialSauceManager +{ + /// + /// Pour. + /// + Task PourAsync(); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.Business/Generated/PostalInfoManager.cs b/samples/Demo/Beef.Demo.Business/Generated/PostalInfoManager.cs index 6a96317d..099c7d6c 100644 --- a/samples/Demo/Beef.Demo.Business/Generated/PostalInfoManager.cs +++ b/samples/Demo/Beef.Demo.Business/Generated/PostalInfoManager.cs @@ -38,7 +38,7 @@ public Task> 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); /// @@ -47,7 +47,7 @@ public Task> 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); /// diff --git a/samples/Demo/Beef.Demo.Business/Generated/RobotManager.cs b/samples/Demo/Beef.Demo.Business/Generated/RobotManager.cs index aba5e5b0..63e61282 100644 --- a/samples/Demo/Beef.Demo.Business/Generated/RobotManager.cs +++ b/samples/Demo/Beef.Demo.Business/Generated/RobotManager.cs @@ -39,19 +39,19 @@ public RobotManager(IRobotDataSvc dataService, IEventPublisher eventPublisher, I public Task> CreateAsync(Robot value) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) => { return Result.Go(value).Required() - .ThenAsync(async v => v.Id = await _identifierGenerator.GenerateIdentifierAsync().ConfigureAwait(false)) + .AdjustsAsync(async v => v.Id = await _identifierGenerator.GenerateIdentifierAsync().ConfigureAwait(false)) .Then(v => Cleaner.CleanUp(v)) .ValidateAsync(vc => vc.Interop(() => FluentValidator.Create().Wrap()), cancellationToken: ct) - .ThenAsAsync(v => _dataService.CreateAsync(value)); + .ThenAsAsync(v => _dataService.CreateAsync(v)); }, InvokerArgs.Create); /// public Task> 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().Wrap()), cancellationToken: ct) - .ThenAsAsync(v => _dataService.UpdateAsync(value)); + .ThenAsAsync(v => _dataService.UpdateAsync(v)); }, InvokerArgs.Update); /// diff --git a/samples/Demo/Beef.Demo.Business/Generated/ServiceCollectionExtensions.cs b/samples/Demo/Beef.Demo.Business/Generated/ServiceCollectionExtensions.cs index a0333feb..66c9f064 100644 --- a/samples/Demo/Beef.Demo.Business/Generated/ServiceCollectionExtensions.cs +++ b/samples/Demo/Beef.Demo.Business/Generated/ServiceCollectionExtensions.cs @@ -23,6 +23,7 @@ public static IServiceCollection AddGeneratedManagerServices(this IServiceCollec .AddScoped() .AddScoped() .AddScoped() + .AddScoped() .AddScoped(); } } diff --git a/samples/Demo/Beef.Demo.Business/Generated/SpecialSauceManager.cs b/samples/Demo/Beef.Demo.Business/Generated/SpecialSauceManager.cs new file mode 100644 index 00000000..3511786a --- /dev/null +++ b/samples/Demo/Beef.Demo.Business/Generated/SpecialSauceManager.cs @@ -0,0 +1,34 @@ +/* + * This file is automatically generated; any changes will be lost. + */ + +#nullable enable +#pragma warning disable + +namespace Beef.Demo.Business; + +/// +/// Provides the business functionality. +/// +public partial class SpecialSauceManager : ISpecialSauceManager +{ + private readonly ISpecialSauceDataSvc _dataService; + + /// + /// Initializes a new instance of the class. + /// + /// The . + public SpecialSauceManager(ISpecialSauceDataSvc dataService) + { _dataService = dataService.ThrowIfNull(); SpecialSauceManagerCtor(); } + + partial void SpecialSauceManagerCtor(); // Enables additional functionality to be added to the constructor. + + /// + public Task PourAsync() => ManagerInvoker.Current.InvokeAsync(this, async (_, ct) => + { + await _dataService.PourAsync().ConfigureAwait(false); + }, InvokerArgs.Unspecified); +} + +#pragma warning restore +#nullable restore \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.CodeGen/contact.entity.beef-5.yaml b/samples/Demo/Beef.Demo.CodeGen/contact.entity.beef-5.yaml index d48e803a..4ecb3490 100644 --- a/samples/Demo/Beef.Demo.CodeGen/contact.entity.beef-5.yaml +++ b/samples/Demo/Beef.Demo.CodeGen/contact.entity.beef-5.yaml @@ -22,4 +22,5 @@ entities: properties: [ { name: Value }, { name: IsPreferred, type: bool, text: Communication is the preferred (only one) } - ]} + ] + } \ No newline at end of file diff --git a/samples/Demo/Beef.Demo.CodeGen/entity.beef-5.yaml b/samples/Demo/Beef.Demo.CodeGen/entity.beef-5.yaml index bb60ee54..423819c4 100644 --- a/samples/Demo/Beef.Demo.CodeGen/entity.beef-5.yaml +++ b/samples/Demo/Beef.Demo.CodeGen/entity.beef-5.yaml @@ -274,12 +274,15 @@ entities: ] } -- { name: SpecialSauce, collection: true, collectionType: Dictionary, internalOnly: true, +- { name: SpecialSauce, collection: true, collectionType: Dictionary, internalOnly: true, excludeWebApi: true, excludeWebApiAgent: true, properties: [ { name: Key1, primaryKey: true }, { name: Key2, primaryKey: true }, { name: Selected, type: bool, default: 'true' }, { name: Ingredient, default: '"special herbs and spices"' } + ], + operations: [ + { name: Pour, type: Custom, dataSvcCustom: Partial } ] } diff --git a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj index d443cd24..64c5ca3c 100644 --- a/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj +++ b/samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj index 2536fd8b..b878950c 100644 --- a/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj +++ b/samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj @@ -52,7 +52,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj index ea30f8a6..3de776e4 100644 --- a/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj +++ b/samples/My.Hr/My.Hr.Api/My.Hr.Api.csproj @@ -5,9 +5,9 @@ true - - - + + + diff --git a/samples/My.Hr/My.Hr.Business/Generated/EmployeeManager.cs b/samples/My.Hr/My.Hr.Business/Generated/EmployeeManager.cs index 5e29a63f..ead73552 100644 --- a/samples/My.Hr/My.Hr.Business/Generated/EmployeeManager.cs +++ b/samples/My.Hr/My.Hr.Business/Generated/EmployeeManager.cs @@ -32,15 +32,15 @@ public Task> CreateAsync(Employee value) => ManagerInvoker.Curr { return Result.Go(value).Required() .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.CreateAsync(value)); + .ThenAsAsync(v => _dataService.CreateAsync(v)); }, InvokerArgs.Create); /// public Task> UpdateAsync(Employee 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) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.UpdateAsync(value)); + .ThenAsAsync(v => _dataService.UpdateAsync(v)); }, InvokerArgs.Update); /// @@ -64,6 +64,6 @@ public Task> TerminateAsync(TerminationDetail value, Guid id) = { return Result.Go(value).Required() .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.TerminateAsync(value, id)); + .ThenAsAsync(v => _dataService.TerminateAsync(v, id)); }, InvokerArgs.Update); } \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Business/Generated/PerformanceReviewManager.cs b/samples/My.Hr/My.Hr.Business/Generated/PerformanceReviewManager.cs index 86ef76c1..d13d9aec 100644 --- a/samples/My.Hr/My.Hr.Business/Generated/PerformanceReviewManager.cs +++ b/samples/My.Hr/My.Hr.Business/Generated/PerformanceReviewManager.cs @@ -37,17 +37,17 @@ public Task> GetByEmployeeIdAsync(Guid /// public Task> CreateAsync(PerformanceReview value, Guid employeeId) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) => { - return Result.Go(value).Required().Then(v => v.EmployeeId = employeeId) + return Result.Go(value).Required().Adjusts(v => v.EmployeeId = employeeId) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.CreateAsync(value)); + .ThenAsAsync(v => _dataService.CreateAsync(v)); }, InvokerArgs.Create); /// public Task> UpdateAsync(PerformanceReview 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) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.UpdateAsync(value)); + .ThenAsAsync(v => _dataService.UpdateAsync(v)); }, InvokerArgs.Update); /// diff --git a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj index ee2e7506..a73c9aa2 100644 --- a/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj +++ b/samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj @@ -6,10 +6,10 @@ latest - - - - + + + + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj index c5ac9f4f..59027142 100644 --- a/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj +++ b/samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj @@ -4,6 +4,6 @@ enable - + \ No newline at end of file diff --git a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj index c074bcac..a3dcdf70 100644 --- a/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj +++ b/samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,7 +42,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj index bbaa0f59..ecbd245c 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj @@ -6,12 +6,12 @@ True - - + + - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Generated/EmployeeManager.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Generated/EmployeeManager.cs index 252bcc77..bdf697ea 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Generated/EmployeeManager.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Generated/EmployeeManager.cs @@ -32,15 +32,15 @@ public Task> CreateAsync(Employee value) => ManagerInvoker.Curr { return Result.Go(value).Required() .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.CreateAsync(value)); + .ThenAsAsync(v => _dataService.CreateAsync(v)); }, InvokerArgs.Create); /// public Task> UpdateAsync(Employee 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) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.UpdateAsync(value)); + .ThenAsAsync(v => _dataService.UpdateAsync(v)); }, InvokerArgs.Update); /// @@ -64,6 +64,6 @@ public Task> TerminateAsync(TerminationDetail value, Guid id) = { return Result.Go(value).Required().Requires(id) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.TerminateAsync(value, id)); + .ThenAsAsync(v => _dataService.TerminateAsync(v, id)); }, InvokerArgs.Update); } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/Generated/PerformanceReviewManager.cs b/samples/MyEf.Hr/MyEf.Hr.Business/Generated/PerformanceReviewManager.cs index b2190fcc..794ccd5d 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/Generated/PerformanceReviewManager.cs +++ b/samples/MyEf.Hr/MyEf.Hr.Business/Generated/PerformanceReviewManager.cs @@ -30,9 +30,9 @@ public PerformanceReviewManager(IPerformanceReviewDataSvc dataService) /// public Task> UpdateAsync(PerformanceReview 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) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.UpdateAsync(value)); + .ThenAsAsync(v => _dataService.UpdateAsync(v)); }, InvokerArgs.Update); /// @@ -52,8 +52,8 @@ public Task> GetByEmployeeIdAsync(Guid /// public Task> CreateAsync(PerformanceReview value, Guid employeeId) => ManagerInvoker.Current.InvokeAsync(this, (_, ct) => { - return Result.Go(value).Required().Requires(employeeId).Then(v => v.EmployeeId = employeeId) + return Result.Go(value).Required().Requires(employeeId).Adjusts(v => v.EmployeeId = employeeId) .ValidateAsync(vc => vc.Entity().With(), cancellationToken: ct) - .ThenAsAsync(v => _dataService.CreateAsync(value)); + .ThenAsAsync(v => _dataService.CreateAsync(v)); }, InvokerArgs.Create); } \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj index 6ebba084..110670c8 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj @@ -6,10 +6,10 @@ latest - - - - + + + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj index 566a27bf..0f8a31c9 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj @@ -5,6 +5,6 @@ True - + \ No newline at end of file diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj index 3f0d0437..3ec635b4 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Subscriptions/MyEf.Hr.Security.Subscriptions.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj index 09fa7ff0..b43f84d2 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Security.Test/MyEf.Hr.Security.Test.csproj @@ -27,7 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj index a00f9694..9b4c473f 100644 --- a/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj +++ b/samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,7 +42,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/templates/Beef.Template.Solution/content/.template.config/template.json b/templates/Beef.Template.Solution/content/.template.config/template.json index 7cd1f5b9..359dd519 100644 --- a/templates/Beef.Template.Solution/content/.template.config/template.json +++ b/templates/Beef.Template.Solution/content/.template.config/template.json @@ -85,7 +85,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "3.23.2" + "value": "3.23.4" }, "replaces": "CoreExVersion" }, @@ -93,7 +93,7 @@ "type": "generated", "generator": "constant", "parameters": { - "value": "5.14.0" + "value": "5.14.1" }, "replaces": "BeefVersion" }, diff --git a/tools/Beef.CodeGen.Core/Config/Entity/EntityConfig.cs b/tools/Beef.CodeGen.Core/Config/Entity/EntityConfig.cs index 88b20dc9..d48f456c 100644 --- a/tools/Beef.CodeGen.Core/Config/Entity/EntityConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Entity/EntityConfig.cs @@ -352,6 +352,13 @@ public class EntityConfig : ConfigBase Description = "Defaults to `Public`.")] public string? DataCtor { get; set; } + /// + /// Indicates whether the `Data` constructor will be implemented as custom; i.e. not generated. + /// + [JsonPropertyName("dataCtorCustom")] + [CodeGenProperty("Data", Title = "Indicates whether the `Data` constructor will be implemented as custom; i.e. not generated.")] + public bool? DataCtorCustom { get; set; } + /// /// Gets or sets the list of extended (non-inferred) Dependency Injection (DI) parameters for the generated `Data` constructor. /// @@ -672,6 +679,21 @@ public class EntityConfig : ConfigBase Description = "Defaults to `Public`.")] public string? DataSvcCtor { get; set; } + /// + /// Gets or set the option that indicates the level of `DataSvc` customization. + /// + [JsonPropertyName("dataSvcCustom")] + [CodeGenProperty("DataSvc", Title = "The option that indicates the level of `DataSvc` customization (invokes `*OnImplementationAsync` method) vs code-generation (automatically invokes data-layer).", IsImportant = true, Options = ["Full", "Partial", "None"], + Description = "`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).")] + public string? DataSvcCustom { get; set; } + + /// + /// Indicates whether the `DataSvc` constructor will be implemented as custom; i.e. not generated. + /// + [JsonPropertyName("dataSvcCtorCustom")] + [CodeGenProperty("DataSvc", Title = "Indicates whether the `DataSvc` constructor will be implemented as custom; i.e. not generated.")] + public bool? DataSvcCtorCustom { get; set; } + /// /// Gets or sets the list of extended (non-inferred) Dependency Injection (DI) parameters for the generated `DataSvc` constructor. /// @@ -724,6 +746,13 @@ public class EntityConfig : ConfigBase #region Manager + /// + /// Indicates whether the `Manager`-layer is a custom implementation; i.e. no auto-`DataSvc` invocation logic is to be generated. + /// + [JsonPropertyName("managerCustom")] + [CodeGenProperty("Manager", Title = "Indicates whether the `Manager` logic is a custom implementation; i.e. no auto-`DataSvc` invocation logic is to be generated.", IsImportant = true)] + public bool? ManagerCustom { get; set; } + /// /// Gets or sets the access modifier for the generated `Manager` constructor. /// @@ -732,6 +761,13 @@ public class EntityConfig : ConfigBase Description = "Defaults to `Public`.")] public string? ManagerCtor { get; set; } + /// + /// Indicates whether the `Manager` constructor will be implemented as custom; i.e. not generated. + /// + [JsonPropertyName("managerCtorCustom")] + [CodeGenProperty("Manager", Title = "Indicates whether the `Manager` constructor will be implemented as custom; i.e. not generated.")] + public bool? ManagerCtorCustom { get; set; } + /// /// Gets or sets the list of extended (non-inferred) Dependency Injection (DI) parameters for the generated `Manager` constructor. /// @@ -1317,12 +1353,12 @@ public class EntityConfig : ConfigBase /// /// Indicates whether at least one operation needs a DataSvc. /// - public bool RequiresDataSvc => !(CompareValue(ExcludeDataSvc, true) && CompareValue(ExcludeIDataSvc, true)) || Operations!.Any(x => CompareNullOrValue(x.ManagerCustom, false)); + public bool RequiresDataSvc => !(CompareValue(ExcludeDataSvc, true) && CompareValue(ExcludeIDataSvc, true)) && Operations!.Any(x => CompareNullOrValue(x.ManagerCustom, false)); /// /// Indicates whether at least one operation needs a Data. /// - public bool RequiresData => (CompareValue(ExcludeData, "Exclude") && CompareValue(ExcludeIData, true)) || Operations!.Any(x => CompareNullOrValue(x.IsDataSvcCustomFull, false)); + public bool RequiresData => !(CompareValue(ExcludeData, "Exclude") && CompareValue(ExcludeIData, true)) && Operations!.Any(x => CompareValue(x.DataSvcCustom, "None") && CompareValue(x.ExcludeDataSvc, false)); /// /// Indicates whether any of the operations will raise an event within the DataSvc-layer. @@ -1440,6 +1476,8 @@ protected override async Task PrepareAsync() HttpAgentName = DefaultWhereNull(HttpAgentName, () => Parent!.HttpAgentName); DataSvcCaching = DefaultWhereNull(DataSvcCaching, () => true); DataSvcCtor = DefaultWhereNull(DataSvcCtor, () => "Public"); + DataSvcCustom = DefaultWhereNull(DataSvcCustom, () => "None"); + ManagerCustom = DefaultWhereNull(ManagerCustom, () => false); EventSource = DefaultWhereNull(EventSource, () => $"{Name!.ToLowerInvariant()}/{{$key}}"); EventPublish = DefaultWhereNull(EventPublish, () => Parent!.EventPublish); EventTransaction = DefaultWhereNull(EventTransaction, () => Parent!.EventTransaction); diff --git a/tools/Beef.CodeGen.Core/Config/Entity/OperationConfig.cs b/tools/Beef.CodeGen.Core/Config/Entity/OperationConfig.cs index b148e985..d12c459c 100644 --- a/tools/Beef.CodeGen.Core/Config/Entity/OperationConfig.cs +++ b/tools/Beef.CodeGen.Core/Config/Entity/OperationConfig.cs @@ -1202,13 +1202,15 @@ protected override async Task PrepareAsync() if (DataTransaction!.Value || CompareValue(EventPublish, "Data") || CompareValue(DataExtensions, true)) DataInvoker = true; - DataSvcCustom = DefaultWhereNull(DataSvcCustom, () => "None"); + DataSvcCustom = DefaultWhereNull(DataSvcCustom, () => Parent!.DataSvcCustom); DataSvcTransaction = DefaultWhereNull(DataSvcTransaction, () => CompareValue(EventPublish, "DataSvc") && CompareValue(Parent!.EventTransaction, true)); DataSvcInvoker = DefaultWhereNull(DataSvcInvoker, () => false); if (DataSvcTransaction!.Value || CompareValue(EventPublish, "DataSvc")) DataSvcInvoker = true; DataSvcExtensions = DefaultWhereNull(DataSvcExtensions, () => Parent!.DataSvcExtensions); + ManagerCustom = DefaultWhereNull(ManagerCustom, () => Parent!.ManagerCustom); + ExcludeAll = DefaultWhereNull(ExcludeAll, () => false); ExcludeIData = DefaultWhereNull(ExcludeIData, () => CompareValue(ExcludeAll, true)); ExcludeData = DefaultWhereNull(ExcludeData, () => CompareValue(ExcludeAll, true)); diff --git a/tools/Beef.CodeGen.Core/Schema/entity.beef-5.json b/tools/Beef.CodeGen.Core/Schema/entity.beef-5.json index da7250e0..72c984c5 100644 --- a/tools/Beef.CodeGen.Core/Schema/entity.beef-5.json +++ b/tools/Beef.CodeGen.Core/Schema/entity.beef-5.json @@ -565,6 +565,10 @@ "Protected" ] }, + "dataCtorCustom": { + "type": "boolean", + "title": "Indicates whether the \u0060Data\u0060 constructor will be implemented as custom; i.e. not generated." + }, "dataCtorParams": { "type": "array", "title": "The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated \u0060Data\u0060 constructor.", @@ -754,6 +758,20 @@ "Protected" ] }, + "dataSvcCustom": { + "type": "string", + "title": "The option that indicates the level of \u0060DataSvc\u0060 customization (invokes \u0060*OnImplementationAsync\u0060 method) vs code-generation (automatically invokes data-layer).", + "description": "\u0060Full\u0060 indicates the logic is fully customized (only invocation is code-generated). \u0060Partial\u0060 indicates combination of surrounding code-generation with final custom invocation versus data-layer. \u0060None\u0060 indicates data-layer invocation with _no_ custom invocation (default).", + "enum": [ + "Full", + "Partial", + "None" + ] + }, + "dataSvcCtorCustom": { + "type": "boolean", + "title": "Indicates whether the \u0060DataSvc\u0060 constructor will be implemented as custom; i.e. not generated." + }, "dataSvcCtorParams": { "type": "array", "title": "The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated \u0060DataSvc\u0060 constructor.", @@ -787,6 +805,10 @@ "title": "Indicates whether a \u0060System.TransactionScope\u0060 should be created and orchestrated whereever generating event publishing logic.", "description": "Usage will force a rollback of any underlying data transaction (where the provider supports TransactionScope) on failure, such as an \u0060EventPublish\u0060 error. This is by no means implying a Distributed Transaction (DTC) should be invoked; this is only intended for a single data source that supports a TransactionScope to guarantee reliable event publishing. Defaults to \u0060CodeGeneration.EventTransaction\u0060. This essentially defaults the \u0060Operation.DataSvcTransaction\u0060 where not otherwise specified. This should only be used where a transactionally-aware data source is being used." }, + "managerCustom": { + "type": "boolean", + "title": "Indicates whether the \u0060Manager\u0060 logic is a custom implementation; i.e. no auto-\u0060DataSvc\u0060 invocation logic is to be generated." + }, "managerCtor": { "type": "string", "title": "The access modifier for the generated \u0060Manager\u0060 constructor.", @@ -797,6 +819,10 @@ "Protected" ] }, + "managerCtorCustom": { + "type": "boolean", + "title": "Indicates whether the \u0060Manager\u0060 constructor will be implemented as custom; i.e. not generated." + }, "managerCtorParams": { "type": "array", "title": "The list of additional (non-inferred) Dependency Injection (DI) parameters for the generated \u0060Manager\u0060 constructor.", diff --git a/tools/Beef.CodeGen.Core/Templates/EntityDataSvc_cs.hbs b/tools/Beef.CodeGen.Core/Templates/EntityDataSvc_cs.hbs index 106fb653..813f1a43 100644 --- a/tools/Beef.CodeGen.Core/Templates/EntityDataSvc_cs.hbs +++ b/tools/Beef.CodeGen.Core/Templates/EntityDataSvc_cs.hbs @@ -33,6 +33,8 @@ public partial class {{Name}}DataSvc{{#if GenericWithT}}{{/if}} : I{{Name}}Da #endregion {{/if}} +{{#unless DataSvcCtorCustom}} + {{#ifne DataSvcCtorParameters.Count 0}} /// /// Initializes a new instance of the class. /// @@ -52,8 +54,13 @@ public partial class {{Name}}DataSvc{{#if GenericWithT}}{{/if}} : I{{Name}}Da {{/ifle}} partial void {{Name}}DataSvcCtor(); // Enables additional functionality to be added to the constructor. + + {{/ifne}} +{{/unless}} {{#each DataSvcOperations}} + {{#unless @first}} + {{/unless}} {{#if ExcludeIDataSvc}} /// /// {{{SummaryText}}} diff --git a/tools/Beef.CodeGen.Core/Templates/EntityData_cs.hbs b/tools/Beef.CodeGen.Core/Templates/EntityData_cs.hbs index b349bd7b..b2b38d83 100644 --- a/tools/Beef.CodeGen.Core/Templates/EntityData_cs.hbs +++ b/tools/Beef.CodeGen.Core/Templates/EntityData_cs.hbs @@ -21,7 +21,9 @@ public partial class {{Name}}Data{{#if GenericWithT}}{{/if}}{{#ifne Operation {{/each}} {{#if DataExtensionsRequired}} {{#if HasDataExtensions}} + {{#ifne DataCtorParameters.Count 0}} + {{/ifne}} #region Extensions {{/if}} @@ -51,16 +53,21 @@ public partial class {{Name}}Data{{#if GenericWithT}}{{/if}}{{#ifne Operation {{/ifne}} private Action? {{PrivateName}}OnException; {{/if}} - {{#if HasDataExtensions}} + {{#if @last}} {{/if}} {{/each}} {{#if HasDataExtensions}} - #endregion + {{/if}} - {{/if}} + {{else}} + {{#ifne DataCtorParameters.Count 0}} + {{/ifne}} + {{/if}} + {{#unless DataCtorCustom}} + {{#ifne DataCtorParameters.Count 0}} /// /// Initializes a new instance of the class. /// @@ -77,11 +84,16 @@ public partial class {{Name}}Data{{#if GenericWithT}}{{/if}}{{#ifne Operation {{/each}} {{Name}}DataCtor(); } -{{/ifle}} + {{/ifle}} partial void {{Name}}DataCtor(); // Enables additional functionality to be added to the constructor. + + {{/ifne}} + {{/unless}} {{#each DataOperations}} + {{#unless @first}} + {{/unless}} {{#if ExcludeIData}} /// /// {{{SummaryText}}} diff --git a/tools/Beef.CodeGen.Core/Templates/EntityManager_cs.hbs b/tools/Beef.CodeGen.Core/Templates/EntityManager_cs.hbs index 635095e3..329e8dcf 100644 --- a/tools/Beef.CodeGen.Core/Templates/EntityManager_cs.hbs +++ b/tools/Beef.CodeGen.Core/Templates/EntityManager_cs.hbs @@ -38,6 +38,8 @@ public partial class {{Name}}Manager{{#if GenericWithT}}{{/if}} : I{{Name}}Ma #endregion {{/if}} +{{#unless ManagerCtorCustom}} + {{#ifne ManagerCtorParameters.Count 0}} /// /// Initializes a new instance of the class. /// @@ -58,6 +60,8 @@ public partial class {{Name}}Manager{{#if GenericWithT}}{{/if}} : I{{Name}}Ma partial void {{Name}}ManagerCtor(); // Enables additional functionality to be added to the constructor. + {{/ifne}} +{{/unless}} {{#each ManagerOperations}} {{#unless @first}} @@ -81,7 +85,7 @@ public partial class {{Name}}Manager{{#if GenericWithT}}{{/if}} : I{{Name}}Ma {{set-value 'HasResultCode' false}}public {{{OperationTaskReturnType}}} {{Name}}Async({{#each Parameters}}{{{ParameterType}}} {{ArgumentName}}{{#unless @last}}, {{/unless}}{{/each}}{{#if Root.CancellationToken}}, CancellationToken cancellationToken = default{{/if}}) => ManagerInvoker.Current.InvokeAsync(this, {{#unless WithResult}}async {{/unless}}(_, ct) => { {{#if WithResult}} - return Result.Go{{#if HasValue}}(value){{#if ValueParameter.IsMandatory}}.Required(){{/if}}{{else}}(){{/if}}{{#each ValueLessMandatoryParameters}}.Requires({{ArgumentName}}){{/each}}{{#ifeq ManagerPassingParameters.Count 1}}{{#each ManagerPassingParameters}}.Then(v => v.{{Name}}{{#ifeq LayerPassing 'ToManagerSet'}} = {{ArgumentName}}{{else}}.ForEach(i => i.{{Name}} = {{ArgumentName}}){{/ifeq}}){{/each}}{{/ifeq}} + return Result.Go{{#if HasValue}}(value){{#if ValueParameter.IsMandatory}}.Required(){{/if}}{{else}}(){{/if}}{{#each ValueLessMandatoryParameters}}.Requires({{ArgumentName}}){{/each}}{{#ifeq ManagerPassingParameters.Count 1}}{{#each ManagerPassingParameters}}.Adjusts(v => v.{{Name}}{{#ifeq LayerPassing 'ToManagerSet'}} = {{ArgumentName}}{{else}}.ForEach(i => i.{{Name}} = {{ArgumentName}}){{/ifeq}}){{/each}}{{/ifeq}} {{/if}} {{#ifval AuthRole}} {{#if WithResult}} .UserIsInRole("{{AuthRole}}"){{else}}ExecutionContext.Current.UserIsInRole("{{AuthRole}}").ThrowOnError();{{/if}} @@ -93,7 +97,7 @@ public partial class {{Name}}Manager{{#if GenericWithT}}{{/if}} : I{{Name}}Ma {{#each Parent.Properties}} {{#if IdentifierGenerator}} {{#if Parent.WithResult}} - .ThenAsync(async v => v.{{Name}} = await _identifierGenerator.GenerateIdentifierAsync<{{Type}}, {{../../ValueType}}>({{#if Root.CancellationToken}}ct{{/if}}).ConfigureAwait(false)) + .AdjustsAsync(async v => v.{{Name}} = await _identifierGenerator.GenerateIdentifierAsync<{{Type}}, {{../../ValueType}}>({{#if Root.CancellationToken}}ct{{/if}}).ConfigureAwait(false)) {{else}} value{{#ifeq ../../EnsureValueCount 0}}.Required(){{/ifeq}}.{{Name}} = await _identifierGenerator.GenerateIdentifierAsync<{{Type}}, {{../../ValueType}}>({{#if Root.CancellationToken}}ct{{/if}}).ConfigureAwait(false); {{/if}} @@ -200,7 +204,7 @@ public partial class {{Name}}Manager{{#if GenericWithT}}{{/if}} : I{{Name}}Ma {{/if}} {{else}} {{#if WithResult}} - .Then{{#if HasReturnValue}}As{{/if}}Async({{#if HasValue}}v{{else}}(){{/if}} => _dataService.{{Name}}Async({{#each DataParameters}}{{#unless @first}}, {{/unless}}{{{ArgumentName}}}{{/each}}{{#if Root.CancellationToken}}, ct{{/if}})); + .Then{{#ifor HasReturnValue HasValue}}As{{/ifor}}Async({{#if HasValue}}v{{else}}(){{/if}} => _dataService.{{Name}}Async({{#each DataParameters}}{{#unless @first}}, {{/unless}}{{#if IsValueArg}}v{{else}}{{{ArgumentName}}}{{/if}}{{/each}}{{#if Root.CancellationToken}}, ct{{/if}})); {{else}} {{#if HasReturnValue}}return {{#if ManagerCleanUp}}Cleaner.Clean({{/if}}{{/if}}await _dataService.{{Name}}Async({{#each DataParameters}}{{{ArgumentName}}}{{#unless @last}}, {{/unless}}{{/each}}{{#if Root.CancellationToken}}, ct{{/if}}).ConfigureAwait(false){{#if HasReturnValue}}{{#if ManagerCleanUp}}){{/if}}{{/if}}; {{/if}} diff --git a/tools/Beef.Database.Core/Beef.Database.Core.csproj b/tools/Beef.Database.Core/Beef.Database.Core.csproj index efe7f828..45dd0feb 100644 --- a/tools/Beef.Database.Core/Beef.Database.Core.csproj +++ b/tools/Beef.Database.Core/Beef.Database.Core.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj index c55a9f11..6b43f70c 100644 --- a/tools/Beef.Database.MySql/Beef.Database.MySql.csproj +++ b/tools/Beef.Database.MySql/Beef.Database.MySql.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj index 0c1e062f..6212711c 100644 --- a/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj +++ b/tools/Beef.Database.Postgres/Beef.Database.Postgres.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj index 7261fedb..fdade4d9 100644 --- a/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj +++ b/tools/Beef.Database.SqlServer/Beef.Database.SqlServer.csproj @@ -14,7 +14,7 @@ - + diff --git a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj index 775a1fe3..c5ef5abe 100644 --- a/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj +++ b/tools/Beef.Test.NUnit/Beef.Test.NUnit.csproj @@ -8,7 +8,7 @@ - +