Skip to content

Commit

Permalink
v5.14.2 (#252)
Browse files Browse the repository at this point in the history
- *Fixed:* Fixed the data model code-generation to output the `PartitionKey` where specified.
- *Fixed:* Fixed the code-generated `PartitionKey` to be a nullable string.
- *Fixed:* Fixed the templated `CosmosDb` to ensure lazy-loading of container (versus re-creating on each access).
  • Loading branch information
chullybun authored Aug 7, 2024
1 parent e0f97ec commit 2edb83a
Show file tree
Hide file tree
Showing 38 changed files with 152 additions and 69 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Represents the **NuGet** versions.

## v5.14.2
- *Fixed:* Fixed the data model code-generation to output the `PartitionKey` where specified.
- *Fixed:* Fixed the code-generated `PartitionKey` to be a nullable string.
- *Fixed:* Fixed the templated `CosmosDb` to ensure lazy-loading of container (versus re-creating on each access).

## 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`.
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.1</Version>
<Version>5.14.2</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
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.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.7.0" />
</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.23.4" />
<PackageReference Include="CoreEx.Cosmos" Version="3.23.4" />
<PackageReference Include="CoreEx.Validation" Version="3.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Cosmos" Version="3.24.1" />
<PackageReference Include="CoreEx.Validation" Version="3.24.1" />
</ItemGroup>
</Project>
34 changes: 30 additions & 4 deletions samples/Cdr.Banking/Cdr.Banking.Business/Data/CosmosDb.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Cdr.Banking.Business.Data;
using System.Diagnostics.Metrics;

namespace Cdr.Banking.Business.Data;

/// <summary>
/// Represents the CosmosDb/DocumentDb client.
Expand All @@ -8,24 +10,28 @@ public interface ICosmos : ICosmosDb
/// <summary>
/// Exposes <see cref="Account"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<Account, Model.Account> Accounts => Container<Account, Model.Account>("Account");
CosmosDbContainer<Account, Model.Account> Accounts { get; }

/// <summary>
/// Exposes <see cref="AccountDetail"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<AccountDetail, Model.Account> AccountDetails => Container<AccountDetail, Model.Account>("Account");
CosmosDbContainer<AccountDetail, Model.Account> AccountDetails { get; }

/// <summary>
/// Exposes <see cref="AccountDetail"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<Transaction, Model.Transaction> Transactions => Container<Transaction, Model.Transaction>("Transaction");
CosmosDbContainer<Transaction, Model.Transaction> Transactions { get; }
}

/// <summary>
/// Represents the CosmosDb/DocumentDb client.
/// </summary>
public class CosmosDb : CoreEx.Cosmos.CosmosDb, ICosmos
{
private readonly Lazy<CosmosDbContainer<Account, Model.Account>> _accounts;
private readonly Lazy<CosmosDbContainer<AccountDetail, Model.Account>> _accountDetails;
private readonly Lazy<CosmosDbContainer<Transaction, Model.Transaction>> _transactions;

/// <summary>
/// Initializes a new instance of the <see cref="CosmosDb"/> class.
/// </summary>
Expand All @@ -34,5 +40,25 @@ public CosmosDb(Mac.Database database, IMapper mapper, CosmosDbInvoker? invoker
// Apply an authorization filter to all operations to ensure only the valid data is available based on the users context; i.e. only allow access to Accounts within list defined on ExecutionContext.
UseAuthorizeFilter<Model.Account>("Account", (q) => ((IQueryable<Model.Account>)q).Where(x => ExecutionContext.Current.Accounts.Contains(x.Id!)));
UseAuthorizeFilter<Model.Account>("Transaction", (q) => ((IQueryable<Model.Transaction>)q).Where(x => ExecutionContext.Current.Accounts.Contains(x.AccountId!)));

// Lazy create the containers.
_accounts = new(() => Container<Account, Model.Account>("Account"));
_accountDetails = new(() => Container<AccountDetail, Model.Account>("Account"));
_transactions = new(() => Container<Transaction, Model.Transaction>("Transaction"));
}

/// <summary>
/// Exposes <see cref="Account"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<Account, Model.Account> Accounts => _accounts.Value;

/// <summary>
/// Exposes <see cref="AccountDetail"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<AccountDetail, Model.Account> AccountDetails => _accountDetails.Value;

/// <summary>
/// Exposes <see cref="AccountDetail"/> entity from <b>Account</b> container.
/// </summary>
public CosmosDbContainer<Transaction, Model.Transaction> Transactions => _transactions.Value;
}
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.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
</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.4" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.24.1" />
</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.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.7.0" />
</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.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="CoreEx" Version="3.24.1" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Cosmos" Version="3.24.1" />
<PackageReference Include="CoreEx.Database" Version="3.24.1" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.24.1" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Validation" Version="3.24.1" />
<PackageReference Include="CoreEx.FluentValidation" Version="3.24.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.20" />
</ItemGroup>

