Skip to content
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
9 changes: 4 additions & 5 deletions .github/workflows/template-build-test-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-target-framework: ["net6.0", "net7.0", "net8.0"]
dotnet-target-framework: ["net8.0", "net9.0"]
include:
- dotnet-install-framework: 6.0.x
dotnet-target-framework: net6.0
- dotnet-install-framework: 7.0.x
dotnet-target-framework: net7.0
- dotnet-install-framework: 8.0.x
dotnet-target-framework: net8.0

- dotnet-install-framework: 9.0.x
dotnet-target-framework: net9.0
env:
source-directory: ${{ inputs.source-directory }}
source-project: ${{ inputs.source-project }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-build-test-solution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest

env:
dotnet-install-framework: 8.0.x
dotnet-install-framework: 9.0.x

defaults:
run:
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup Label="Build Settings">
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<PropertyGroup Label="Compile Settings">
Expand Down
34 changes: 13 additions & 21 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,29 @@

<ItemGroup Label="Microsoft NuGet Packages (All Frameworks)">
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
</ItemGroup>

<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.15" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
</ItemGroup>

<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.4" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.17" />
</ItemGroup>

<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.6" />
</ItemGroup>

<ItemGroup Label="Microsoft NuGet Packages (Test)">
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
</ItemGroup>

<ItemGroup Label="External Testing Packages">
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Moq" Version="4.18.3" />
<PackageVersion Include="Bogus" Version="35.6.3" />
<PackageVersion Include="FluentAssertions" Version="[7.0.0]" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="BlazorFocused.Testing.Logging" Version="1.0.0" />
</ItemGroup>

Expand Down
19 changes: 9 additions & 10 deletions samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
</PropertyGroup>

<ItemGroup Label="Microsoft NuGet Packages (Source)">
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-rc.1.23421.29" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
</ItemGroup>

<ItemGroup Label="Microsoft NuGet Packages (Test)">
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.1.23421.29" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="xunit" Version="2.5.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.6" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
</ItemGroup>

<ItemGroup Label="External Testing Packages">
<PackageVersion Include="Bogus" Version="34.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Moq" Version="4.18.3" />
<PackageVersion Include="Bogus" Version="35.6.3" />
<PackageVersion Include="FluentAssertions" Version="[7.0.0]" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Swashbuckle.AspNetCore" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@baseAddress = https://localhost:7288

GET {{baseAddress}}/ThrowRandomException

###

GET {{baseAddress}}/ThrowCustomClientException?statusCode=400&message=Test%20Exception%20Throw

7 changes: 3 additions & 4 deletions samples/MiddlewareSample/MiddlewareSample.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddOpenApi();

// Register custom exceptions and status codes
builder.Services
Expand All @@ -20,15 +20,14 @@
{
options.CorrelationKey = "X-TestCorrelation-Id";
options.CorrelationKey = CORRELATION_HEADER_KEY;
options.ConfigureCorrelationValue = (httpContext) => { return httpContext.TraceIdentifier; };
options.ConfigureCorrelationValue = (httpContext) => httpContext.TraceIdentifier;
}) // Use this extension for default correlation key/value
.AddException<RandomException>(HttpStatusCode.FailedDependency);

WebApplication app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.MapOpenApi();

// Register Exceptions API Middleware
app.UseExceptionsMiddleware();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"Sample API - Http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5176",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Sample API - Https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"launchUrl": "openapi/v1.json",
"applicationUrl": "https://localhost:7288;http://localhost:5101",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@

namespace BlazorFocused.Exceptions.Middleware.ApplicationBuilder;

internal class ApplicationBuilderMiddleware
internal class ApplicationBuilderMiddleware(RequestDelegate next)
{
private readonly RequestDelegate next;

public ApplicationBuilderMiddleware(RequestDelegate next)
{
this.next = next;
}

public async Task Invoke(
HttpContext httpContext,
IOptions<ExceptionsMiddlewareOptions> exceptionsMiddlewareOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Label="NuGet Metadata">
Expand Down
4 changes: 2 additions & 2 deletions src/Middleware/src/ExceptionsMiddlewareException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class ExceptionsMiddlewareException : Exception
/// <param name="httpStatusCode">Desired status code of a given exception</param>
/// <param name="message">Message that should be logged in case of given exception</param>
/// <remarks>Passed in "message" will also be output to client/user if "clientErrorMessage" not specified</remarks>
public ExceptionsMiddlewareException(HttpStatusCode httpStatusCode, string message) :
protected ExceptionsMiddlewareException(HttpStatusCode httpStatusCode, string message) :
base(message)
{
StatusCode = httpStatusCode;
Expand All @@ -41,7 +41,7 @@ public ExceptionsMiddlewareException(HttpStatusCode httpStatusCode, string messa
/// <param name="message">Message that should be logged in case of given exception</param>
/// <param name="innerException">Inner exception that triggered exception response</param>
/// <remarks>Passed in "message" will also be output to client/user if "clientErrorMessage" not specified</remarks>
public ExceptionsMiddlewareException(HttpStatusCode httpStatusCode, string message, Exception innerException) :
protected ExceptionsMiddlewareException(HttpStatusCode httpStatusCode, string message, Exception innerException) :
base(message, innerException)
{
StatusCode = httpStatusCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down