Skip to content

Commit 2823258

Browse files
authored
Merge pull request #348 from exceptionless/feature/modernize-aspnetcore-platform-deps
refactor(platforms): modernize ASP.NET Core integration and upgrade to .NET 10
2 parents 1129ee2 + 8cfa7a2 commit 2823258

69 files changed

Lines changed: 875 additions & 387 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Exceptionless .NET Clients
22

3-
[![Build Windows](https://github.com/exceptionless/Exceptionless.Net/workflows/Build%20Windows/badge.svg?branch=master)](https://github.com/Exceptionless/Exceptionless.Net/actions)
4-
[![Build OSX](https://github.com/exceptionless/Exceptionless.Net/workflows/Build%20OSX/badge.svg)](https://github.com/Exceptionless/Exceptionless.Net/actions)
5-
[![Build Linux](https://github.com/exceptionless/Exceptionless.Net/workflows/Build%20Linux/badge.svg)](https://github.com/Exceptionless/Exceptionless.Net/actions)
3+
[![Build Windows](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-windows.yml/badge.svg?branch=main)](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-windows.yml)
4+
[![Build OSX](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-osx.yml/badge.svg?branch=main)](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-osx.yml)
5+
[![Build Linux](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-linux.yml/badge.svg?branch=main)](https://github.com/Exceptionless/Exceptionless.Net/actions/workflows/build-linux.yml)
66
[![NuGet Version](http://img.shields.io/nuget/v/Exceptionless.svg?style=flat)](https://www.nuget.org/packages/Exceptionless/)
77
[![Discord](https://img.shields.io/discord/715744504891703319)](https://discord.gg/6HxgFCx)
88

@@ -29,8 +29,8 @@ editor design surfaces are available.
2929

3030
1. You will need to install:
3131
1. [Visual Studio 2022](https://visualstudio.microsoft.com/vs/community/)
32-
2. [.NET Core 6.x & 8.x SDK with VS Tooling](https://dotnet.microsoft.com/download)
33-
3. [.NET Framework 4.6.2 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/net462)
32+
2. [.NET 10 SDK with Visual Studio tooling](https://dotnet.microsoft.com/download)
33+
3. [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/net472)
3434
2. Open the `Exceptionless.Net.slnx` Visual Studio solution file.
3535
3. Select `Exceptionless.SampleConsole` as the startup project.
3636
4. Run the project by pressing `F5` to start the console.
@@ -43,7 +43,7 @@ build windows specific packages.
4343

4444
1. You will need to install:
4545
1. [Visual Studio Code](https://code.visualstudio.com)
46-
2. [.NET Core 6.x & 8.x SDK with VS Tooling](https://dotnet.microsoft.com/download)
46+
2. [.NET 10 SDK](https://dotnet.microsoft.com/download)
4747
2. Open the cloned Exceptionless.Net folder.
4848
3. Run the `Exceptionless.SampleConsole` project by pressing `F5` to start the console.
4949

build/common.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
1818
<PackageIcon>exceptionless-icon.png</PackageIcon>
1919
<PackageTags>Exceptionless;Error;Error-Handling;Error-Handler;Error-Reporting;Error-Management;Error-Monitoring;Handling;Management;Monitoring;Report;Reporting;Crash-Reporting;Exception;Exception-Handling;Exception-Handler;Exception-Reporting;Exceptions;Log;Logs;Logging;Unhandled;Unhandled-Exceptions;Feature;Configuration;Debug;FeatureToggle;Metrics;ELMAH</PackageTags>
20-
<PackageLicenseExpression>APACHE-2.0</PackageLicenseExpression>
20+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
2121
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
2222
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2323
<EmbedUntrackedSources>true</EmbedUntrackedSources>
@@ -41,9 +41,9 @@
4141
</PropertyGroup>
4242

4343
<ItemGroup>
44-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
45-
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
46-
<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All" />
44+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All"/>
45+
<PackageReference Include="AsyncFixer" Version="2.1.0" PrivateAssets="All" />
46+
<PackageReference Include="MinVer" Version="7.0.0" PrivateAssets="All" />
4747
</ItemGroup>
4848

4949
<ItemGroup>

samples/Exceptionless.SampleAspNetCore/Controllers/ValuesController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ValuesController : Controller {
1010
private readonly ILogger _logger;
1111

1212
public ValuesController(ExceptionlessClient exceptionlessClient, ILogger<ValuesController> logger) {
13-
// ExceptionlessClient instance from DI that was registered with the AddExceptionless call in Startup.ConfigureServices
13+
// ExceptionlessClient instance from DI that was registered with the builder.AddExceptionless call in Program.cs.
1414
_exceptionlessClient = exceptionlessClient;
1515
_logger = logger;
1616
}
@@ -21,7 +21,7 @@ public Dictionary<string, string> Get() {
2121
// Submit a feature usage event directly using the client instance that is injected from the DI container.
2222
_exceptionlessClient.SubmitFeatureUsage("ValuesController_Get");
2323

24-
// This log message will get sent to Exceptionless since Exceptionless has be added to the logging system in Program.cs.
24+
// This log message will get sent to Exceptionless since Exceptionless has been added to the logging system in Program.cs.
2525
_logger.LogWarning("Test warning message");
2626

2727
try {
@@ -42,7 +42,8 @@ public Dictionary<string, string> Get() {
4242
handledException.ToExceptionless().Submit();
4343
}
4444

45-
// Unhandled exceptions will get reported since called UseExceptionless in the Startup.cs which registers a listener for unhandled exceptions.
45+
// Unhandled exceptions will get reported because Program.cs enables the built-in exception handler pipeline
46+
// and wires Exceptionless into both ASP.NET Core diagnostics and middleware hooks.
4647
throw new Exception($"Unhandled Exception: {Guid.NewGuid()}");
4748
}
4849
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
</PropertyGroup>
55

66
<ItemGroup>
77
<ProjectReference Include="..\..\src\Platforms\Exceptionless.AspNetCore\Exceptionless.AspNetCore.csproj" />
88
<ProjectReference Include="..\..\src\Platforms\Exceptionless.Extensions.Logging\Exceptionless.Extensions.Logging.csproj" />
99
</ItemGroup>
10-
</Project>
10+
</Project>
Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1-
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Hosting;
3-
4-
namespace Exceptionless.SampleAspNetCore {
5-
public class Program {
6-
public static void Main(string[] args) {
7-
CreateHostBuilder(args).Build().Run();
8-
}
9-
10-
public static IHostBuilder CreateHostBuilder(string[] args) =>
11-
Host.CreateDefaultBuilder(args)
12-
.ConfigureLogging(b => {
13-
// By default sends warning and error log messages to Exceptionless.
14-
// Log levels can be controlled remotely per log source from the Exceptionless app in near real-time.
15-
b.AddExceptionless();
16-
})
17-
.ConfigureWebHostDefaults(webBuilder => {
18-
webBuilder.UseStartup<Startup>();
19-
});
20-
}
21-
}
1+
using Exceptionless;
2+
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Logging;
5+
6+
var builder = WebApplication.CreateBuilder(args);
7+
8+
// By default sends warning and error log messages to Exceptionless.
9+
// Log levels can be controlled remotely per log source from the Exceptionless app in near real-time.
10+
builder.Logging.AddExceptionless();
11+
12+
// Reads settings from IConfiguration then adds additional configuration from this lambda.
13+
// This also configures ExceptionlessClient.Default, host shutdown queue flushing,
14+
// and automatically registers the Exceptionless IExceptionHandler.
15+
builder.AddExceptionless(c => c.DefaultData["Startup"] = "heyyy");
16+
// OR
17+
// builder.AddExceptionless();
18+
// OR
19+
// builder.AddExceptionless("API_KEY_HERE");
20+
21+
// Required: configures the response format for unhandled exceptions (e.g., RFC 7807 Problem Details).
22+
builder.Services.AddProblemDetails();
23+
24+
// This is normal ASP.NET Core code.
25+
builder.Services.AddControllers();
26+
27+
var app = builder.Build();
28+
29+
// Uses the built-in exception handler pipeline, with Exceptionless capturing via IExceptionHandler.
30+
app.UseExceptionHandler();
31+
32+
// Adds Exceptionless middleware for diagnostics, 404 tracking, and queue processing.
33+
app.UseExceptionless();
34+
35+
app.MapControllers();
36+
37+
app.Run();

samples/Exceptionless.SampleAspNetCore/Startup.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

samples/Exceptionless.SampleBlazorWebAssemblyApp/Exceptionless.SampleBlazorWebAssemblyApp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.5" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.5" PrivateAssets="all" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

samples/Exceptionless.SampleConsole/Exceptionless.SampleConsole.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<AssemblyName>Exceptionless.SampleConsole</AssemblyName>
66
<OutputType>Exe</OutputType>
77
<DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_0</DefineConstants>
@@ -20,11 +20,11 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Exceptionless.DateTimeExtensions" Version="3.4.3" />
24-
<PackageReference Include="Exceptionless.RandomData" Version="1.2.2" />
23+
<PackageReference Include="Exceptionless.DateTimeExtensions" Version="6.0.1" />
24+
<PackageReference Include="Exceptionless.RandomData" Version="2.0.1" />
2525
</ItemGroup>
2626

2727
<ItemGroup>
2828
<Folder Include="Properties\" />
2929
</ItemGroup>
30-
</Project>
30+
</Project>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
</PropertyGroup>
55

66
<ItemGroup>
77
<ProjectReference Include="..\..\src\Platforms\Exceptionless.Extensions.Hosting\Exceptionless.Extensions.Hosting.csproj" />
88
<ProjectReference Include="..\..\src\Platforms\Exceptionless.Extensions.Logging\Exceptionless.Extensions.Logging.csproj" />
99
</ItemGroup>
10-
</Project>
10+
</Project>

samples/Exceptionless.SampleHosting/Program.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
1818
// Log levels can be controlled remotely per log source from the Exceptionless app in near real-time.
1919
builder.AddExceptionless();
2020
})
21-
.UseExceptionless() // listens for host shutdown and
21+
.UseExceptionless() // initializes the client and flushes the queue during host shutdown
2222
.ConfigureServices(services => {
2323
// Reads settings from IConfiguration then adds additional configuration from this lambda.
2424
// This also configures ExceptionlessClient.Default
@@ -64,11 +64,13 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
6464
handledException.ToExceptionless().Submit();
6565
}
6666

67-
// Unhandled exceptions will get reported since called UseExceptionless in the Startup.cs which registers a listener for unhandled exceptions.
67+
// This simulates an unhandled exception. Host-level Exceptionless integration reports
68+
// host/AppDomain-level unhandled exceptions; ASP.NET Core request-pipeline exceptions
69+
// require the ASP.NET Core integration and UseExceptionHandler.
6870
throw new Exception($"Unhandled Exception: {Guid.NewGuid()}");
6971
});
7072
});
7173
});
7274
});
7375
}
74-
}
76+
}

0 commit comments

Comments
 (0)