Expand Down
11 changes: 5 additions & 6 deletions samples/Demo/Beef.Demo.Business/Data/DemoCosmosDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ namespace Beef.Demo.Business.Data
/// </summary>
public class DemoCosmosDb : CosmosDb
{
private readonly Lazy<CosmosDbContainer<Robot, Model.Robot>> _items;

/// <summary>
/// Initializes a new instance of the <see cref="DemoCosmosDb"/> class.
/// </summary>
/// <param name="client">The <see cref="CosmosClient"/>.</param>
/// <param name="databaseId">The database identifier.</param>
/// <param name="createDatabaseIfNotExists">Indicates whether the database shoould be created if it does not exist.</param>
/// <param name="throughput">The throughput (RU/S).</param>
public DemoCosmosDb(Microsoft.Azure.Cosmos.Database database, IMapper mapper, CosmosDbInvoker? invoker = null) : base(database, mapper, invoker) { }
public DemoCosmosDb(Microsoft.Azure.Cosmos.Database database, IMapper mapper, CosmosDbInvoker? invoker = null) : base(database, mapper, invoker)
=> _items = new(() => Container<Robot, Model.Robot>("Items"));

public CosmosDbContainer<Robot, Model.Robot> Items => Container<Robot, Model.Robot>("Items");
public CosmosDbContainer<Robot, Model.Robot> Items => _items.Value;

///// <summary>
///// System.Text.Json not supported natively; see https://github.com/Azure/azure-cosmos-dotnet-v3/issues/2533 and https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/Usage/SystemTextJson.
Expand Down
15 changes: 14 additions & 1 deletion samples/Demo/Beef.Demo.Business/Data/Model/Generated/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Beef.Demo.Business.Data.Model
/// <summary>
/// Represents the Person model.
/// </summary>
public partial class Person
public partial class Person : IPartitionKey
{
/// <summary>
/// Gets or sets the User Name.
Expand All @@ -26,6 +26,19 @@ public partial class Person
/// Gets or sets the Last Name.
/// </summary>
public string? LastName { get; set; }

/// <summary>
/// Creates the <see cref="IPartitionKey.PartitionKey"/>.
/// </summary>
/// <returns>The partition key.</returns>
/// <param name="userName">The <see cref="UserName"/>.</param>
public static string? CreatePartitionKey(string? userName) => CompositeKey.Create(userName).ToString();

/// <summary>
/// Gets the Partition Key (consists of the following property(s): <see cref="UserName"/>).
/// </summary>
[JsonIgnore]
public string? PartitionKey => CreatePartitionKey(UserName);
}
}

