Skip to content

Commit

Permalink
v5.14.0 (#250)
Browse files Browse the repository at this point in the history
* v5.13.1
- *Fixed:* Model code-generation corrected to explicitly output `Newtonsoft.Json.JsonIgnore`.
- *Fixed:* Entity and model templates updated to correctly generate the `PrimaryKey` where the property is reference data.
- *Fixed:* Upgraded dependencies.

* Common and Dictionary fixes.

* Operation.DataSvcCustom changes.
Version now v15.14.0 given changes.

* `ICacheKey` support.

* CoreEx fix to correct failing test.

* OnRamp long vs decimal fix.
  • Loading branch information
chullybun authored Jul 30, 2024
1 parent 06c8fa2 commit df0b999
Show file tree
Hide file tree
Showing 54 changed files with 487 additions and 165 deletions.
29 changes: 20 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Represents the **NuGet** versions.

## 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:
- `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).
- Existing configurations of `dataSvcCustom: true` should be changed to `dataSvcCustom: Full` to achieve same behavior. Where not changed a code-generation runtime error will occur.
- *Enhancement:* Added support for `Property`-based `ICacheKey` support using `cacheKey: true` resulting in corresponding entity code-generation.
- *Fixed:* Model code-generation corrected to explicitly output `Newtonsoft.Json.JsonIgnore`.
- *Fixed:* Entity and model templates updated to correctly generate the `PrimaryKey` where the property is reference data.
- *Fixed:* Entity collection code-generation for Dictionary updated to include capabilities to add items using primary key where specified.
- *Fixed:* Upgraded dependencies.

## v5.13.0
- *Enhancement:* Added `dotnet run openapi` option to perform *basic* parsing of an [OpenAPI](https://spec.openapis.org/oas/latest.html) document generating the corresponding `Entity`, `Operation` and `Property` configuration into a temporary YAML file. The contents are expected to then be copied and pasted into the appropriate YAML destination and further configured as necessary.
- Execute `dotnet run -- --help` to see all command-line capabilities for this.
Expand Down Expand Up @@ -185,12 +198,10 @@ Represents the **NuGet** versions.
- *Fixed:* Upgraded `CoreEx`, `DbEx` and `UnitTestEx` to latest packages to include all related fixes. Template solution updated to leverage `app.UseReferenceDataOrchestrator()` to specifically include.

## v5.1.0
Represents the initial commit for _Beef_ version 5.x. All assemblies/packages now share the same version and change log; i.e. they are now published as a set versus individually versioned (prior releases). This version is a _major_ refactoring from the prior; to achieve largely the same outcomes, in a modernized decoupled manner.

As stated in the [README](./README.md), _Beef_ is _now_ (as of version 5.x) ostensibly the code-generation engine, and solution orchestration, that ultimately takes dependencies on the following capabilities to enable the end-to-functionality and testing thereof in a standardized (albeit somewhat opinionated) manner:
- [CoreEx](https://github.com/Avanade/CoreEx) - provides the core runtime capabilities (extends .NET core);
- [UnitTestEx](https://github.com/Avanade/UnitTestEx) - provides extended unit and intra-domain integration testing;
- [DbEx](https://github.com/Avanade/DbEx) - provides extended database management capabilities ;
- [OnRamp](https://github.com/Avanade/OnRamp) - provides the underlying code-generation engine functionality.

Prior to version 5.x, _Beef_ was all encompassing. These capabilities have been extracted, simplified and refactored to be first class frameworks in their own right, and made into the repos listed above. This allows them to be used and maintained independently to _Beef_; therefore, offering greater opportunities for reuse versus all-or-nothing.
- Represents the initial commit for _Beef_ version 5.x. All assemblies/packages now share the same version and change log; i.e. they are now published as a set versus individually versioned (prior releases). This version is a _major_ refactoring from the prior; to achieve largely the same outcomes, in a modernized decoupled manner.
- As stated in the [README](./README.md), _Beef_ is _now_ (as of version 5.x) ostensibly the code-generation engine, and solution orchestration, that ultimately takes dependencies on the following capabilities to enable the end-to-functionality and testing thereof in a standardized (albeit somewhat opinionated) manner:
- [CoreEx](https://github.com/Avanade/CoreEx) - provides the core runtime capabilities (extends .NET core);
- [UnitTestEx](https://github.com/Avanade/UnitTestEx) - provides extended unit and intra-domain integration testing;
- [DbEx](https://github.com/Avanade/DbEx) - provides extended database management capabilities ;
- [OnRamp](https://github.com/Avanade/OnRamp) - provides the underlying code-generation engine functionality.
- Prior to version 5.x, _Beef_ was all encompassing. These capabilities have been extracted, simplified and refactored to be first class frameworks in their own right, and made into the repos listed above. This allows them to be used and maintained independently to _Beef_; therefore, offering greater opportunities for reuse versus all-or-nothing.
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.13.0</Version>
<Version>5.14.0</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
2 changes: 1 addition & 1 deletion docs/Entity-Entity-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Property | Description
**`excludeEntity`** | Indicates whether to exclude the generation of the `Entity` class (`Xxx.cs`).
**`excludeAll`** | Indicates whether to exclude the generation of all `Operation` related artefacts; excluding the `Entity` class.<br/>&dagger; Is a shorthand means for setting all of the other `Exclude*` properties (with the exception of `ExcludeEntity`) to exclude.
`excludeIData` | Indicates whether to exclude the generation of the `Data` interface (`IXxxData.cs`).
`excludeData` | The option to exclude the generation of the `Data` class (`XxxData.cs`). Valid options are: `Include`, `Exclude`, `RequiresMapper`.<br/>&dagger; Defaults to `Include` indicating _not_ to exlude. A value of `Exclude` indicates to exclude all output; alternatively, `RequiresMapper` indicates to at least output the corresponding `Mapper` class.
`excludeData` | The option to exclude the generation of the `Data` class (`XxxData.cs`). Valid options are: `Include`, `Exclude`, `RequiresMapper`.<br/>&dagger; Defaults to `Include` indicating _not_ to exclude. A value of `Exclude` indicates to exclude all output; alternatively, `RequiresMapper` indicates to at least output the corresponding `Mapper` class.
`excludeIDataSvc` | Indicates whether to exclude the generation of the `DataSvc` interface (`IXxxDataSvc.cs`).
`excludeDataSvc` | Indicates whether to exclude the generation of the `DataSvc` class (`XxxDataSvc.cs`).
`excludeIManager` | Indicates whether to exclude the generation of the `Manager` interface (`IXxxManager.cs`).
Expand Down
6 changes: 3 additions & 3 deletions docs/Entity-Operation-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Property | Description
**`paging`** | Indicates whether a `PagingArgs` argument is to be added to the operation to enable (standardized) paging related logic.
`valueType` | The .NET value parameter `Type` for the operation.<br/>&dagger; Defaults to the parent `Entity.Name` where the `Operation.Type` options are `Create` or `Update`.
`returnType` | The .NET return `Type` for the operation.<br/>&dagger; Defaults to the parent `Entity.Name` where the `Operation.Type` options are `Get`, `GetColl`, `Create` or `Update`; otherwise, defaults to `void`.
`returnTypeNullable` | Indicates whether the `ReturnType` is nullable for the operation.<br/>&dagger; This is only applicable for an `Operation.Type` of `Custom`. Will be inferred where the `ReturnType` is denoted as nullable; i.e. suffixed by a `?`.
`returnTypeNullable` | Indicates whether the `ReturnType` is nullable for the operation.<br/>&dagger; Will be inferred where the `ReturnType` is denoted as nullable; i.e. suffixed by a `?`. Additionally a `Type` of `Get` will default to `true` where not specified.
`returnText` | The text for use in comments to describe the `ReturnType`.<br/>&dagger; A default will be created where not specified. To create a `<see cref="XXX"/>` within use moustache shorthand (e.g. {{Xxx}}). To have the text used as-is prefix with a `+` plus-sign character.
`privateName` | The overriding private name.<br/>&dagger; Overrides the `Name` to be used for private usage. By default reformatted from `Name`; e.g. `GetByArgs` as `_getByArgs`.
`withResult` | Indicates whether to use `CoreEx.Results` (aka Railway-oriented programming).<br/>&dagger; Defaults to `Entity.WilhResult`.
Expand Down Expand Up @@ -138,9 +138,9 @@ Provides the _Data Services-layer_ configuration.

Property | Description
-|-
**`dataSvcCustom`** | Indicates whether the `DataSvc` logic is a custom implementation; i.e. no auto-`DataSvc` invocation logic is to be generated.
**`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).
`dataSvcTransaction` | Indicates whether a `System.TransactionScope` should be created and orchestrated at the `DataSvc`-layer.
`dataSvcInvoker` | Indicates whether a `DataSvcInvoker` should orchestrate the `DataSvc`-layer.<br/>&dagger; Where `DataSvcTransaction` or `EventPublish` is `DataSvc` then orchestration will default to `true`.
`dataSvcInvoker` | Indicates whether a `DataSvcInvoker` should orchestrate the `DataSvc`-layer.<br/>&dagger; Where `DataSvcTransaction` or `EventPublish` is `DataSvc` then the orchestration will default to `true`.
`dataSvcExtensions` | Indicates whether the `DataSvc` extensions logic should be generated.<br/>&dagger; Defaults to `Entity.ManagerExtensions`.

