Skip to content

Commit 6738a92

Browse files
authored
v3.27.0 (#125)
- *Fixed:* The `ValueContentResult.TryCreateValueContentResult` would return `NotModified` where the request `ETag` was `null`; this has been corrected to return `OK` with the resulting `value`. - *Fixed:* The `ValueContentResult.TryCreateValueContentResult` now returns `ExtendedStatusCodeResult` versus `StatusCodeResult` as this offers additional capabilities where required. - *Enhancement:* The `ExtendedStatusCodeResult` and `ExtendedContentResult` now implement `IExtendedActionResult` to standardize access to the `BeforeExtension` and `AfterExtension` functions. - *Enhancement:* Added `WebApiParam.CreateActionResult` helper methods to enable execution of the underlying `ValueContentResult.CreateValueContentResult` (which is no longer public as this was always intended as internal only). - *Fixed:* `PostgresDatabase.OnDbException` corrected to use `PostgresException.MessageText` versus `Message` as it does not include the `SQLSTATE` code. - *Enhancement:* Improve debugging insights by adding `ILogger.LogDebug` start/stop/elapsed for the `InvokerArgs`. - *Fixed*: Updated `System.Text.Json` package depenedency to latest (including related); resolve [Microsoft Security Advisory CVE-2024-43485](GHSA-8g4q-xg66-9fp4).
1 parent 4821c40 commit 6738a92

44 files changed

Lines changed: 614 additions & 184 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Represents the **NuGet** versions.
44

5+
## v3.27.0
6+
- *Fixed:* The `ValueContentResult.TryCreateValueContentResult` would return `NotModified` where the request `ETag` was `null`; this has been corrected to return `OK` with the resulting `value`.
7+
- *Fixed:* The `ValueContentResult.TryCreateValueContentResult` now returns `ExtendedStatusCodeResult` versus `StatusCodeResult` as this offers additional capabilities where required.
8+
- *Enhancement:* The `ExtendedStatusCodeResult` and `ExtendedContentResult` now implement `IExtendedActionResult` to standardize access to the `BeforeExtension` and `AfterExtension` functions.
9+
- *Enhancement:* Added `WebApiParam.CreateActionResult` helper methods to enable execution of the underlying `ValueContentResult.CreateValueContentResult` (which is no longer public as this was always intended as internal only).
10+
- *Fixed:* `PostgresDatabase.OnDbException` corrected to use `PostgresException.MessageText` versus `Message` as it does not include the `SQLSTATE` code.
11+
- *Enhancement:* Improve debugging insights by adding `ILogger.LogDebug` start/stop/elapsed for the `InvokerArgs`.
12+
- *Fixed*: Updated `System.Text.Json` package depenedency to latest (including related); resolve [Microsoft Security Advisory CVE-2024-43485](https://github.com/advisories/GHSA-8g4q-xg66-9fp4).
13+
514
## v3.26.0
615
- *Enhancement:* Enable JSON serialization of database parameter values; added `DatabaseParameterCollection.AddJsonParameter` method and associated `JsonParam`, `JsonParamWhen` and `JsonParamWith` extension methods.
716
- *Enhancement:* Updated (simplified) `EventOutboxEnqueueBase` to pass events to the underlying stored procedures as JSON versus existing TVP removing database dependency on a UDT (user-defined type).

Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>3.26.0</Version>
3+
<Version>3.27.0</Version>
44
<LangVersion>preview</LangVersion>
55
<Authors>Avanade</Authors>
66
<Company>Avanade</Company>

samples/My.Hr/My.Hr.Database/My.Hr.Database.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="DbEx.SqlServer" Version="2.5.9" />
25+
<PackageReference Include="DbEx.SqlServer" Version="2.6.1" />
2626
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
2727
</ItemGroup>
2828

samples/My.Hr/My.Hr.Functions/My.Hr.Functions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="1.5.1" />
99
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
10-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.4.0" />
10+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.4.1" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

samples/My.Hr/My.Hr.UnitTest/My.Hr.UnitTest.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
24-
<PackageReference Include="NUnit" Version="4.1.0" />
25-
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
23+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
24+
<PackageReference Include="NUnit" Version="4.2.2" />
25+
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>

src/CoreEx.AspNetCore/CoreEx.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<Import Project="..\..\Common.targets" />
1414

1515
<ItemGroup>
16-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
16+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

src/CoreEx.AspNetCore/WebApis/ExtendedContentResult.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ namespace CoreEx.AspNetCore.WebApis
1111
/// <summary>
1212
/// Represents an extended <see cref="ContentResult"/> that enables customization of the <see cref="HttpResponse"/>.
1313
/// </summary>
14-
public class ExtendedContentResult : ContentResult
14+
public class ExtendedContentResult : ContentResult, IExtendedActionResult
1515
{
16-
/// <summary>
17-
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
18-
/// </summary>
16+
/// <inheritdoc/>
1917
[JsonIgnore]
2018
public Func<HttpResponse, Task>? BeforeExtension { get; set; }
2119

22-
/// <summary>
23-
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
24-
/// </summary>
20+
/// <inheritdoc/>
2521
[JsonIgnore]
2622
public Func<HttpResponse, Task>? AfterExtension { get; set; }
2723

src/CoreEx.AspNetCore/WebApis/ExtendedStatusCodeResult.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ namespace CoreEx.AspNetCore.WebApis
1212
/// <summary>
1313
/// Represents an extended <see cref="StatusCodeResult"/> that enables customization of the <see cref="HttpResponse"/>.
1414
/// </summary>
15-
/// <param name="statusCode">The <see cref="HttpStatusCode"/>.</param>
16-
public class ExtendedStatusCodeResult(HttpStatusCode statusCode) : StatusCodeResult((int)statusCode)
15+
/// <param name="statusCode">The status code value.</param>
16+
public class ExtendedStatusCodeResult(int statusCode) : StatusCodeResult(statusCode), IExtendedActionResult
1717
{
1818
/// <summary>
19-
/// Gets or sets the <see cref="Microsoft.AspNetCore.Http.Headers.ResponseHeaders.Location"/> <see cref="Uri"/>.
19+
/// Initializes a new instance of the <see cref="ExtendedStatusCodeResult"/> class with the specified <see cref="HttpStatusCode"/>.
2020
/// </summary>
21-
public Uri? Location { get; set; }
21+
/// <param name="statusCode">The <see cref="HttpStatusCode"/>.</param>
22+
public ExtendedStatusCodeResult(HttpStatusCode statusCode) : this((int)statusCode) { }
2223

2324
/// <summary>
24-
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
25+
/// Gets or sets the <see cref="Microsoft.AspNetCore.Http.Headers.ResponseHeaders.Location"/> <see cref="Uri"/>.
2526
/// </summary>
27+
public Uri? Location { get; set; }
28+
29+
/// <inheritdoc/>
2630
[JsonIgnore]
2731
public Func<HttpResponse, Task>? BeforeExtension { get; set; }
2832

29-
/// <summary>
30-
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
31-
/// </summary>
33+
/// <inheritdoc/>
3234
[JsonIgnore]
3335
public Func<HttpResponse, Task>? AfterExtension { get; set; }
3436

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/CoreEx
2+
3+
using Microsoft.AspNetCore.Http;
4+
using Microsoft.AspNetCore.Mvc;
5+
using System;
6+
using System.Text.Json.Serialization;
7+
using System.Threading.Tasks;
8+
9+
namespace CoreEx.AspNetCore.WebApis
10+
{
11+
/// <summary>
12+
/// Extends an <see cref="IActionResult"/> to enable customization of the resulting <see cref="HttpResponse"/> using the <see cref="BeforeExtension"/> and <see cref="AfterExtension"/> functions.
13+
/// </summary>
14+
public interface IExtendedActionResult : IActionResult
15+
{
16+
/// <summary>
17+
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
18+
/// </summary>
19+
[JsonIgnore]
20+
Func<HttpResponse, Task>? BeforeExtension { get; set; }
21+
22+
/// <summary>
23+
/// Gets or sets the function to perform the extended <see cref="HttpResponse"/> customization.
24+
/// </summary>
25+
[JsonIgnore]
26+
Func<HttpResponse, Task>? AfterExtension { get; set; }
27+
}
28+
}

src/CoreEx.AspNetCore/WebApis/ValueContentResult.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override Task ExecuteResultAsync(ActionContext context)
8181
}
8282

8383
/// <summary>
84-
/// Creates the <see cref="IActionResult"/> as either <see cref="ValueContentResult"/> or <see cref="StatusCodeResult"/> as per <see cref="TryCreateValueContentResult"/>; unless <paramref name="value"/> is an instance of <see cref="IActionResult"/> which will return as-is.
84+
/// Creates the <see cref="IActionResult"/> as either <see cref="ValueContentResult"/> or <see cref="ExtendedStatusCodeResult"/> as per <see cref="TryCreateValueContentResult"/>; unless <paramref name="value"/> is an instance of <see cref="IActionResult"/> which will return as-is.
8585
/// </summary>
8686
/// <param name="value">The value.</param>
8787
/// <param name="statusCode">The primary status code where there is a value.</param>
@@ -91,11 +91,11 @@ public override Task ExecuteResultAsync(ActionContext context)
9191
/// <param name="checkForNotModified">Indicates whether to check for <see cref="HttpStatusCode.NotModified"/> by comparing request and response <see cref="IETag.ETag"/> values.</param>
9292
/// <param name="location">The <see cref="Microsoft.AspNetCore.Http.Headers.ResponseHeaders.Location"/> <see cref="Uri"/>.</param>
9393
/// <returns>The <see cref="IActionResult"/>.</returns>
94-
public static IActionResult CreateResult<T>(T value, HttpStatusCode statusCode, HttpStatusCode? alternateStatusCode, IJsonSerializer jsonSerializer, WebApiRequestOptions requestOptions, bool checkForNotModified, Uri? location)
94+
internal static IActionResult CreateResult<T>(T value, HttpStatusCode statusCode, HttpStatusCode? alternateStatusCode, IJsonSerializer jsonSerializer, WebApiRequestOptions requestOptions, bool checkForNotModified, Uri? location)
9595
=> TryCreateValueContentResult(value, statusCode, alternateStatusCode, jsonSerializer, requestOptions, checkForNotModified, location, out var pr, out var ar) ? pr! : ar!;
9696

9797
/// <summary>
98-
/// Try and create an <see cref="IActionResult"/> as either <see cref="ValueContentResult"/> or <see cref="StatusCodeResult"/> as per <see cref="TryCreateValueContentResult"/>; unless <paramref name="value"/> is an instance of <see cref="IActionResult"/> which will return as-is.
98+
/// Try and create an <see cref="IActionResult"/> as either <see cref="ValueContentResult"/> or <see cref="ExtendedStatusCodeResult"/> as per <see cref="TryCreateValueContentResult"/>; unless <paramref name="value"/> is an instance of <see cref="IActionResult"/> which will return as-is.
9999
/// </summary>
100100
/// <param name="value">The value.</param>
101101
/// <param name="statusCode">The primary status code where there is a value.</param>
@@ -107,7 +107,7 @@ public static IActionResult CreateResult<T>(T value, HttpStatusCode statusCode,
107107
/// <param name="primaryResult">The <see cref="IActionResult"/> where created.</param>
108108
/// <param name="alternateResult">The alternate result where no <paramref name="primaryResult"/>.</param>
109109
/// <returns><c>true</c> indicates that the <paramref name="primaryResult"/> was created; otherwise, <c>false</c> for <paramref name="alternateResult"/> creation.</returns>
110-
public static bool TryCreateValueContentResult<T>(T value, HttpStatusCode statusCode, HttpStatusCode? alternateStatusCode, IJsonSerializer jsonSerializer, WebApiRequestOptions requestOptions, bool checkForNotModified, Uri? location, out IActionResult? primaryResult, out IActionResult? alternateResult)
110+
internal static bool TryCreateValueContentResult<T>(T value, HttpStatusCode statusCode, HttpStatusCode? alternateStatusCode, IJsonSerializer jsonSerializer, WebApiRequestOptions requestOptions, bool checkForNotModified, Uri? location, out IActionResult? primaryResult, out IActionResult? alternateResult)
111111
{
112112
if (value is Results.IResult)
113113
throw new ArgumentException($"The {nameof(value)} must not implement {nameof(Results.IResult)}; the underlying {nameof(Results.IResult.Value)} must be unwrapped before invoking.", nameof(value));
@@ -182,10 +182,10 @@ public static bool TryCreateValueContentResult<T>(T value, HttpStatusCode status
182182
ExecutionContext.Current.IsTextSerializationEnabled = isTextSerializationEnabled;
183183

184184
// Check for not-modified and return status accordingly.
185-
if (checkForNotModified && result.etag == requestOptions.ETag)
185+
if (checkForNotModified && requestOptions.ETag is not null && result.etag == requestOptions.ETag)
186186
{
187187
primaryResult = null;
188-
alternateResult = new StatusCodeResult((int)HttpStatusCode.NotModified);
188+
alternateResult = new ExtendedStatusCodeResult(HttpStatusCode.NotModified);
189189
return false;
190190
}
191191

0 commit comments

Comments
 (0)