Expand Down
4 changes: 2 additions & 2 deletions samples/Demo/Beef.Demo.Business/Entities/Generated/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ public partial class Person : EntityBase, IIdentifier<Guid>, IPartitionKey, IETa
/// </summary>
/// <param name="eyeColor">The <see cref="EyeColor"/>.</param>
/// <returns>The Partition Key.</returns>
public static string CreatePartitionKey(string? eyeColorSid) => CompositeKey.Create(eyeColorSid).ToString();
public static string? CreatePartitionKey(string? eyeColorSid) => CompositeKey.Create(eyeColorSid).ToString();

/// <summary>
/// Gets the Partition Key (consists of the following property(s): <see cref="EyeColor"/>).
/// </summary>
[JsonIgnore]
public string PartitionKey => CreatePartitionKey(EyeColorSid);
public string? PartitionKey => CreatePartitionKey(EyeColorSid);

/// <inheritdoc/>
protected override IEnumerable<IPropertyValue> GetPropertyValues()
Expand Down
2 changes: 1 addition & 1 deletion samples/Demo/Beef.Demo.CodeGen/datamodel.beef-5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ entities:

- { name: Person,
properties: [
{ name: UserName },
{ name: UserName, partitionKey: true },
{ name: FirstName },
{ name: LastName }
# The endpoint always fails when Gender is passed; removed for now.
Expand Down
2 changes: 1 addition & 1 deletion samples/Demo/Beef.Demo.Common/Beef.Demo.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Folder Include="Agents\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
<PackageReference Include="Grpc.Tools" Version="2.64.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion samples/Demo/Beef.Demo.Test/Beef.Demo.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx.UnitTesting" Version="3.23.4" />
<PackageReference Include="CoreEx.UnitTesting" Version="3.24.1" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion samples/My.Hr/My.Hr.Api/My.Hr.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.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.7.0" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions samples/My.Hr/My.Hr.Business/My.Hr.Business.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx" 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" Version="3.24.1" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.24.1" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Validation" Version="3.24.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.31" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/My.Hr/My.Hr.Common/My.Hr.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions samples/My.Hr/My.Hr.Test/My.Hr.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -42,7 +42,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.4" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.24.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/MyEf.Hr/MyEf.Hr.Api/MyEf.Hr.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx.AspNetCore" Version="3.23.4" />
<PackageReference Include="CoreEx.Azure" Version="3.23.4" />
<PackageReference Include="CoreEx.AspNetCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Azure" Version="3.24.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.9" />
<PackageReference Include="AspNetCore.HealthChecks.Azure.Storage.Blobs" Version="8.0.1" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0" />
Expand Down
8 changes: 4 additions & 4 deletions samples/MyEf.Hr/MyEf.Hr.Business/MyEf.Hr.Business.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx" 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" Version="3.24.1" />
<PackageReference Include="CoreEx.Database.SqlServer" Version="3.24.1" />
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="3.24.1" />
<PackageReference Include="CoreEx.Validation" Version="3.24.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/MyEf.Hr/MyEf.Hr.Common/MyEf.Hr.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CoreEx.Azure" Version="3.23.4" />
<PackageReference Include="CoreEx.Validation" Version="3.23.4" />
<PackageReference Include="CoreEx.Azure" Version="3.24.1" />
<PackageReference Include="CoreEx.Validation" Version="3.24.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.20.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.23.4" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.24.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/MyEf.Hr/MyEf.Hr.Test/MyEf.Hr.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CoreEx" Version="3.23.4" />
<PackageReference Include="CoreEx" Version="3.24.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -42,7 +42,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.4" />
<PackageReference Include="CoreEx.UnitTesting.NUnit" Version="3.24.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@
"type": "generated",
"generator": "constant",
"parameters": {
"value": "3.23.4"
"value": "3.24.1"
},
"replaces": "CoreExVersion"
},
"beef_version": {
"type": "generated",
"generator": "constant",
"parameters": {
"value": "5.14.1"
"value": "5.14.2"
},
"replaces": "BeefVersion"
},
Expand Down
Loading

0 comments on commit 2edb83a

Please sign in to comment.