<br/>
Expand Down
1 change: 1 addition & 0 deletions docs/Entity-Property-Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Property | Description
`autoCreate` | Indicates whether an instance of the `Type` is to be automatically created/instantiated when the property is first accessed (i.e. lazy instantiation).
`default` | The C# code to default the value.<br/>&dagger; Where the `Type` is `string` then the specified default value will need to be delimited. Any valid value assignment C# code can be used.
`partitionKey` | Indicates whether the property is considered part of the Partition Key.<br/>&dagger; This will implement `IPartitionKey` for the generated entity.
`cacheKey` | Indicates whether the property is considered part of the Cache Key.<br/>&dagger; This will implement `ICacheKey` for the generated entity.
`internalOnly` | Indicates whether the property is for internal use only; declared in Business entities only.<br/>&dagger; In this instance the `Property` will be excluded from the `Common` entity declaration and `Business` JSON serialization.

<br/>
Expand Down
2 changes: 1 addition & 1 deletion samples/Cdr.Banking/Cdr.Banking.Api/Cdr.Banking.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.21.1" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
</ItemGroup>
<ItemGroup>
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.21.1" />
<PackageReference Include="CoreEx.Cosmos" Version="3.21.1" />
<PackageReference Include="CoreEx.Validation" Version="3.21.1" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.2" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.2" />
<PackageReference Include="CoreEx.Validation" Version="3.23.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ partial void AccountDataCtor()
private Task<Result<Balance?>> GetBalanceOnImplementationAsync(string? accountId)
{
// Use the 'Account' model and select for the specified id to access the balance property.
return Result.GoAsync(_cosmos.Accounts.ModelQuery(q => q.Where(x => x.Id == accountId)).SelectFirstOrDefaultWithResultAsync())
return Result.GoAsync(_cosmos.Accounts.ModelContainer.Query(q => q.Where(x => x.Id == accountId)).SelectFirstOrDefaultWithResultAsync())
.WhenAs(a => a is not null, a =>
{
var bal = _cosmos.Mapper.Map<Model.Balance, Balance>(a!.Balance);
Expand Down
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.21.1" />
<PackageReference Include="CoreEx" Version="3.23.2" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions samples/Cdr.Banking/Cdr.Banking.Test/Cdr.Banking.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -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.21.1" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.23.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Demo/Beef.Demo.Api/Beef.Demo.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.21.1" />
<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" />
</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.21.1" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.21.1" />
<PackageReference Include="CoreEx.Cosmos" Version="3.21.1" />
<PackageReference Include="CoreEx.Database" Version="3.21.1" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.21.1" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.21.1" />
<PackageReference Include="CoreEx.Validation" Version="3.21.1" />
<PackageReference Include="CoreEx.FluentValidation" Version="3.21.1" />
<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="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.20" />
</ItemGroup>

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

#nullable enable
#pragma warning disable

namespace Beef.Demo.Business.Data.Model
{
/// <summary>
/// Represents the Ref Data Primary Key model.
/// </summary>
public partial class RefDataPrimaryKey : IPrimaryKey
{
/// <summary>
/// Gets or sets the Key1 code.
/// </summary>
public string? Key1 { get; set; }

/// <summary>
/// Gets or sets the Other.
/// </summary>
public string? Other { get; set; }

/// <summary>
/// Creates the primary <see cref="CompositeKey"/>.
/// </summary>
/// <returns>The primary <see cref="CompositeKey"/>.</returns>
/// <param name="key1">The <see cref="Key1"/>.</param>
public static CompositeKey CreatePrimaryKey(string? key1) => CompositeKey.Create(key1);

/// <summary>
/// Gets the primary <see cref="CompositeKey"/> (consists of the following property(s): <see cref="Key1"/>).
/// </summary>
[JsonIgnore]
public CompositeKey PrimaryKey => CreatePrimaryKey(Key1);
}
}

#pragma warning restore
#nullable restore
5 changes: 2 additions & 3 deletions samples/Demo/Beef.Demo.Business/Data/Model/Generated/Robot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#nullable enable
#pragma warning disable

using Newtonsoft.Json;

namespace Beef.Demo.Business.Data.Model
{
/// <summary>
Expand Down Expand Up @@ -42,7 +40,8 @@ public partial class Robot : IIdentifier<string>, IETag, IChangeLog
/// <summary>
/// Gets or sets the ETag.
/// </summary>
[JsonProperty("_etag")]
[Newtonsoft.Json.JsonProperty("_etag")]
[JsonPropertyName("_etag")]
public string? ETag { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public partial class PersonDataSvc : IPersonDataSvc
private Func<Person?, Task>? _getNoArgsOnAfterAsync;
private Func<PersonDetail?, Guid, Task>? _getDetailOnAfterAsync;
private Func<PersonDetail, Task>? _updateDetailOnAfterAsync;
private Func<int, Task>? _dataSvcCustomOnAfterAsync;
private Func<Person?, string?, List<string>?, Task>? _getNullOnAfterAsync;
private Func<PersonCollectionResult, PersonArgs?, PagingArgs?, Task>? _getByArgsWithEfOnAfterAsync;
private Func<Task>? _throwErrorOnAfterAsync;
Expand Down Expand Up @@ -196,7 +197,12 @@ public Task<PersonDetail> UpdateDetailAsync(PersonDetail value) => DataSvcInvoke
}, new InvokerArgs { IncludeTransactionScope = true, EventPublisher = _events });

/// <inheritdoc/>
public Task<int> DataSvcCustomAsync() => DataSvcCustomOnImplementationAsync();
public async Task<int> DataSvcCustomAsync()
{
var r = await DataSvcCustomOnImplementationAsync().ConfigureAwait(false);
await Invoker.InvokeAsync(_dataSvcCustomOnAfterAsync?.Invoke(r)).ConfigureAwait(false);
return r;
}

/// <inheritdoc/>
public async Task<Person?> GetNullAsync(string? name, List<string>? names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public RobotDataSvc(IRobotData data, IEventPublisher events, IRequestCache cache
partial void RobotDataSvcCtor(); // Enables additional functionality to be added to the constructor.

/// <inheritdoc/>
public Task<Result<Robot?>> GetAsync(Guid id) => Result.Go().CacheGetOrAddAsync(_cache, id, () => _data.GetAsync(id));
public Task<Result<Robot?>> GetAsync(Guid id) => Result.Go().CacheGetOrAddAsync(_cache, id, () => GetOnImplementationAsync(id));

/// <inheritdoc/>
public Task<Result<Robot>> CreateAsync(Robot value) => DataSvcInvoker.Current.InvokeAsync(this, (_, __) =>
Expand Down
7 changes: 7 additions & 0 deletions samples/Demo/Beef.Demo.Business/DataSvc/RobotDataSvc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Beef.Demo.Business.DataSvc
{
public partial class RobotDataSvc
{
private Task<Result<Robot?>> GetOnImplementationAsync(Guid id) => _data.GetAsync(id);
}
}
16 changes: 15 additions & 1 deletion samples/Demo/Beef.Demo.Business/Entities/Generated/PersonArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Beef.Demo.Business.Entities;
/// <summary>
/// Represents the <see cref="Person"/> arguments entity.
/// </summary>
public partial class PersonArgs : EntityBase
public partial class PersonArgs : EntityBase, ICacheKey
{
private string? _firstName;
private string? _lastName;
Expand Down Expand Up @@ -45,6 +45,20 @@ public partial class PersonArgs : EntityBase
/// </summary>
public Common.Entities.OrderBy? OrderBy { get => _orderBy; set => SetValue(ref _orderBy, value); }

/// <summary>
/// Creates the <see cref="ICacheKey.CacheKey"/>.
/// </summary>
/// <param name="firstName">The <see cref="FirstName"/>.</param>
/// <param name="lastName">The <see cref="LastName"/>.</param>
/// <returns>The Cache Key.</returns>
public static CompositeKey CreateCacheKey(string? firstName, string? lastName) => CompositeKey.Create(firstName, lastName);

/// <summary>
/// Gets the Cache Key (consists of the following property(s): <see cref="FirstName"/>, <see cref="LastName"/>).
/// </summary>
[JsonIgnore]
public CompositeKey CacheKey => CreateCacheKey(FirstName, LastName);

/// <inheritdoc/>
protected override IEnumerable<IPropertyValue> GetPropertyValues()
{
Expand Down
Loading

0 comments on commit df0b999

Please sign in to comment.