Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.14.1 #94

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Represents the **NuGet** versions.

## v3.14.1
- *Fixed*: The `Result.ValidatesAsync` extension method signature has had the value nullability corrected to enable fluent-style method-chaining.
- *Fixed*: The fully qualified type and property name is now correctly used as the `LText.KeyAndOrText` when creating within the `PropertyExpression<TEntity, TProperty>` to enable a qualified _key_ that can be used by the `ITextProvider` to substitute the text at runtime; the existing text fallback behavior remains such that an appropriate text is used. The `PropertyExpression.CreatePropertyLTextKey` function can be overridden to change this behavior.

## v3.14.0
- *Enhancement*: Planned feature obsoletion. The `TypedHttpClientBase` methods `WithRetry`, `WithTimeout`, `WithCustomRetryPolicy` and `WithMaxRetryDelay` are now marked as obsolete and will result in a compile-time warning. Related `TypedHttpClientOptions`, `HttpRequestLogger` and `SettingsBase` capabilities have also been obsoleted.
- Why? Primarily based on Microsoft guidance around [`IHttpClientFactory`](https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory) usage. Specifically advances in native HTTP [resilency](https://learn.microsoft.com/en-us/dotnet/core/resilience/http-resilience) support, and the [.NET 8 networking improvements](https://devblogs.microsoft.com/dotnet/dotnet-8-networking-improvements/).
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>3.14.0</Version>
<Version>3.14.1</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
3 changes: 2 additions & 1 deletion samples/My.Hr/My.Hr.Database/My.Hr.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DbEx.SqlServer" Version="2.4.0" />
<PackageReference Include="DbEx.SqlServer" Version="2.5.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions samples/My.Hr/My.Hr.UnitTest/My.Hr.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.0.1">
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
10 changes: 5 additions & 5 deletions src/CoreEx.Azure/CoreEx.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.8.2" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.2" />
<PackageReference Include="Azure.Data.Tables" Version="12.8.3" />
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.4" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.16.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.13.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.14.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="7.1.0" />
</ItemGroup>

<Import Project="..\..\Common.targets" />
Expand Down
4 changes: 2 additions & 2 deletions src/CoreEx.Cosmos/CoreEx.Cosmos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<Import Project="..\..\Common.targets" />

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.38.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.38.1" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="8.0.0" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.5" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<Import Project="..\..\Common.targets" />

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.26" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.28" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Import Project="..\..\Common.targets" />

<ItemGroup>
<PackageReference Include="UnitTestEx.NUnit" Version="4.2.0" />
<PackageReference Include="UnitTestEx.NUnit" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreEx.UnitTesting/CoreEx.UnitTesting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="UnitTestEx" Version="4.2.0" />
<PackageReference Include="UnitTestEx" Version="4.3.0" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions src/CoreEx.Validation/IEntityRule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx

using System;
using System.Threading;
using System.Threading.Tasks;

namespace CoreEx.Validation
{
/// <summary>
/// Provides a validation rule for an entity.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
public interface IEntityRule<TEntity> where TEntity : class
{
/// <summary>
/// Validates an entity given a <see cref="ValidationContext{TEntity}"/>.
/// </summary>
/// <param name="context">The <see cref="ValidationContext{TEntity}"/></param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
Task ValidateAsync(ValidationContext<TEntity> context, CancellationToken cancellationToken);
}
}
40 changes: 33 additions & 7 deletions src/CoreEx.Validation/IPropertyRule.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx

using System;
using CoreEx.Localization;
using System.Threading;
using System.Threading.Tasks;

namespace CoreEx.Validation
{
/// <summary>
/// Provides a validation rule for a property.
/// Enables a validation rule for an entity property.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
public interface IPropertyRule<TEntity> where TEntity : class
public interface IPropertyRule
{
/// <summary>
/// Validates an entity given a <see cref="ValidationContext{TEntity}"/>.
/// Gets the property name.
/// </summary>
public string Name { get; }

/// <summary>
/// Gets the JSON property name.
/// </summary>
public string JsonName { get; }

/// <summary>
/// Gets or sets the friendly text name used in validation messages.
/// </summary>
public LText Text { get; set; }

/// <summary>
/// Executes the validation for the property value.
/// </summary>
/// <param name="context">The <see cref="ValidationContext{TEntity}"/></param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
Task ValidateAsync(ValidationContext<TEntity> context, CancellationToken cancellationToken);
/// <returns>A <see cref="ValueValidatorResult{TEntity, TProperty}"/>.</returns>
Task<IValidationResult> ValidateAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Executes the validation for the property value.
/// </summary>
/// <param name="throwOnError">Indicates whether to automatically throw a <see cref="ValidationException"/> where <see cref="IValidationResult.HasErrors"/>.</param>
/// <param name="cancellationToken">>The <see cref="CancellationToken"/>.</param>
/// <returns>A <see cref="ValueValidatorResult{TEntity, TProperty}"/>.</returns>
public async Task<IValidationResult> ValidateAsync(bool throwOnError, CancellationToken cancellationToken = default)
{
var ir = await ValidateAsync(cancellationToken).ConfigureAwait(false);
return throwOnError ? ir.ThrowOnError() : ir;
}
}
}
39 changes: 1 addition & 38 deletions src/CoreEx.Validation/IPropertyRuleT2.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx

using CoreEx.Localization;
using CoreEx.Validation.Clauses;
using CoreEx.Validation.Rules;
using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace CoreEx.Validation
{
Expand All @@ -15,23 +12,8 @@ namespace CoreEx.Validation
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TProperty">The property <see cref="Type"/>.</typeparam>
public interface IPropertyRule<TEntity, in TProperty> where TEntity : class
public interface IPropertyRule<TEntity, in TProperty> : IPropertyRule where TEntity : class
{
/// <summary>
/// Gets the property name.
/// </summary>
public string Name { get; }

/// <summary>
/// Gets the JSON property name.
/// </summary>
public string JsonName { get; }

/// <summary>
/// Gets or sets the friendly text name used in validation messages.
/// </summary>
public LText Text { get; set; }

/// <summary>
/// Adds a clause (<see cref="IPropertyRuleClause{TEntity, TProperty}"/>) to the rule.
/// </summary>
Expand All @@ -45,25 +27,6 @@ public interface IPropertyRule<TEntity, in TProperty> where TEntity : class
/// <returns>The <see cref="PropertyRuleBase{TEntity, TProperty}"/>.</returns>
IPropertyRule<TEntity, TProperty> AddRule(IValueRule<TEntity, TProperty> rule);

/// <summary>
/// Executes the validation for the property value.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <returns>A <see cref="ValueValidatorResult{TEntity, TProperty}"/>.</returns>
Task<IValidationResult> ValidateAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Executes the validation for the property value.
/// </summary>
/// <param name="throwOnError">Indicates whether to automatically throw a <see cref="ValidationException"/> where <see cref="IValidationResult.HasErrors"/>.</param>
/// <param name="cancellationToken">>The <see cref="CancellationToken"/>.</param>
/// <returns>A <see cref="ValueValidatorResult{TEntity, TProperty}"/>.</returns>
public async Task<IValidationResult> ValidateAsync(bool throwOnError, CancellationToken cancellationToken = default)
{
var ir = await ValidateAsync(cancellationToken).ConfigureAwait(false);
return throwOnError ? ir.ThrowOnError() : ir;
}

/// <summary>
/// Adds a <see cref="DependsOnClause{TEntity, TProperty}"/> to this <see cref="PropertyRule{TEntity, TProperty}"/> in that another specified property of the entity must have a non-default value (and not have a validation error) to continue.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreEx.Validation/IncludeBaseRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace CoreEx.Validation
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TInclude">The entity base <see cref="Type"/>.</typeparam>
public class IncludeBaseRule<TEntity, TInclude> : ValidatorBase<TEntity>, IPropertyRule<TEntity> where TEntity : class where TInclude : class
public class IncludeBaseRule<TEntity, TInclude> : ValidatorBase<TEntity>, IEntityRule<TEntity> where TEntity : class where TInclude : class
{
private readonly IValidatorEx<TInclude> _include;

Expand Down
2 changes: 1 addition & 1 deletion src/CoreEx.Validation/PropertyRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace CoreEx.Validation
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TProperty">The property <see cref="Type"/>.</typeparam>
public class PropertyRule<TEntity, TProperty> : PropertyRuleBase<TEntity, TProperty>, IPropertyRule<TEntity>, IValueRule<TEntity, TProperty> where TEntity : class
public class PropertyRule<TEntity, TProperty> : PropertyRuleBase<TEntity, TProperty>, IEntityRule<TEntity>, IValueRule<TEntity, TProperty> where TEntity : class
{
private readonly PropertyExpression<TEntity, TProperty> _property;

Expand Down
2 changes: 1 addition & 1 deletion src/CoreEx.Validation/PropertyRuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ protected async Task InvokeAsync(PropertyContext<TEntity, TProperty> context, Ca
public abstract Task<ValueValidatorResult<TEntity, TProperty>> ValidateAsync(CancellationToken cancellationToken = default);

/// <inheritdoc/>
async Task<IValidationResult> IPropertyRule<TEntity, TProperty>.ValidateAsync(CancellationToken cancellationToken) => await ValidateAsync(cancellationToken).ConfigureAwait(false);
async Task<IValidationResult> IPropertyRule.ValidateAsync(CancellationToken cancellationToken) => await ValidateAsync(cancellationToken).ConfigureAwait(false);
}
}
2 changes: 1 addition & 1 deletion src/CoreEx.Validation/RuleSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CoreEx.Validation
/// Represents a validation rule set for an entity, in that it groups one or more <see cref="Rules"/> together for a specified condition.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
public class RuleSet<TEntity> : ValidatorBase<TEntity>, IPropertyRule<TEntity> where TEntity : class
public class RuleSet<TEntity> : ValidatorBase<TEntity>, IEntityRule<TEntity> where TEntity : class
{
/// <summary>
/// Initializes a new instance of the <see cref="RuleSet{TEntity}"/> class to be invoked where the predicate is true.
Expand Down
Loading
Loading